Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created May 7, 2024 16:15
Show Gist options
  • Save aspose-com-gists/1b2bc5380564ddf4082ebc1fb4fb2a35 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/1b2bc5380564ddf4082ebc1fb4fb2a35 to your computer and use it in GitHub Desktop.
Convert DWG to PDF in C#
using Aspose.CAD;
using Aspose.CAD.ImageOptions;
namespace AsposeThreeD
{
class DWGtoPDF {
// Convert DWG to PDF in C#
static void Main(string[] args) {
string sourceFilePath = "/sample.dwg";
// Invoke the Load method of the Image class to load the source DWG file.
using (Image image = Image.Load(sourceFilePath)) {
// Create an instance of CadRasterizationOptions and set its various properties such as PageWidth, PageHeight and AutomaticLayoutsScaling.
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.PageWidth = 1600;
rasterizationOptions.PageHeight = 1600;
rasterizationOptions.AutomaticLayoutsScaling = true;
// Create an object of the PdfOptions class.
PdfOptions pdfOptions = new PdfOptions();
// Set the VectorRasterizationOptions property.
pdfOptions.VectorRasterizationOptions = rasterizationOptions;
// Convert DWG to PDF by calling the Save method.
image.Save("/output.pdf", pdfOptions);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment