com.groupdocs.viewer.converter.options

Class CadOptions



  • public class CadOptions
    extends Object

    The CAD documents rendering options.

    • Constructor Detail

      • CadOptions

        public CadOptions()

        Initializes a new instance of the CadOptions class.

    • Method Detail

      • setHeight

        public void setHeight(int value)

        The height of the render result in pixels.

        Example:
        The following example demonstrates how to set output image height in pixels.

         ViewerImageHandler imageHandler = new ViewerImageHandler();
         ImageOptions options = new ImageOptions();
         options.getCadOptions().setHeight(750);
        
         String guid = "document.dwg";
         List<PageImage> pages = imageHandler.getPages(guid, options);
         

        Parameters:
        value - The height.
      • setLayers

        public void setLayers(List<String> value)

        The list of document layers to render.

        Note:
        When the list is empty, all visible layers will be rendered. Layer names are case sensitive.

        Example:
        The following example demonstrates how to render specific layers from CAD drawing.

         ViewerImageHandler imageHandler = new ViewerImageHandler();
         ImageOptions options = new ImageOptions();
         options.getCadOptions().getLayers().add("LayerName");
        
         String guid = "multilayer.dwg";
         List<PageImage> pages = imageHandler.getPages(guid, options);
         

        Parameters:
        value - The list of document layers to render.
      • setLayoutName

        public void setLayoutName(String value)

        The name of the specific layout to render.

        Note:
        This property is case-insensitive.

        Example:
        The following example demonstrates how to render specific layout from dwg drawing.

         ViewerImageHandler imageHandler = new ViewerImageHandler();
         ImageOptions options = new ImageOptions();
         options.getCadOptions().setLayoutName("layout1");
        
         String guid = "multilayout.dwg";
         List<PageImage> pages = imageHandler.getPages(guid, options);
         

        Parameters:
        value - The name of the specific layout to render.
      • setRenderLayouts

        public void setRenderLayouts(boolean value)

        Indicates whether layouts from CAD document should be rendered. Default value is false.

        Note:
        This option applies only to CAD formats, that support layouts, like dxf and dwg. When render layouts is enabled, Model and all non-empty layouts contained in the CAD document will be rendered. Otherwise only Model is rendered.

        Example:
        The following example demonstrates how to render layouts from dwg drawing.

         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler();
         HtmlOptions options = new HtmlOptions();
         options.getCadOptions().setRenderLayouts(true);
        
         String guid = "multilayout.dwg";
         List<PageHtml> pages = htmlHandler.getPages(guid, options);
         

        Parameters:
        value - True if layouts from CAD document should be rendered.
      • setScaleFactor

        public void setScaleFactor(float value)

        The scale factor affects the size of an output document.

        Note:
        Values higher than 1 will enlarge and values between 0 and 1 will make render result smaller. This property is ignored when either Height or Width properties are set.

        Example:
        The following example demonstrates how to set the scale factor while rendering into HTML.

         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler();
         HtmlOptions options = new HtmlOptions();
         options.getCadOptions().setScaleFactor(1.5f);
        
         String guid = "document.dwg";
         List<PageHtml> pages = htmlHandler.getPages(guid, options);
         

        Parameters:
        value - The scale factor.
      • setTiles

        public void setTiles(List<Tile> value)

        The coordinates of the drawing regions, that should be rendered.

        Note:
        Please note, that this option works only for DWG format. When the list is empty, then whole drawing is rendered. When the list contains at least one tile, then ScaleFactor, Width, Height, RenderLayouts and LayoutName properties are ignored.

        Example:
        The following example demonstrates how to render the bottom left part of the drawing.

         // Create image handler
         ViewerImageHandler imageHandler = new ViewerImageHandler(config);
         String guid = "document.dwg";
        
         // Get document width and height
         DocumentInfoContainer docInfo = imageHandler.getDocumentInfo(guid);
         int width = docInfo.getPages().get(0).getWidth();
         int height = docInfo.getPages().get(0).getHeight();
         // Set tile width and height as a half of whole image
         int tileWidth = width / 2;
         int tileHeight = height / 2;
        
         int pointX = 0;
         int pointY = 0;
         // Create image options to add bottom left part of the drawing
         ImageOptions options = new ImageOptions();
         Tile tile = new Tile(pointX, pointY, tileWidth, tileHeight);
        
         // The pages list will contain only one image - the bottom left part of the drawing.
         List<PageImage> pages = imageHandler.getPages(guid, options);
        
         for (PageImage page : pages)
         {
             System.out.println("Page number: " + page.getPageNumber());
             InputStream imageContent = page.getStream();
         }
         

        Parameters:
        value - The coordinates of the drawing regions
      • setWidth

        public void setWidth(int value)

        The width of the render result in pixels.

        Example:
        The following example demonstrates how to set output image width in pixels.

         ViewerImageHandler imageHandler = new ViewerImageHandler();
         ImageOptions options = new ImageOptions();
         options.getCadOptions().setWidth(850);
        
         String guid = "document.dwg";
         List<PageImage> pages = imageHandler.getPages(guid, options);
         

        Parameters:
        value - The width.