Skip to content

Instantly share code, notes, and snippets.

@aspose-com-kb
Last active September 23, 2023 04:57
How to Convert STL File to PDF in Java. For more details: https://kb.aspose.com/3d/java/how-to-convert-stl-file-to-pdf-in-java/
import com.aspose.threed.*;
public class Main
{
public static void main(String[] args) throws Exception // Change STL to PDF in Java
{
com.aspose.threed.TrialException.setSuppressTrialException(true);
// Set the licenses
// new License().setLicense("License.lic");
// Initialize StlLoadOptions class object
com.aspose.threed.StlLoadOptions stloptions = new com.aspose.threed.StlLoadOptions();
// Load input STL file
com.aspose.threed.Scene scene = new com.aspose.threed.Scene(); scene.open("output.stl", stloptions);
// Create PdfSaveOptions class object
com.aspose.threed.PdfSaveOptions pdfoptions = new com.aspose.threed.PdfSaveOptions();
// Convert STL to PDF format
scene.save("STLtoPDF.pdf", pdfoptions);
System.out.println("Done");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment