Load CAD document with options
Leave feedback
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:
Option | Description |
---|---|
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. |
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.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.