将 DGN AutoCAD 导出

将 DGN AutoCAD 格式导出为 PDF

Aspose.CAD for Java API 已引入加载 DGN AutoCAD 文件并将其转换为 PDF 格式的功能。 DgnImage 类用于此目的。

您需要将现有的 DGN 文件加载为 DgnImage。创建 CadRasterizationOptions 类的实例并设置不同的属性。创建 PdfOptions 类的实例并传递 CadRasterizationOptions 实例。现在调用 DgnImage 类实例的 save 方法。

示例代码

以下是将 DGN 转换/导出为 PDF 格式的代码演示。

// 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);

将 DGN AutoCAD 格式导出为光栅图像格式

Aspose.CAD for Java API 已引入加载 DGN AutoCAD 文件并将其转换为光栅图像的功能。 DgnImage 类用于此目的。

您需要将现有的 DGN 文件加载为 DgnImage。创建 CadRasterizationOptions 类的实例并设置不同的属性。创建 JpegOptions 类的实例并传递 CadRasterizationOptions 实例。现在调用 DgnImage 类实例的 save 方法。

示例代码

以下是将 DGN 转换/导出为 JPEG 图像的代码演示。

// 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);