How to Export AutoCAD DXF Drawing, Specific DXF Layout or Layer to PDF using Jav
This technical tip explains how Java developers can export DXF drawings, specific DXF layouts or specific layer to PDF. Aspose.Imaging component provide means to load AutoCAD DXF files, and to render DXF drawing entities to PDF format as a single drawing. At the moment we fully support AutoCAD DXF 2010 file format only. Previous DXF format versions are not guaranteed to be 100% valid. We are planning to include more formats and features in future Aspose.Imaging versions. At the moment we support all widespread 2D entities and their basic default parameters. Aspose.Imaging for Java API has added the Cad class to the com.aspose.imaging.fileformats package that is responsible for loading AutoCAD drawings into Aspose.Imaging core. To accomplish DXF to PDF export, a new class, PdfOptions has been introduced to the com.aspose.imaging.imageOptions package.
//your code here...Exporting DXF Drawings to PDF
//Load a CAD drawing
Image image = Image.load(sourceFile);
//Create an instance of CadRasterizationOptions and set its various properties
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);
//Export the DXF to PDF
image.save(outputFile, pdfOptions);
//Exporting Specific Layouts of DXF to PDF
//The programming sample below shows how to convert a specific layout of DXF to PDF.
//Load an existing CAD in an instance of Image
Image image = Image.load(sourceImage);
//Create an instance of CadRasterizationOptions and set its various properties
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.setPageWidth(1600);
rasterizationOptions.setPageHeight(1600);
//Specify desired layout names
rasterizationOptions.setLayouts(new String [] {"Model", "Layout1"});
//Create an instance of PdfOptions
PdfOptions pdfOptions = new PdfOptions();
//Set the VectorRasterizationOptions property
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
//Exporting Specific Layer of DXF to PDF
////The programming sample below shows how to convert a specific layers of DXF to PDF.
//Load an existing CAD in an instance of Image
Image image = Image.load(sourceImage);
//Create an instance of CadRasterizationOptions and set its various properties
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.setPageWidth(1600);
rasterizationOptions.setPageHeight(1600);
//Add desired layers
rasterizationOptions.getLayers().add("layer1");
rasterizationOptions.getLayers().add("layer2");
//Create an instance of PdfOptions
PdfOptions pdfOptions = new PdfOptions();
//Set the VectorRasterizationOptions property
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
//Export the CAD to PDF
image.save(outputImage, pdfOptions);
Url: http://www.aspose.com/java/imaging-component.aspx
Language: Java | User: Sheraz Khan | Created: May 6, 2015 | Tags: convert AutoCAD DXF to PDF export DXF drawings to PDF export specific layouts of DXF to PDF export Specific Layer of DXF to PDF Java Imaging API Export the CAD to PDF