Exporting DGN AutoCAD

Exporting DGN AutoCAD Format To PDF

Aspose.CAD for Java API has introduced the functionality to load a DGN AutoCAD file and convert it to PDF format. DgnImage class serves the purpose.

You need to load an existing DGN file as DgnImage. Create an instance of the CadRasterizationOptions class and set different properties. Create an instance of PdfOptions class and pass the CadRasterizationOptions instance. Now call the save method of DgnImage class instance.

Sample Code

Following is the code demonstration to convert/export DGN to PDF format.

// load an existing DGN file as DgnImage.
DgnImage dgnImage = (DgnImage)Image.load(dataDir + "Nikon_D90_Camera.dgn");
// Create an object of CadRasterizationOptions class and define/set different properties
PdfOptions options = new PdfOptions();
CadRasterizationOptions vectorOptions = new CadRasterizationOptions();
vectorOptions.setPageWidth(1500);
vectorOptions.setPageHeight(1500);
vectorOptions.setNoScaling(true);
vectorOptions.setAutomaticLayoutsScaling(false);
options.setVectorRasterizationOptions(vectorOptions);
OutputStream outStream = new FileOutputStream(dataDir + "ExportDGNToPdf_Out.pdf");
// Call the save method of the DgnImage class object.
dgnImage.save(outStream, options);

Exporting DGN AutoCAD Format To Raster Image Format

Aspose.CAD for Java API has introduced the functionality to load a DGN AutoCAD file and convert it to a raster image. The DgnImage class serves the purpose.

You need to load an existing DGN file as DgnImage. Create an instance of the CadRasterizationOptions class and set different properties. Create an instance of JpegOptions class and pass the CadRasterizationOptions instance. Now call the save method of DgnImage class instance.

Sample Code

Following is the code demonstration to convert/export DGN to JPEG image.

// Load an existing DGN file as DgnImage.
DgnImage dgnImage = (DgnImage) Image.load(dataDir + "Nikon_D90_Camera.dgn");
// Create an object of JpegOptions class as we are converting the DGN to JPEG and assign DgnRasterizationOptions object to it.
ImageOptionsBase options = new JpegOptions();
CadRasterizationOptions vectorOptions = new CadRasterizationOptions();
vectorOptions.setPageWidth(600);
vectorOptions.setPageHeight(400);
vectorOptions.setNoScaling(true);
vectorOptions.setAutomaticLayoutsScaling(false);
options.setVectorRasterizationOptions(vectorOptions);
OutputStream outStream = new FileOutputStream(dataDir + "ExportDGNToRasterImage_Out.jpg");
// Call the save method of the CadImage class object.
dgnImage.save(outStream, options);