Class ImageOptions
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);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classFluent builder forImageOptions; seebuilder(). -
Method Summary
Modifier and TypeMethodDescriptionstatic ImageOptions.Builderbuilder()A builder with the defaults: scale 1.0, no target width, the sheet's own gridline setting, page 1 and no extra font directories.fontDirs()Extra directories scanned for fonts, on top of the host's own font paths.The gridline override.page()The printed page that renders, 1-based over the sheet's print pagination (the PDF page numbering).doublescale()The zoom over the 96-DPI base: 1.0 = 96 DPI, 2.0 = 192 DPI.The exact output width in pixels, with the height keeping the page's aspect ratio.A builder pre-loaded with these options, for changing a few of them.
-
Method Details
-
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
A builder pre-loaded with these options, for changing a few of them.- Returns:
- a new builder
-
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. SeeImageOptions.Builder.scale(double).- Returns:
- the scale; 1.0 by default
-
targetWidthPx
The exact output width in pixels, with the height keeping the page's aspect ratio. Raster output only.- Returns:
- the width, or
nullwhenscale()sets the size
-
gridLines
The gridline override.- Returns:
TRUEorFALSEto force gridlines on or off;nullto use the sheet's own print-gridlines setting
-
page
The printed page that renders, 1-based over the sheet's print pagination (the PDF page numbering).- Returns:
- the page, or
nullfor page 1
-