Package io.keikai.axyra.sheets.io
Class PdfOptions
java.lang.Object
io.keikai.axyra.sheets.io.PdfOptions
Immutable options for PDF export:
Renderer.toPdf(io.keikai.axyra.sheets.Workbook, java.nio.file.Path) and
Workbook.renderPdf. Build one with builder();
toBuilder() copies an existing one for changes. Every field is
optional; empty options render exactly like the plain
toPdf(workbook, file) call.
PdfOptions opts = PdfOptions.builder()
.sheetNames("Summary")
.pageRange("1-3")
.watermark("DRAFT")
.build();
Renderer.toPdf(workbook, Path.of("summary.pdf"), opts);
- pageRange — 1-based selection over the final document, e.g.
"2-5,8". Pages beyond the document are dropped; a range that selects no pages throws. The output preserves document page order (a selection, not a reordering). - sheets / sheetNames — subset of sheets to export (union of both, workbook order). Default: all visible sheets. Explicitly selected sheets are exported even when hidden; an unknown name or out-of-range index fails.
- fitTo — page-scale override replacing each selected sheet's
own scale / fit-to-page setting:
PdfOptions.Fit.WIDTHfits all columns on one page width,PdfOptions.Fit.HEIGHTall rows on one page height,PdfOptions.Fit.PAGEthe whole sheet on a single page. - userPassword / ownerPassword / allow* — PDF encryption
(standard security handler, AES-128,
/V4 /R4 /AESV2). Setting either password encrypts the document; the user password is required to open it (empty = opens without a prompt), the owner password grants full access, and theallow*flags map to the standard permission bits (print / copy / modify). Flags default to allow. Forbidding anything without either password fails the export with anAxyraException, since an unencrypted PDF carries no permissions.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classFluent builder forPdfOptions; seebuilder().static enumFit-to-page override forPdfOptions.Builder.fitTo(Fit), with the meaning of Excel's page setup "Fit to" (ECMA-376fitToWidth/fitToHeight). -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether content copy and extraction is permitted (encryption only; defaulttrue).booleanWhether document modification is permitted (encryption only; defaulttrue).booleanWhether printing is permitted (encryption only; defaulttrue).author()Document author (PDF metadata), ornull.booleanWhether a PDF outline (one bookmark per exported sheet) is emitted.static PdfOptions.Builderbuilder()A builder with every option unset; its result renders like the plainrenderPdf(Path).fitTo()The fit-to-page override, ornullto keep each sheet's own scaling.fontDirs()Extra directories scanned for fonts, on top of the host's own font paths.The password that grants full access, ornull; seePdfOptions.Builder.ownerPassword(String).The 1-based page selection (e.g.booleanpdfA()Whether the output is PDF/A-2b conformant (ISO 19005-2 level B).The selected sheet names.int[]sheets()The selected 0-based sheet indices.title()Document title (PDF metadata), ornull.A builder pre-loaded with these options, for changing a few of them.The password required to open the document, ornull; seePdfOptions.Builder.userPassword(String).Diagonal watermark text painted under every page's content, ornull.
-
Method Details
-
builder
A builder with every option unset; its result renders like the plainrenderPdf(Path).- 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
-
title
Document title (PDF metadata), ornull. -
author
Document author (PDF metadata), ornull. -
pageRange
The 1-based page selection (e.g."2-5,8"), ornull. -
sheets
public int[] sheets()The selected 0-based sheet indices.- Returns:
- a new copy, or
nullwhen not set
-
sheetNames
The selected sheet names.- Returns:
- an unmodifiable list, or
nullwhen not set
-
fitTo
The fit-to-page override, ornullto keep each sheet's own scaling. -
userPassword
The password required to open the document, ornull; seePdfOptions.Builder.userPassword(String). -
ownerPassword
The password that grants full access, ornull; seePdfOptions.Builder.ownerPassword(String). -
allowPrint
public boolean allowPrint()Whether printing is permitted (encryption only; defaulttrue). -
allowCopy
public boolean allowCopy()Whether content copy and extraction is permitted (encryption only; defaulttrue). -
allowModify
public boolean allowModify()Whether document modification is permitted (encryption only; defaulttrue). -
watermark
Diagonal watermark text painted under every page's content, ornull. -
bookmarks
public boolean bookmarks()Whether a PDF outline (one bookmark per exported sheet) is emitted. -
pdfA
public boolean pdfA()Whether the output is PDF/A-2b conformant (ISO 19005-2 level B).
-