public class CadOptions extends Object
The CadOptions class encapsulates various settings and parameters that can be used to control the rendering of CAD drawings in the GroupDocs.Viewer component.
For more information and code examples, see the Render CAD drawings and models as HTML, PDF, and image files and Specify rendering options for CAD files.
Example usage:
CadOptions options = CadOptions.forRenderingByWidth(256);
options.setRenderLayouts(true);
options.setBackgroundColor(Color.YELLOW);
options.setLayers(Arrays.asList(
CacheableFactory.getInstance().newLayer("Layer1"),
CacheableFactory.getInstance().newLayer("Layer2")
));
try (Viewer viewer = new Viewer("document.dwg")) {
PdfViewOptions pdfViewOptions = new PdfViewOptions();
pdfViewOptions.setCadOptions(options);
viewer.view(pdfViewOptions);
// Use the viewer object for further operations
}
CacheableFactory,
PdfViewOptions,
Viewer| Modifier and Type | Field and Description |
|---|---|
static String |
HEIGHT |
static String |
WIDTH |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o)
Checks if this CadOptions object is equal to another object.
|
static CadOptions |
forRenderingByHeight(int height)
Initializes a new instance of the
CadOptions class for rendering by height. |
static CadOptions |
forRenderingByScaleFactor(double scaleFactor)
Initializes a new instance of the
CadOptions class for rendering by scale factor. |
static CadOptions |
forRenderingByWidth(int width)
Initializes a new instance of the
CadOptions class for rendering by width. |
static CadOptions |
forRenderingByWidthAndHeight(int width,
int height)
Initializes a new instance of the
CadOptions class for rendering by width and height. |
Color |
getBackgroundColor()
Gets the background color of the image.
|
String |
getBackgroundColorAsHex()
Gets the background color of the image.
|
int |
getHeight()
Gets the height of the output result in pixels.
|
List<Layer> |
getLayers()
Gets the CAD drawing layers to render.
|
String |
getLayoutName()
Gets the name of the specific layout to render.
|
String |
getPc3File()
Retrieves the PC3 (Plotter Configuration) file associated with the plotter.
|
double |
getScaleFactor()
Gets the scale factor for rendering.
|
List<Tile> |
getTiles()
Gets the drawing regions to render.
|
int |
getWidth()
Gets the width of the output result in pixels.
|
int |
hashCode() |
boolean |
isEnablePerformanceConversionMode()
Setting this flag to
|
boolean |
isRenderLayouts()
Indicates whether layouts from the CAD document should be rendered.
|
void |
setBackgroundColor(Color backgroundColor)
Sets the background color of the image.
|
void |
setBackgroundColor(String colorName)
Sets the background color of the image.
|
void |
setEnablePerformanceConversionMode(boolean enablePerformanceConversionMode)
Setting this flag to
|
void |
setLayers(List<Layer> value)
Gets the CAD drawing layers to render.
|
void |
setLayoutName(String value)
Sets the name of the specific layout to render.
|
void |
setPc3File(String pc3File)
Sets the PC3 (Plotter Configuration) file associated with the plotter.
|
void |
setRenderLayouts(boolean value)
Sets whether layouts from the CAD document should be rendered.
|
void |
setTiles(List<Tile> value)
Sets the drawing regions to render.
|
String |
toString() |
String |
toString(org.apache.commons.lang3.builder.ToStringStyle style) |
public static final String HEIGHT
public static final String WIDTH
public boolean equals(Object o)
Checks if this CadOptions object is equal to another object.
public static CadOptions forRenderingByHeight(int height)
Initializes a new instance of the CadOptions class for rendering by height.
For code example, see the documentation.
height - The height of the output result in pixels.CadOptions class for rendering by height.IllegalArgumentException - If height is less than or equal to zero.public static CadOptions forRenderingByScaleFactor(double scaleFactor)
Initializes a new instance of the CadOptions class for rendering by scale factor.
For code example, see the documentation.
scaleFactor - The scale factor for rendering. Values greater than 1 will enlarge the output result, while values between 0 and 1 will make the output result smaller.CadOptions class for rendering by scale factor.public static CadOptions forRenderingByWidth(int width)
Initializes a new instance of the CadOptions class for rendering by width.
For code example, see the documentation.
width - The width of the output result in pixels.CadOptions class for rendering by width.IllegalArgumentException - If width is less than or equal to zero.public static CadOptions forRenderingByWidthAndHeight(int width, int height)
Initializes a new instance of the CadOptions class for rendering by width and height.
For code example, see the documentation.
width - The width of the output result in pixels.height - The height of the output result in pixels.CadOptions class for rendering by width and height.IllegalArgumentException - If width is less than or equal to zero or if height is less than or equal to zero.public Color getBackgroundColor()
Gets the background color of the image.
public String getBackgroundColorAsHex()
Gets the background color of the image.
public final int getHeight()
Gets the height of the output result in pixels.
public final List<Layer> getLayers()
Gets the CAD drawing layers to render.
Note: By default, all layers are rendered. Layer names are case-sensitive.
public final String getLayoutName()
Gets the name of the specific layout to render. The layout name is case-sensitive.
Note: This option applies only to CAD drawings that support layouts, such as FileType.DXF, FileType.DWG, FileType.DWT, FileType.DWF, and FileType.DWFX.
By default, only the Model is rendered.
public String getPc3File()
Retrieves the PC3 (Plotter Configuration) file associated with the plotter.
public final double getScaleFactor()
Gets the scale factor for rendering. Values higher than 1 will enlarge the output result, while values between 0 and 1 will make the output result smaller.
public final List<Tile> getTiles()
Gets the drawing regions to render.
Note: This option is supported only for FileType.DWG and FileType.DWT file types.
The RenderLayouts (isRenderLayouts()/setRenderLayouts(boolean))
and LayoutName (getLayoutName()/setLayoutName(String)) options are ignored
when rendering by tiles.
public final int getWidth()
Gets the width of the output result in pixels.
public int hashCode()
Computes the hash code value for this object. The hash code is based on the internal state of the object and is used in hash-based data structures such as hash maps and hash sets.
Note: This method overrides the default implementation of the hashCode() method defined in the Object class.
public boolean isEnablePerformanceConversionMode()
true if performance-oriented conversion mode is enabled, false otherwise.public final boolean isRenderLayouts()
Indicates whether layouts from the CAD document should be rendered.
Note: This option applies only to CAD drawings that support layouts, such as FileType.DXF, FileType.DWG, FileType.DWT, FileType.DWF, and FileType.DWFX.
By default, only the Model is rendered.
true if layouts should be rendered, false otherwise.public void setBackgroundColor(Color backgroundColor)
Sets the background color of the image.
backgroundColor - The background color of the image.public void setBackgroundColor(String colorName)
Sets the background color of the image.
colorName - The background color name of the image.public void setEnablePerformanceConversionMode(boolean enablePerformanceConversionMode)
enablePerformanceConversionMode - true to enable the performance-oriented conversion mode, false to disable it.public final void setLayers(List<Layer> value)
Gets the CAD drawing layers to render.
Note: By default, all layers are rendered. Layer names are case-sensitive.
value - The CAD drawing layers.public final void setLayoutName(String value)
Sets the name of the specific layout to render. The layout name is case-sensitive.
Note: This option applies only to CAD drawings that support layouts, such as FileType.DXF, FileType.DWG, FileType.DWT, FileType.DWF, and FileType.DWFX.
By default, only the Model is rendered.
value - The name of the specific layout to render.public void setPc3File(String pc3File)
Sets the PC3 (Plotter Configuration) file associated with the plotter.
pc3File - The PC3 file path.public final void setRenderLayouts(boolean value)
Sets whether layouts from the CAD document should be rendered.
Note: This option applies only to CAD drawings that support layouts, such as FileType.DXF, FileType.DWG, FileType.DWT, FileType.DWF, and FileType.DWFX.
By default, only the Model is rendered.
value - true to render layouts, false otherwise.public final void setTiles(List<Tile> value)
Sets the drawing regions to render.
Note: This option is supported only for FileType.DWG and FileType.DWT file types.
The RenderLayouts (isRenderLayouts()/setRenderLayouts(boolean))
and LayoutName (getLayoutName()/setLayoutName(String)) options are ignored
when rendering by tiles.
value - The list of drawing regions to render.public String toString()
Returns a string representation of this object.
Note: This method overrides the default implementation of the toString() method defined in the Object class.
public String toString(org.apache.commons.lang3.builder.ToStringStyle style)
Returns a string representation of this object.
Note: This method overrides the default implementation of the toString() method defined in the Object class.
style - The ToStringStyle to use for generating the string representation.ToStringStyle.Copyright © 2025. All rights reserved.