DEV Community

Atir Tahir
Atir Tahir

Posted on

Rendering a DWG file

GroupDocs.Viewer for .NET is a back-end API that allows you to render an AutoCAD file to HTML, Image or PDF file formats.
Let's see how to render a DWG file to HTML in few code lines:

string outputDirectory = "output directory";
string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.html");
using (Viewer viewer = new Viewer("sample CAD file"))
{                
    HtmlViewOptions options = 
    HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat);    
    viewer.View(options);
}
Enter fullscreen mode Exit fullscreen mode

Same file could be rendered to PDF as follows:

using (Viewer viewer = new Viewer("sample CAD file"))
{
    PdfViewOptions options = new PdfViewOptions(outputFilePath);
    viewer.View(options);
}
Enter fullscreen mode Exit fullscreen mode

Explore the API documentation to learn more. In case of any issue, post it on free support forum.

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay