Convert DWG to PDF File.

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
nthangaraj
Posts: 19
Joined: 31 Aug 2017, 09:47

Convert DWG to PDF File.

Post by nthangaraj » 10 Oct 2017, 17:15

Please let me know how i could convert a DWG to PDF file ?

Thanks
Thangaraj N

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: Convert DWG to PDF File.

Post by support » 10 Oct 2017, 19:06

Hello,

DWG to PDF conversion is performed in two steps:

1) Reading the DWG file to a CADImage object.

Code: Select all

using CADImport;
...

string filePath = @"C:\test.dwg";
CADImage cadImage = CADImage.CreateImageByExtension(filePath);
cadImage.LoadFromFile(filePath);
cadImage.IsWithoutMargins = true;
2) Saving the CADImage object to a PDF file using a CADToPDF class.

Code: Select all

using CADImport.Export;
using System.IO;
...

CADToPDF pdfExporter = new CADToPDF(cadImage);
pdfExporter.Settings.LayoutsExportMode = LayoutsExportOption.All;
pdfExporter.Settings.DrawMode = CADDrawMode.Normal;
pdfExporter.Settings.IsShowLineWeight = true;
pdfExporter.Settings.LineWeightScale = 0;
pdfExporter.Settings.PageHeight = 17 * 25.4;   // 17 inches converted to mm
pdfExporter.Settings.PageWidth = 11 * 25.4;    // 11 inches converted to mm
pdfExporter.SaveToFile(Path.ChangeExtension(filePath, ".pdf"));
Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

nthangaraj
Posts: 19
Joined: 31 Aug 2017, 09:47

Re: Convert DWG to PDF File.

Post by nthangaraj » 11 Oct 2017, 14:48

I did tried to export the PDF, But i'm getting a blank page. Also i have few colored layer and i want the background to be printed as black when exported(Same as in CAD). Please provide some suggestions.

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: Convert DWG to PDF File.

Post by support » 11 Oct 2017, 15:30

Hello,

To produce a PDF with black background, add the following line to the PDF export routine:

Code: Select all

pdfExporter.Settings.BackgroundColor = Color.Black.ToArgb();
As for the problem with a blank page, please send us the .dwg and .pdf files for investigation.


Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

nthangaraj
Posts: 19
Joined: 31 Aug 2017, 09:47

Re: Convert DWG to PDF File.

Post by nthangaraj » 12 Oct 2017, 12:31

Can you please let me know how i can upload the file. It is more than 1 MB.

Thanks
Thangaraj N

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: Convert DWG to PDF File.

Post by support » 12 Oct 2017, 14:33

Hello,

You can send the files to the Technical Support e-mail or via Skype.


Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply