Rendering DWF file layers

Design Web Format File (.dwf) consists of various user layers. Layers represent various parts of the entire drawing, for example, this drawing describes a plan of a building and it’s parts like stairs, walls, doors located in different layers.


Let’s take a sample DWF described above and then we’ll process with GroupDocs.Viewer and compare results.

By default GroupDocs.Viewer renders all layers:

How to view only specific layers

If you want to view only specific layers you can set setLayers() property of CadOptions (getCadOptions() method of HtmlViewOptionsPngViewOptions, JpgViewOptions or PdfViewOptions) class. 

Let’s view only “Doors”, “Stairs”, “Walls” layers, to do that use following code, 

    try (Viewer viewer = new Viewer("sample.dwf")) {
        PngViewOptions viewOptions = new PngViewOptions();
        viewOptions.getCadOptions().getLayers().add(new Layer("Stairs"));
        viewOptions.getCadOptions().getLayers().add(new Layer("Walls"));
        viewOptions.getCadOptions().getLayers().add(new Layer("Doors"));

Now GroupDocs.Viewer will render only these layers: