Page 1 of 1

Convert DWG to PDF File.

Posted: 10 Oct 2017, 17:15
by nthangaraj
Please let me know how i could convert a DWG to PDF file ?

Thanks
Thangaraj N

Re: Convert DWG to PDF File.

Posted: 10 Oct 2017, 19:06
by support
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

Re: Convert DWG to PDF File.

Posted: 11 Oct 2017, 14:48
by nthangaraj
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.

Re: Convert DWG to PDF File.

Posted: 11 Oct 2017, 15:30
by support
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

Re: Convert DWG to PDF File.

Posted: 12 Oct 2017, 12:31
by nthangaraj
Can you please let me know how i can upload the file. It is more than 1 MB.

Thanks
Thangaraj N

Re: Convert DWG to PDF File.

Posted: 12 Oct 2017, 14:33
by support
Hello,

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


Mikhail