Convert CAD’s DWG and DXF to PDF using C#

CAD is used by designers to create various types of designs of buildings, bridges, automobiles, chips and etc. in a wide range of industries. However, the CAD formats (DWG, DXF, etc.) can only be viewed in a dedicated software or an online CAD viewer. To make things easier, the DWG/DXF files could be converted into PDF files which can be viewed anywhere without any dependency. In this article, you will learn how to convert CAD’s DWG or DXF files to PDF using C#.

C# CAD to PDF Converter – Free Download

Aspose.CAD for .NET is a powerful CAD to PDF converter API that lets you convert DWG and DXF files to PDF format quiet easily. In addition, it allows you to convert the CAD drawings to raster images. The API can be installed using the NuGet or downloaded as DLL from the Downloads section.

PM> Install-Package Aspose.CAD

DWG or DXF to PDF C# Conversion

The following are the steps to convert a DWG/DXF file to PDF format using Aspose.CAD for .NET API.

The following code sample shows how to convert DWG to PDF using C#.

C# DWG/DXF to PDF – Set Canvas Size

Aspose.CAD for .NET also allows you to specify the size of the pages (height and width) in the converted PDF document. The following are the steps to customize page size in CAD to PDF conversion.

The following code sample shows how to convert DXF to PDF using C#.

C# CAD to PDF – Auto Scaling

The CAD drawing may consist of multiple layers where each layer might have a different dimension. In various scenarios, you may want to have a unified scaling in the converted PDF file. For such cases, you can configure the API to auto-scale the layers in accordance with the page size in the PDF document. The following are the steps to perform auto-scaling in AutoCAD to PDF conversion.

The following code sample shows how to convert CAD drawing to PDF with auto-scaling using C#.

Modify Background and Drawing Color in Converted PDF

Aspose.CAD for .NET also lets you modify the default color scheme of the CAD drawings in the converted PDF document. The following are the steps to specify the background and drawing colors.

The following code sample shows how to convert DWG/DXF drawing to PDF with customized background and drawing colors.

Convert Specific Layers of CAD to PDF using C#

In case there are multiple layers in the AutoCAD drawing, you can specify the layers you want to have in the converted PDF document. For this, you can provide the list of the layers’ names to the API using CadRasterizationOptions.Layers property. The following code sample shows how to convert a specific layer of the AutoCAD drawing to PDF using C#.

Conclusion

In this article, you have seen how to convert CAD’s DWG or DXF files to PDF using C#. Furthermore, you have learned how to customize the CAD to PDF conversion in various scenarios using Aspose.CAD for .NET API. You can explore more about the API using the documentation.

See Also