aspose.cad 如何指定layout进行转换pdf?请问使用过的么 ?
可以使用Aspose.CAD for .NET或Aspose.CAD for Java API来指定layout进行转换pdf。这个API可以加载DWG格式的AutoCAD绘图,并将其转换为PDF,的大概分为以下几步,github地址我放源码里了:
// For complete examples and data files, please go to https://github.com/aspose-cad/Aspose.CAD-for-Java
// The path to the documents directory.
String MyDir = RunExamples.getDataDir_DWGDrawings();
String sourceFilePath = MyDir + "Bottom_plate.dwg";
try (com.aspose.cad.Image image = com.aspose.cad.Image.load(sourceFilePath))
{
// Create an instance of CadRasterizationOptions and set its various properties
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.setBackgroundColor(Color.getWhite());
rasterizationOptions.setPageWidth(1600);
rasterizationOptions.setPageHeight(1600);
rasterizationOptions.setLayouts(new String[] { "Model" });
// Set the Entities type property to Entities3D.
rasterizationOptions.setTypeOfEntities(TypeOfEntities.Entities3D);
// Enable the usage of predefined Rendering Configurations
rasterizationOptions.setNoScaling(DxfDrawingUnits.Unitless);
// Add the layer name to the list that are excluded from rendering
rasterizationOptions.getLayers().add("0");
// Create an instance of PdfOptions
PdfOptions pdfOptions = new PdfOptions();
// Set the VectorRasterizationOptions property
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
// Export layout to PDF
String outPath = sourceFilePath + ".pdf";
image.save(outPath, pdfOptions);
}