How to Convert DWG to PDF in C#

This simple article focuses on how to convert DWG to PDF in C# by exposing the application configuration to use the library and the step-wise process to code this application. The CadRasterizationOptions class instance can be used to customize the output PDF according to your requirements. In the example code to export the DWG file to PDF in C#, we have exhibited the setting of the page size for the output PDF file.

Steps to Export DWG to PDF in C#

  1. Configure the project to add Aspose.CAD for .NET from the NuGet package manager to convert DWG to PDF
  2. Access the target DWG file using an instance of the Image class
  3. Initialize the CadRasterizationOptions class object to set the output PDF page size
  4. Declare the PdfOptions class object and set the VectorRasterizationOptions property of PdfOptions
  5. Save the DWG as PDF file using the PdfOptions object

The above mentioned steps crisply explain the process that can convert DWG file to PDF in C#, whereby first of all the DWG file will be loaded using an instance of the Image class, which is then followed by instantiating a PdfOptions class object as an argument with the default settings. If you want to customize the rasterization options of the DWG file then you can use CadRasterizationOptions class instance for the customization of the output PDF.

Code to Export DWG to PDF in C#

The example code can be utilized to develop a DWG to PDF converter software in C# as all the required classes and methods are introduced in it. The CadRasterizationOptions class instance is used to customize the rasterization process like the page size is set however, you can set other properties also like draw color, background color, draw type, layers, pen options, layouts, and quality to name a few.

This article has focused on the process to convert DWG file to PDF in C#. If you want to learn about the process to convert DWG to SVG, refer to the article how to convert DWG to SVG in C#.

 English