How to convert CAD to HTML

Introduction

CAD drawings are vector format images that contain points with X, Y and Z coordinates, and associated lines definitions. CAD drawings also may contain layers and layouts. 

Background

If you convert your CAD drawings to HTML it’s better to leave them in vector format rather rasterization to get better viewing and zooming. While converting your CAD drawings to HTML GroupDocs.Viewer converts a drawing to SVG (Scalable Vector Graphics format) and embeds it to HTML.

How to convert CAD drawings to HTML

There are two ways: HTML with external resources and HTML with embedded resources.

To render to HTML with external resources use following code:

    Viewer viewer = new Viewer("document.dwg");
    HtmlViewOptions viewOptions = HtmlViewOptions.forExternalResources("page_{0}.html", "page_{0}/resource_{1}", "page_{0}/resources");

    viewer.view(viewOptions);
    viewer.close();

Result:

Output SVG and HTML styles are located in the separate resources folder.

To render to HTML with embedded resources use following code:

    Viewer viewer = new Viewer("document.dwg");
    HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources("page_{0}.html");

    viewer.view(viewOptions);
    viewer.close();

Result:

HTML content, SVG and HTML styles are located in one HTML file.

More resources

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App

Along with full-featured Java library we provide simple but powerful free Apps. You are welcome to view Word, PDF, Excel, PowerPoint documents with free to use online GroupDocs Viewer App.