How to view DWF file layers

Introduction

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.

Background

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 CadOptions.Layers property of HtmlViewOptions (or PngViewOptions, or  JpgViewOptions, orPdfViewOptions) class. 

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

using (Viewer viewer = new Viewer("sample.dwf"))
{
    PngViewOptions viewOptions = new PngViewOptions();
    
    options.CadOptions.Layers.Add(new Results.Layer("Stairs"));
    options.CadOptions.Layers.Add(new Results.Layer("Walls"));
    options.CadOptions.Layers.Add(new Results.Layer("Doors"));

    viewer.View(viewOptions);
}

Now GroupDocs.Viewer will render only these layers:

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 .NET 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.