Convert DWG or DFX to PDF in Java
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
// Load the source CAD file | |
com.aspose.cad.Image objImage = com.aspose.cad.Image.load("input.dwg"); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Set auto scaling | |
rasterizationOptions.setAutomaticLayoutsScaling(true); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export CAD to PDF | |
objImage.save("dwg-to-pdf.pdf", pdfOptions); |
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
// Load the source CAD file | |
com.aspose.cad.Image objImage = com.aspose.cad.Image.load("input.dwg"); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Set background and drawing color | |
rasterizationOptions.setDrawType(CadDrawTypeMode.UseDrawColor); | |
rasterizationOptions.setBackgroundColor(com.aspose.cad.Color.getBlue()); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export CAD to PDF | |
objImage.save("dwg-to-pdf.pdf", pdfOptions); |
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
// Load the source CAD file | |
com.aspose.cad.Image objImage = com.aspose.cad.Image.load("input.dwg"); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); |
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
// Load the source CAD file | |
com.aspose.cad.Image objImage = com.aspose.cad.Image.load("sample.dwg"); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Export CAD to PDF | |
objImage.save("dwg-to-pdf.pdf", pdfOptions); |
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
// Load the source CAD file | |
com.aspose.cad.Image objImage = com.aspose.cad.Image.load("input.dwg"); | |
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); | |
rasterizationOptions.setPageWidth(1600); | |
rasterizationOptions.setPageHeight(1600); | |
ArrayList<String> layers=new ArrayList<String>(); | |
layers.add("LayerA"); | |
// Set background and drawing color | |
rasterizationOptions.setLayers(layers); | |
// Create an instance of PdfOptions | |
PdfOptions pdfOptions = new PdfOptions(); | |
// Set the VectorRasterizationOptions property | |
pdfOptions.setVectorRasterizationOptions(rasterizationOptions); | |
// Export CAD to PDF | |
objImage.save("dwg-to-pdf.pdf", pdfOptions); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment