Class ImageOptions

java.lang.Object
io.keikai.axyra.sheets.io.ImageOptions

public final class ImageOptions extends Object
Immutable options for sheet and range image export: Renderer.toPng(io.keikai.axyra.sheets.Workbook, int, io.keikai.axyra.sheets.io.ImageOptions), Renderer.toSvg(io.keikai.axyra.sheets.Workbook, int, io.keikai.axyra.sheets.io.ImageOptions), Renderer.toImage(io.keikai.axyra.sheets.Workbook, int, java.lang.String, io.keikai.axyra.sheets.io.ImageOptions) and the JPEG, GIF, BMP and TIFF shortcuts, and the matching Workbook.render* methods. Build one with builder(); toBuilder() copies an existing one for changes.

The image is one page of the sheet's print layout, with page setup, print area and print titles honored. It is page 1 by default, or the page chosen with ImageOptions.Builder.page(int); Renderer.pageCount(io.keikai.axyra.sheets.Workbook, int) gives the number of pages. Raster output uses a 96-DPI base (1 pt = 4/3 px), so an A4 portrait page is 794 px wide at scale = 1.0. SVG output is sized in points and ignores the scale and the target width.


 ImageOptions opts = ImageOptions.builder()
         .targetWidthPx(1200)
         .gridLines(true)
         .page(2)
         .build();
 byte[] png = Renderer.toPng(workbook, 0, opts);
 
  • Method Details

    • builder

      public static ImageOptions.Builder builder()
      A builder with the defaults: scale 1.0, no target width, the sheet's own gridline setting, page 1 and no extra font directories.
      Returns:
      a new builder
    • toBuilder

      public ImageOptions.Builder toBuilder()
      A builder pre-loaded with these options, for changing a few of them.
      Returns:
      a new builder
    • fontDirs

      public List<String> fontDirs()
      Extra directories scanned for fonts, on top of the host's own font paths.

      A workbook whose fonts are not installed on the rendering machine is drawn with substitute fonts. Every character width then changes, so text wraps and clips differently from the original. Point the renderer at the directory that holds those font files to make the output match. Directories that do not exist are skipped; they do not fail the render.

      Returns:
      an unmodifiable list; empty by default
    • scale

      public double scale()
      The zoom over the 96-DPI base: 1.0 = 96 DPI, 2.0 = 192 DPI. Raster output only; ignored when a target width is set. See ImageOptions.Builder.scale(double).
      Returns:
      the scale; 1.0 by default
    • targetWidthPx

      public Integer targetWidthPx()
      The exact output width in pixels, with the height keeping the page's aspect ratio. Raster output only.
      Returns:
      the width, or null when scale() sets the size
    • gridLines

      public Boolean gridLines()
      The gridline override.
      Returns:
      TRUE or FALSE to force gridlines on or off; null to use the sheet's own print-gridlines setting
    • page

      public Integer page()
      The printed page that renders, 1-based over the sheet's print pagination (the PDF page numbering).
      Returns:
      the page, or null for page 1