Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active January 7, 2022 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/f82b9836c8c4781963cb6565badc911d to your computer and use it in GitHub Desktop.
Save GroupDocsGists/f82b9836c8c4781963cb6565badc911d to your computer and use it in GitHub Desktop.
View STL File as HTML, PDF, JPG or PNG in Java
// Render STL files to HTML with embedded resources using Java
try (Viewer viewer = new Viewer("path/input.stl")) {
HtmlViewOptions options = HtmlViewOptions.forEmbeddedResources("path/stl-output.html");
viewer.view(options);
}
// Render STL files to JPG in Java
try (Viewer viewer = new Viewer("path/input.stl")) {
JpgViewOptions options = new JpgViewOptions("path/stl-output.jpg");
viewer.view(options);
}
// Render STL files to PDF in Java
try (Viewer viewer = new Viewer("path/input.stl")) {
PdfViewOptions options = new PdfViewOptions("path/stl-output.pdf");
viewer.view(options);
}
// Render STL files to PNG in Java
try (Viewer viewer = new Viewer("path/input.stl")) {
PngViewOptions options = new PngViewOptions("path/stl-output.png");
viewer.view(options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment