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)