DWG Drawings

Exporting DWG Drawings to PDF

Aspose.CAD for .NET API can load AutoCAD drawings in DWG format, and convert it to PDF. This topic explains the usage of Aspose.CAD API to achieve the conversion of DWG to PDF format through simple steps as defined ahead.

DWG File Format

A DWG is a binary file that contains vector image data and metadata. The vector image data provides instructions to the CAD application about how to display the DWG; the metadata may contain a variety of information about the file including location-specific data and also client data. Open Specifications for DWG file format can be found in this PDF

Convert DWG Files to PDF

The following simple steps are required to convert DWG to PDF.

  1. Load the DWG file into an instance of Image.
  2. Create an object of the CadRasterizationOptions class and set the PageHeight & PageWidth properties.
  3. Create an object of the PdfOptions class and set the VectorRasterizationOptions property.
  4. Call Image.Save while passing an object of PdfOptions as the second parameter.

The code sample below shows how to export DWG Drawings to PDF.

Create Single PDF with Different Layout Sizes

Aspose.CAD for .NET allows you to convert DWG file to a single PDF with different layout sizes. This approach works as follows:

  1. Load a DWG file using the Aspose.CAD.Image.Load factory method.
  2. Create an instance of the CadRasterizationOptions class and set the resultant page height and width.
  3. Add required LayoutPageSizes for the CadRasterizationOptions object.
  4. Create an instance of PdfOptions class and set its VectorRasterizationOptions property.
  5. Export the image to PDF using the Image.Save() method.

The code sample below shows how to create a single PDF with different layouts.

Supported AutoCAD Primitives

The following AutoCAD primitives are supported.

  • TEXT
  • MTEXT
  • ATTDEF
  • ATTRIB
  • ARC
  • ELLIPSE
  • HATCH
  • LEADER
  • POINT
  • VERTEX 2D
  • VERTEX 3D
  • POLYLINE 2D
  • LWPOLYLINE
  • RAY
  • CIRCLE
  • DIMENSION ORDINATE
  • DIMENSION LINEAR
  • DIMENSION ALIGNED
  • DIMENSION ANG 3Pt
  • DIMENSION ANG 2Ln
  • DIMENSION RADIUS
  • DIMENSION DIAMETER
  • SHAPE
  • SOLID
  • SPLINE
  • MLINE
  • LINE
  • XLINE
  • STYLE
  • DIMSTYLE
  • LTYPE
  • MLINESTYLE
  • LAYER
  • VIEWPORT
  • LAYOUT

Exporting Specific DWG Layout to PDF

This approach works as follows:

  1. Load a DWG file using the Aspose.CAD.Image.Load factory method.
  2. Create an instance of the CadRasterizationOptions class and set the resultant page height and width.
  3. Set the Layouts property for the CadRasterizationOptions object.
  4. Create an instance of PdfOptions class and set its VectorRasterizationOptions property.
  5. Export the image to PDF using the Image.Save() method.

The code sample below shows how to convert a specific layout of DWG to PDF.

Render DWG document by specifying coordinates

Aspose.CAD for .NET API now provides a feature to render DWG documents by providing coordinates of the width and height of the document.

The code sample below shows how to render a DWG document.

Exporting DWG to Raster or PDF using Fixed Size

Aspose.CAD for .NET API can load AutoCAD drawings in DWG format, and convert it to PDF or Raster using fixed size.

The code sample below shows how to implement this feature.

Exporting DWG to PDF/A and PDF/E

This approach works as follows:

  1. Load a DWG file using the Aspose.CAD.Image.Load factory method.
  2. Create an instance of the CadRasterizationOptions class.
  3. Create an instance of PdfOptions class and set its VectorRasterizationOptions property.
  4. Set PDF compliance property and save it.
  5. Export the image to PDF using the Image.Save() method.

The code sample below shows how to convert a DWG file to PDF/A and PDF/E.

Support for rounded hidden lines when exporting DWG/DXF to BMP and PDF

This approach works as follows:

  1. Load a DWG file using the Aspose.CAD.Image.Load factory method.
  2. Create an instance of the CadRasterizationOptions class and set the resultant page height and width.
  3. Create an instance of PdfOptions class and set its VectorRasterizationOptions property.
  4. Export the image to PDF using the Image.Save() method.

The code sample below shows how to implement this feature.

Support for setting print area for DWG image in exported PDF

Aspose.CAD for .NET API can load AutoCAD drawings in DWG format, and convert it to PDF. This topic explains the usage of Aspose.CAD API to achieve the support for setting a print area for the DWG image in exported PDF.

The code sample below shows how to implement this feature.

Support for reading XREF metadata for DWG file

  1. Load a DWG file using the Aspose.CAD.Image.Load factory method.
  2. Traverse through every image entity.
  3. If an entity is CadUnderlay than XREF entity with metadata.

The code sample below shows how to achieve this feature.

The property CadRasterizationOptions.Layouts is of type string array so you may specify more than one layouts at a time for possible conversion to PDF format. While specifying multiple layouts for the CadRasterizationOptions.Layouts property, the resultant PDF would have multiple pages, where each page represents an individual AutoCAD layout.

List All Layouts

You may list all the layouts present in an AutoCAD drawing using the following code snippet.

Accessing underlay Flags for DWG Format

Aspose.CAD for .NET has implemented the underlay flags for DWG format and allows developers to access them. Following is the simple code demonstration.

Support for DWG Entities

Aspose.CAD for .NET API can load AutoCAD drawings in DWG format and support different entities to work with.

Support for MLeader Entity

A DWG is a binary file that contains vector image data and metadata. There are different entities in a DWG file. The following section describes an example of working with MLeader entity inside the DWG file.

Support for Exporting DWG Entity to Image

A DWG is a binary file that contains vector image data and metadata. There are different entities in a DWG file. The following section describes an example of exporting a particular DWG entity to the image.

Support for Adding text in DWG

Aspose.CAD for .NET API can load AutoCAD drawings in DWG format and support different entities to work with. A DWG is a binary file that contains vector image data and metadata. There are different entities in a DWG file. The following section describes how can we add text inside the DWG file.

Support for Import Image to DWG File

Aspose.CAD for .NET API can load AutoCAD drawings in DWG format and support different entities to work with. A DWG is a binary file that contains vector image data and metadata. There are different entities in a DWG file. The following section describes how can we import images inside the DWG file.

Support for Mesh in DWG

Aspose.CAD for .NET API can now access the entities supporting mesh which include CadPolyFaceMesh and CadPolygonMesh types. The following example describes how can we access the mesh types.

Convert DWG Drawings to DXF

Aspose.CAD provides the feature to load AutoCAD DWG file and export it to DXF format. DWG to DXF conversion approach works as follows:

  1. Load DWG drawing file using the Image.Load factory method.
  2. Export the DWG drawing to DXF using the Image.Save() method.

The code sample below shows how to convert a DWG file to a DXF format.

Convert DWG Drawings to SVG

Aspose.CAD for .NET API can load AutoCAD drawings in DWG format, and convert it to SVG. This topic explains the usage of Aspose.CAD API to achieve the conversion of DWG to SVG format through simple steps as defined below.

  1. Load the DWG file into an instance of Image.
  2. Create an object of the SvgOptions class and set the required properties.
  3. Export the DWG drawing to SVG using the Image.Save() method.

The code sample below shows how to convert a DWG file to SVG format.

Load Large DWG File

Aspose.CAD for .NET provides the facility to open very large DWG files using Image class. Now you can easily open large files with the help of the sample code given below.