Load CAD document with options

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Conversion MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-conversion -- dnx GroupDocs.Conversion.Mcp --yes
Folders, licensing and more →

This documentation explains how to load CAD documents with configurable options using GroupDocs.Conversion for Java. It provides a flexible approach to handling and converting CAD files (such as DWG, DXF, and others) into various target formats (e.g., PDF, PNG, JPEG). Developers can customize the rendering and conversion process to suit their specific requirements using the CadLoadOptions class. The following options can be set:

OptionDescription
setFormat()Allows you to the source document format explicitly with this property. Available options are: Dxf, Dwg, Dgn, Dwf, Stl, Ifc, Plt, Igs, Dwt.
setWidth()Sets the desired page width.
setHeight()Sets the desired page height.
setLayoutNames()Specifies which CAD layout to be converted.

Specify layouts to be converted

The following code snippet shows how to convert a CAD document and convert only certain layouts:

import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.options.convert.PdfConvertOptions;
import com.groupdocs.conversion.options.load.CadLoadOptions;

public class ConvertCadAndSpecifyLayouts {
    public static void convert() {
        CadLoadOptions loadOptions =  new CadLoadOptions();
        loadOptions.setLayoutNames(new  String[]{ "Layout1", "Layout3" });

        try(Converter converter = new Converter("with_layers_and_layouts.dwg", () -> loadOptions)) {
            PdfConvertOptions options = new PdfConvertOptions();
            converter.convert("converted_with_layout.pdf", options);
        }
    }

    public static void main(String[] args){
        convert();
    }
}

with_layers_and_layouts.dwg is sample file used in this example. Click here to download it.

converted_with_layout.pdf is converted PDF document. Click here to download it.