STL Drawings

Exporting STL To PNG Format

Aspose.CAD for Java allows developers to export an STL file to PNG. Following is the code demonstrating how to access the STL file and convert that to PNG using CadRasterizationOption and PngOptions.

Sample Code

String dataDir = Utils.getDataDir(ExportSTLToPNG.class) + "ExportingSTL/";
String fileName = dataDir + "example.stl";
CadImage cadImage = (CadImage)Image.load(fileName);
CadRasterizationOptions vectorOptions = new CadRasterizationOptions();
vectorOptions.setPageWidth(1500);
vectorOptions.setPageHeight(1500);
PngOptions pngOptions = new PngOptions();
//pngOptions.setVectorRasterizationOptions(rasterizationOptions);
String outPath = dataDir + "galeon.stl.png";
cadImage.save(outPath, pngOptions);