How to convert CAD to HTML
CAD drawings are vector format images that contain points with x,y, 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:
using (Viewer viewer = new Viewer("document.dwg"))
{
HtmlViewOptions viewOptions =
HtmlViewOptions.ForExternalResources("page_{0}.html","page_{0}/resource_{1}","page_{0}/resources");
viewer.View(viewOptions);
}
Result:
Output SVG and HTML styles are located in the separate resources folder.
To render to HTML with embedded resources use following code:
using (Viewer viewer = new Viewer("document.dwg"))
{
HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources("page_{0}.html");
viewer.View(viewOptions);
}
Result:
HTML content, SVG and HTML styles are located in one HTML file.
More resources
View CAD Drawings Online
Along with full-featured .NET library we provide simple but powerful free online Apps. View DXF, DWG, and DWF files online with GroupDocs Viewer App.
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples:
- GroupDocs.Viewer for .NET examples, plugins, and showcase
- GroupDocs.Viewer for Java examples, plugins, and showcase
- Document Viewer for .NET MVC UI Example
- Document Viewer for .NET App WebForms UI Modern Example
- Document Viewer for Java App Dropwizard UI Modern Example
- Document Viewer for Java Spring UI Example