Xuất DGN AutoCAD
Xuất định dạng DGN AutoCAD sang PDF
Aspose.CAD cho API Java đã giới thiệu tính năng tải một tệp DGN AutoCAD và chuyển đổi nó sang định dạng PDF. Lớp DgnImage phục vụ mục đích này.
Bạn cần tải một tệp DGN hiện có dưới dạng DgnImage. Tạo một thể hiện của lớp CadRasterizationOptions và thiết lập các thuộc tính khác nhau. Tạo một thể hiện của lớp PdfOptions và truyền thể hiện CadRasterizationOptions vào. Bây giờ gọi phương thức save của thể hiện lớp DgnImage.
Mã mẫu
Dưới đây là minh họa mã để chuyển đổi/xuất DGN sang định dạng 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); |
Xuất định dạng DGN AutoCAD sang định dạng hình ảnh raster
Aspose.CAD cho API Java đã giới thiệu tính năng tải một tệp DGN AutoCAD và chuyển đổi nó sang hình ảnh raster. Lớp DgnImage phục vụ mục đích này.
Bạn cần tải một tệp DGN hiện có dưới dạng DgnImage. Tạo một thể hiện của lớp CadRasterizationOptions và thiết lập các thuộc tính khác nhau. Tạo một thể hiện của lớp JpegOptions và truyền thể hiện CadRasterizationOptions vào. Bây giờ gọi phương thức save của thể hiện lớp DgnImage.
Mã mẫu
Dưới đây là minh họa mã để chuyển đổi/xuất DGN sang hình ảnh 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); | |