STL File Viewer using C#

STL (STereoLithography) file format is used for 3D CAD drawings and 3D printing. There are several requirements when the developers are required to programmatically render STL files into various other formats. One of the reasons for conversion is better portability. In this article, you will learn how to render the STL files into PDF format using C#. Additionally, we will convert the STL files to HTML, JPG, and PNG format within .NET application using examples.

The following topics are discussed below:

.NET API to View STL Files

GroupDocs.Viewer showcases document viewer .NET API that allows rendering the documents into PDF, HTML, and images within the .NET application. In this article, we will use it in examples to convert the STL files into different other file formats.

You can download the DLLs or MSI installer from the downloads section or install the API in your .NET application via NuGet.

PM> Install-Package GroupDocs.Viewer

View STL File as PDF using C#

It is often required to convert the stereolithography STL format to PDF format due to its high portability. The following steps show how to convert the STL files into PDF format using C#.

  • Load the STL file using the Viewer class.
  • Prepare the PDF rendering options using the PdfViewOptions class.
  • Use the View() method to render STL file as PDF.

The following C# code example renders the STL files into PDF format.

View STL File as HTML, JPG, or PNG using C#

Similarly, you can convert the STL files into other formats according to the requirement. The following steps help you to render the STL files into various other formats using C#.

  • Load the STL file using the Viewer class.
  • Prepare the rendering options according to the conversion format:
  • Use the View() method to render STL file as HTML, JPG, or PNG.

Below are the C# examples that separately render STL files into each format using the respective format options.

STL to HTML using C#

The following C# code converts the STL file into HTML with embedded resources. Similarly, you can convert to HTML with external resources.

STL to JPG using C#

The following C# code converts the STL file into JPG image format.

STL to PNG using C#

The following C# code converts the STL file into PNG image format.

Get a Free API License

You can use the APIs for free by getting a temporary license.

Conclusion

To conclude, we learned how to render the STL files into other formats. Specifically, we converted the STL files into PDF, HTML, JPG, and PNG formats using the C# example. You can build your own STL viewer application like Groupdocs.Viewer Online App.

To learn more about GroupDocs.Viewer for .NET, visit its documentation. For queries, contact us via the forum.

See Also