CadOptions
Inheritance: java.lang.Object
public class CadOptions
Provides options for rendering CAD drawings.
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
}
Fields
Field | Description |
---|---|
WIDTH | |
HEIGHT |
Methods
Method | Description |
---|---|
getPc3File() | Retrieves the PC3 (Plotter Configuration) file associated with the plotter. |
setPc3File(String pc3File) | Sets the PC3 (Plotter Configuration) file associated with the plotter. |
forRenderingByScaleFactor(double scaleFactor) | Initializes a new instance of the CadOptions class for rendering by scale factor. |
forRenderingByWidth(int width) | Initializes a new instance of the CadOptions class for rendering by width. |
forRenderingByHeight(int height) | Initializes a new instance of the CadOptions class for rendering by height. |
forRenderingByWidthAndHeight(int width, int height) | Initializes a new instance of the CadOptions class for rendering by width and height. |
getScaleFactor() | Gets the scale factor for rendering. |
getWidth() | Gets the width of the output result in pixels. |
getHeight() | Gets the height of the output result in pixels. |
getBackgroundColor() | Gets the background color of the image. |
getBackgroundColorAsHex() | Gets the background color of the image. |
setBackgroundColor(Color backgroundColor) | Sets the background color of the image. |
setBackgroundColor(String colorName) | Sets the background color of the image. |
getTiles() | Gets the drawing regions to render. |
setTiles(List |
Sets the drawing regions to render. |
isRenderLayouts() | Indicates whether layouts from the CAD document should be rendered. |
setRenderLayouts(boolean value) | Sets whether layouts from the CAD document should be rendered. |
getLayoutName() | Gets the name of the specific layout to render. |
setLayoutName(String value) | Sets the name of the specific layout to render. |
getLayers() | Gets the CAD drawing layers to render. |
setLayers(List |
Gets the CAD drawing layers to render. |
isEnablePerformanceConversionMode() | Setting this flag to true enables a special performance-oriented conversion mode for all formats within the CAD family. |
setEnablePerformanceConversionMode(boolean enablePerformanceConversionMode) | Setting this flag to true enables a special performance-oriented conversion mode for all formats within the CAD family. |
equals(Object o) | Checks if this CadOptions object is equal to another object. |
hashCode() | {@inheritDoc} |
toString() | {@inheritDoc} |
toString(ToStringStyle style) | {@inheritDoc} |
WIDTH
public static final String WIDTH
HEIGHT
public static final String HEIGHT
getPc3File()
public String getPc3File()
Retrieves the PC3 (Plotter Configuration) file associated with the plotter.
Returns: java.lang.String - the PC3 file path.
setPc3File(String pc3File)
public void setPc3File(String pc3File)
Sets the PC3 (Plotter Configuration) file associated with the plotter.
Parameters:
Parameter | Type | Description |
---|---|---|
pc3File | java.lang.String | The PC3 file path. |
forRenderingByScaleFactor(double scaleFactor)
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.
Parameters:
Parameter | Type | Description |
---|---|---|
scaleFactor | double | 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. |
Returns: CadOptions - a new instance of the CadOptions class for rendering by scale factor.
forRenderingByWidth(int width)
public static CadOptions forRenderingByWidth(int width)
Initializes a new instance of the CadOptions class for rendering by width.
For code example, see the documentation.
Parameters:
Parameter | Type | Description |
---|---|---|
width | int | The width of the output result in pixels. |
Returns: CadOptions - a new instance of the CadOptions class for rendering by width.
forRenderingByHeight(int height)
public static CadOptions forRenderingByHeight(int height)
Initializes a new instance of the CadOptions class for rendering by height.
For code example, see the documentation.
Parameters:
Parameter | Type | Description |
---|---|---|
height | int | The height of the output result in pixels. |
Returns: CadOptions - a new instance of the CadOptions class for rendering by height.
forRenderingByWidthAndHeight(int width, int height)
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.
Parameters:
Parameter | Type | Description |
---|---|---|
width | int | The width of the output result in pixels. |
height | int | The height of the output result in pixels. |
Returns: CadOptions - a new instance of the CadOptions class for rendering by width and height.
getScaleFactor()
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.
Returns: double - the scale factor for rendering.
getWidth()
public final int getWidth()
Gets the width of the output result in pixels.
Returns: int - the width of the output result.
getHeight()
public final int getHeight()
Gets the height of the output result in pixels.
Returns: int - the height of the output result.
getBackgroundColor()
public Color getBackgroundColor()
Gets the background color of the image.
Returns: java.awt.Color - the background color of the image.
getBackgroundColorAsHex()
public String getBackgroundColorAsHex()
Gets the background color of the image.
Returns: java.lang.String - the background color of the image in 0xFFFFFF format.
setBackgroundColor(Color backgroundColor)
public void setBackgroundColor(Color backgroundColor)
Sets the background color of the image.
Parameters:
Parameter | Type | Description |
---|---|---|
backgroundColor | java.awt.Color | The background color of the image. |
setBackgroundColor(String colorName)
public void setBackgroundColor(String colorName)
Sets the background color of the image.
Parameters:
Parameter | Type | Description |
---|---|---|
colorName | java.lang.String | The background color name of the image. |
getTiles()
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.
Returns: java.util.List<com.groupdocs.viewer.options.Tile> - the list of drawing regions to render.
setTiles(List value)
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.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.util.List<com.groupdocs.viewer.options.Tile> | The list of drawing regions to render. |
isRenderLayouts()
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.
Returns: boolean - true if layouts should be rendered, false otherwise.
setRenderLayouts(boolean value)
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.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | true to render layouts, false otherwise. |
getLayoutName()
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.
Returns: java.lang.String - the name of the specific layout to render.
setLayoutName(String value)
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.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | The name of the specific layout to render. |
getLayers()
public final List<Layer> getLayers()
Gets the CAD drawing layers to render.
Note: By default, all layers are rendered. Layer names are case-sensitive.
Returns: java.util.List<com.groupdocs.viewer.results.Layer> - the CAD drawing layers.
setLayers(List value)
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.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.util.List<com.groupdocs.viewer.results.Layer> | The CAD drawing layers. |
isEnablePerformanceConversionMode()
public boolean isEnablePerformanceConversionMode()
Setting this flag to true enables a special performance-oriented conversion mode for all formats within the CAD family. In this mode, the conversion speed is much faster, but the quality of the resultant documents is significantly worse. By default, it is disabled (false). The quality of the resultant documents is the best possible at the expense of performance.
Returns: boolean - true if performance-oriented conversion mode is enabled, false otherwise.
setEnablePerformanceConversionMode(boolean enablePerformanceConversionMode)
public void setEnablePerformanceConversionMode(boolean enablePerformanceConversionMode)
Setting this flag to true enables a special performance-oriented conversion mode for all formats within the CAD family. In this mode, the conversion speed is much faster, but the quality of the resultant documents is significantly worse. By default, it is disabled (false). The quality of the resultant documents is the best possible at the expense of performance.
Parameters:
Parameter | Type | Description |
---|---|---|
enablePerformanceConversionMode | boolean | true to enable the performance-oriented conversion mode, false to disable it. |
equals(Object o)
public boolean equals(Object o)
Checks if this CadOptions object is equal to another object.
Parameters:
Parameter | Type | Description |
---|---|---|
o | java.lang.Object | The object to compare with. |
Returns: boolean - true if the objects are equal, false otherwise.
hashCode()
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.
Returns: int - the hash code value for this object.
toString()
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.
Returns: java.lang.String - a string representation of this object.
toString(ToStringStyle style)
public String toString(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.
Parameters:
Parameter | Type | Description |
---|---|---|
style | org.apache.commons.lang3.builder.ToStringStyle | The ToStringStyle to use for generating the string representation. |
Returns: java.lang.String - a string representation of this object using the specified ToStringStyle.