Created
May 7, 2024 16:15
-
-
Save aspose-com-gists/1b2bc5380564ddf4082ebc1fb4fb2a35 to your computer and use it in GitHub Desktop.
Convert DWG to PDF in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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