Convert DWG to DWF using Java REST API

This short guide explains how to convert DWG to DWF using Java REST API. The transformation of DWG to DWF using Java Low Code API turns your editable CAD drawing into a lightweight, shareable, read-only file for easy viewing, printing, and markup without exposing the original. You will perform his conversion with the help of a Dotjava-based Cloud SDK.

Prerequisite

Steps to Convert DWG File to DXF using Java-based API

  1. Create a CadApi instance with your App Key, App SID, and baseUrl
  2. Point inputPath to the source DWG and outputPath to the target DWF file
  3. Open the DWG, copy it into a MemoryStream, and reset Position to 0
  4. Build a PutDrawingDwfRequest with the prepared MemoryStream
  5. Call cadApi.PutDrawingDwf(request) to obtain the converted DWF as a stream
  6. Create the destination file and copy the result stream to the outputPath

These steps have summarized the process to change DWG in DWF using Java-based API. First, set up CadApi with your credentials and point it to your DWG file and the DWF you want to create. Then load the DWG into memory, send it with PutDrawingDwfRequest to convert, and save the returned stream as your DWF.

Code for AutoCAD to DWF Converter using Java REST Interface

This code sample has demonstrated the process to develop a DWG to DWF converter online using Java REST API. The source file is loaded directly from the disk storage; however, you may upload multiple files into the Cloud storage and perform the transformations for the already uploaded files. You may supply optional params such as target page size/DPI, background color, rotation, zoom/scale, etc., using the extra parameters in the PutDrawingDwfRequest() method.

This tutorial has taught us the conversion of DWG to DWF. To transform a DWG file to DXF, refer to the article on Convert DWG into DXF using Java REST API.

 English