DWG Drawings
Exporting DWG Drawings to PDF
Aspose.CAD for Python 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.
The API supports the following AutoCAD DWG revisions:
- DWG 2004 version 16.0 release 18
- DWG 2005 version 16.1
- DWG 2010 version 18.0
- DWG 2013 version 19.0
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.
- Load the DWG file into an instance of Image.
- Create an object of the CadRasterizationOptions class and set the page_height & page_width properties.
- Create an object of the PdfOptions class and set the VectorRasterizationOptions property.
- 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.
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:
- Load a DWG file using the Aspose.CAD.Image.load factory method.
- Create an instance of the CadRasterizationOptions class and set the resultant page height and width.
- Set the Layouts property for the CadRasterizationOptions object.
- Create an instance of PdfOptions class and set its VectorRasterizationOptions property.
- 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.
Exporting DWG to PDF/A and PDF/E
This approach works as follows:
- Load a DWG file using the Image.load factory method.
- Create an instance of the CadRasterizationOptions class.
- Create an instance of PdfOptions class and set its VectorRasterizationOptions property.
- Set PDF compliance property and save it.
- 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.
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:
- Load DWG drawing file using the Image.load factory method.
- 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 Python 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.
- Load the DWG file into an instance of Image.
- Create an object of the SvgOptions class and set the required properties.
- 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.