maven:
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cad</artifactId>
<version>23.12</version>
<classifier>javadoc</classifier>
</dependency>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cad</artifactId>
<version>23.12</version>
</dependency>
java code:
String dataDir = Utils.getDataDir(AddTextInDWG2.class) + "DWGDrawings/";
String dwgPathToFile = dataDir + "Drawing1.dwg";
CadImage image = (CadImage) Image.load(dwgPathToFile);
List<CadEntityBase> entities = image.getEntities();
for (int i = 0; i < entities.size(); i++) {
CadEntityBase entity = entities.get(i);
if (entity instanceof CadLwPolyline) {
CadLwPolyline lwPolyline = (CadLwPolyline) entity;
lwPolyline.setColorValue(Color.getRed().toArgb());
}
}
DwgOptions pdfOptions = new DwgOptions();
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions();
pdfOptions.setVectorRasterizationOptions(cadRasterizationOptions);
cadRasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor);
cadRasterizationOptions.setPageHeight(1600);
cadRasterizationOptions.setPageWidth(1600);
cadRasterizationOptions.setLayouts(new String[]{"Model"});
image.save(dataDir + "output.dwg", pdfOptions);
Drawing1.zip (26.8 KB)