Aspose.CAD for Java 从
Aspose.Imaging中分离出来后就专门用于处理CAD文件了,可以对CAD文件格式进行编辑和转换,在新的1.1版本中主要做了如下的更新:
1.支持在DWG文件中进行文本的搜索
String sourceFile = "sample.dwg";
// Load an existing DWG file as DgnImage.
com.aspose.cad.fileformats.dgn.DgnImage dgnImage =
(com.aspose.cad.fileformats.dgn.DgnImage)com.aspose.cad.Image.load(file);
// search for text in the file
for (com.aspose.cad.fileformats.cad.cadobjects.CadBaseEntity entity : cadImage.getEntities())
{
// please, note: we iterate through CadText entities here, but some other entities
// may contain text also, e.g. CadMText and others
if (entity.getClass() == com.aspose.cad.fileformats.cad.cadobjects.CadText.class)
{
com.aspose.cad.fileformats.cad.cadobjects.CadText text =
(com.aspose.cad.fileformats.cad.cadobjects.CadText)entity;
System.out.println(text.getDefaultValue());
}
}
2.支持导出DNG格式为PDF文件格式
String file = "sample.dgn";
String outFile = "sample.dgn.pdf";
// load an existing DGN file as DgnImage.
com.aspose.cad.fileformats.dgn.DgnImage dgnImage =
(com.aspose.cad.fileformats.dgn.DgnImage)com.aspose.cad.Image.load(file);
java.io.OutputStream outStream = new java.io.FileOutputStream(outFile);
com.aspose.cad.imageoptions.DgnRasterizationOptions rasterizationOptions =
new com.aspose.cad.imageoptions.DgnRasterizationOptions();
// Create an object of CadRasterizationOptions class and define/set different properties
PdfOptions options = new PdfOptions();
rasterizationOptions.setPageWidth(600);
rasterizationOptions.setPageHeight(300);
rasterizationOptions.setCenterDrawing(true);
rasterizationOptions.setAutomaticLayoutsScaling(false);
options.setVectorRasterizationOptions(rasterizationOptions);
// Call the save method of the CadImage class object.
cadImage.save(outStream, options);
3.支持导出DNG格式为光栅图片格式
String file = "sample.dgn";
String outFile = "sample.dgn.jpg";
// load an existing DGN file as DgnImage.
com.aspose.cad.fileformats.dgn.DgnImage dgnImage =
(com.aspose.cad.fileformats.dgn.DgnImage)com.aspose.cad.Image.load(file);
java.io.OutputStream outStream = new java.io.FileOutputStream(outFile);
// Create an object of DgnRasterizationOptions class and define/set different properties
com.aspose.cad.imageoptions.DgnRasterizationOptions rasterizationOptions =
new com.aspose.cad.imageoptions.DgnRasterizationOptions();
// Create an object of JpegOptions class as we are converting the DGN to jpeg and assign DgnRasterizationOptions object to it.
JpegOptions options = new JpegOptions();
rasterizationOptions.setPageWidth(600);
rasterizationOptions.setPageHeight(300);
rasterizationOptions.setCenterDrawing(true);
rasterizationOptions.setAutomaticLayoutsScaling(false);
options.setVectorRasterizationOptions(rasterizationOptions);
// Call the save method of the CadImage class object.
cadImage.save(outStream, options);
4.支持获取块属性扩展信息的值
5.对转换CAD文件格式为BMP进行了增强
6.处理DXF中的Face3D对象进行了增强