DWG to PDF conversion

Aspose.CAD Cloud is a RESTFul API providing the capabilities to manipulate existing AutoCAD files (DWG, DWF, DXF, DGN, DWT, IGES (IGS), PLT, Industry Foundation Classes (IFC) and STereoLithography (STL)). It also allows you to fetch image information of existing CAD drawings. Resize CAD images, flip CAD diagrams, or rotate CAD sketches with ease. Furthermore, it also enables you to convert DWG and DXF to PDF as well as raster images (BMP, PNG, JPG, JPEG, JPEG2000, TIF, TIFF, PSD, GIF, and WMF).

AutoCAD to PDF Conversion, Faster than ever!

AutoCAD® is computer-aided design (CAD) software that architects, engineers, and construction professionals rely on to create precise 2D and 3D drawings and is quite famous due to its support for popular drawing formats. However during collaboration, you need to share the documents for review/feedback and in order to view CAD/DWG files, you need to have specific applications that incur costs related to installation effort as well as license cost. So a viable solution can be the conversion of files to PDF format as the PDF format, preserves its layout on all platforms.

Aspose.CAD Cloud offers the capabilities to convert supported AutoCAD formats to PDF format with fewer code lines. Following is the list of features currently supported by API

  • Enhanced conversion quality by Smart Object Recognition
  • Retaining the accuracy of lines, arcs, and True Type texts
  • Accept single-sheet and multi-sheet CAD drawings

All Aspose APIs are protected, so enter a valid Client_ID and Client_Secret to access them. They can be found once you have subscribed over dashboard.aspose.cloud.

cURL command

// First get JWT authentication token

curl -v "https://api.aspose.cloud/oauth2/token" \
-X POST \
-d 'grant_type=client_credentials&client_id=xxx-xxxx-xxx-&client_secret=xxxxxx' \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

// command to convert DWG to PDF format

curl -v "https://api.aspose.cloud/v1.1/cad/ENFRIADOR.dwg/saveAs?format=pdf" \
-X GET \
-H "Content-Type: application/json" \
-H "Accept: multipart/form-data" \
-H "Authorization: Bearer <JWT Token>" \
-o Resultant.pdf

C#.NET

Aspose.CAD Cloud REST API is also available in specific programming language SDK. The specified below code shows steps to load and convert the DWG file to PDF format.

  1. First, we need to create an object of CADApi while providing ClientID and ClientSecret as arguments
  2. Then call the method GetImageSaveAsRequest(..) taking input DWG file and resultant file names as arguments
  3. Call the method GetImageSaveAs(..) using CADApi object to initialize the conversion operation
  4. Save the resultant stream to local system storage

For testing purposes, you may download the input ENFRIADOR.dwg and Resultant.pdf files.

AutoCAD to JPEG Conversion

Aspose.CAD Cloud is equally powerful when it comes to the conversion of CAD files to JPEG format. Similar to the conversion of DWG to PDF, the conversion to raster images can be accomplished through fewer code lines.

In order to perform the conversion, you may try using either of the following available options

  • GetImageSaveAs(…) - provides the capabilities to load CAD files available on Cloud storage and perform the conversion. The mandatory parameters required by API are

    • name - filename of drawing

    • format - Output file format (we will be providing PDF here)

      Other optional parameters include

    • folder - Original drawing folder

    • storage - File storage which has to be used

    • rasterOptions - The raster options as Base64 string

    • outPath - Path to updated file, if this is empty, the response contains streamed image

  • PostImageSaveAs(…) - Export existing images to another format, where the Image is passed as a request body. The mandatory parameters required by API are

    • drawingData - filename of drawing

    • format - Output file format (we will be providing PDF here)

      Other optional parameters include

    • storage - File storage which has to be used

    • rasterOptions - The raster options as Base64 string

    • outPath - Path to updated file, if this is empty, the response contains streamed image

cURL command

In the following example, the Post HTTP request is used where an input file is provided as argument and conversion is performed.

// First get JWT authentication token
curl -v "https://api.aspose.cloud/oauth2/token" \
-X POST \
-d 'grant_type=client_credentials&client_id=xxxxx&client_secret=xxxxxxx' \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

// command to convert GDN to JPEG format

curl -v "https://api.aspose.cloud/v1.1/cad/saveAs?format=jpeg" \
-X POST \
-T Nikon_D90_Camera.dgn \
-H "Content-Type: multipart/form-data" \
-H "Accept: multipart/form-data" \
-H "Authorization: Bearer <JWT Token>" \
-o Converted.jpeg

C#.NET

For reference, the input and output files are attached. Nikon_D90_Camera.dgn and Output.png.

Convert AutoCAD to PNG

In order to perform the conversion of AutoCAD files to PNG (Portable Network Graphics) format, all you need to do is provide output format as PNG in the above-specified cURL commands and code snippet.

We also recommend visiting the following links to learn more about: