Skip to content

Instantly share code, notes, and snippets.

@aspose-cad-gists
Last active February 15, 2023 11:10
Convert DWG to PDF Online - Free Converter

Learn how to convert DWG to PDF: https://blog.aspose.com/cad/convert-dwg-to-pdf-online/

The following topics are covered in this article:

  1. Convert DWG to PDF Online
  2. Online DWG to PDF Converter - Developer’s Guide
  3. DWG to PDF in C#
  4. Convert DWG file to PDF in Java
  5. Convert DWG to PDF Online - Cloud API
  6. Learning Resources
// This code example demonstrates how to convert DWG to PDF in C#
// Load DWG file in an instance of Image via its Load method
using (var image = Image.Load("C:\\Files\\Sample.dwg"))
{
// Create an instance of CadRasterizationOptions and set page height and width
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions()
{
PageWidth = 1600,
PageHeight = 1600
};
// Create an instance of PdfOptions
var options = new Aspose.CAD.ImageOptions.PdfOptions();
// Set the VectorRasterizationOptions property as CadRasterizationOptions
options.VectorRasterizationOptions = rasterizationOptions;
// Export DWG to PDF
image.Save("C:\\Files\\output.pdf", options);
}
// This code example demonstrates how to convert DWG to PDF in Java
// Load DWG file in an instance of Image via its Load method
com.aspose.cad.Image objImage = com.aspose.cad.Image.load("C:\\Files\\Sample.dwg");
// Create an instance of CadRasterizationOptions and set its various properties
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.setBackgroundColor(Color.getWhite());
rasterizationOptions.setPageWidth(1600);
rasterizationOptions.setPageHeight(1600);
// Create an instance of PdfOptions
PdfOptions pdfOptions = new PdfOptions();
// Set the VectorRasterizationOptions property
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
// Export the DWG to PDF
objImage.save("C:\\Files\\Sample_out.pdf", pdfOptions);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment