Package io.keikai.axyra.sheets.io
Class PdfOptions.Builder
java.lang.Object
io.keikai.axyra.sheets.io.PdfOptions.Builder
- Enclosing class:
- PdfOptions
Fluent builder for
PdfOptions; see PdfOptions.builder().-
Method Summary
Modifier and TypeMethodDescriptionaddFontDir(String dir) Adds one directory tofontDirs(List).allowCopy(boolean allow) Permits or forbids copying and extracting content.allowModify(boolean allow) Permits or forbids changing the document.allowPrint(boolean allow) Permits or forbids printing.Sets the document author in the PDF metadata.bookmarks(boolean on) Adds a PDF outline (bookmarks): one entry per exported sheet, pointing at the sheet's first page.build()Builds immutable options; later builder calls do not change them.fitTo(PdfOptions.Fit fit) Overrides the scaling of every selected sheet; each sheet's own scale and fit-to-page setting is ignored.Sets the extra directories scanned for fonts, on top of the host's own font paths, replacing any set before.ownerPassword(String password) Sets the password that grants full access and lifts theallow*restrictions; this turns on encryption.Selects pages of the final document: comma-separated 1-based pages or inclusive spans, e.g.pdfA(boolean on) Produces a PDF/A-2b conformant document (ISO 19005-2 level B): XMP identification metadata, an sRGB output intent, a document ID and print-flagged annotations.sheetNames(String... names) Selects sheets to export by name, compared case-sensitively.sheets(int... sheets) Selects sheets to export by 0-based index.Sets the document title in the PDF metadata.userPassword(String password) Sets the password required to open the document; this turns on AES-128 encryption.Paintstextdiagonally, in light gray, under every page's content, e.g.
-
Method Details
-
title
Sets the document title in the PDF metadata.- Parameters:
title- the title;nullleaves it unset- Returns:
- this builder
-
author
Sets the document author in the PDF metadata.- Parameters:
author- the author;nullleaves it unset- Returns:
- this builder
-
pageRange
Selects pages of the final document: comma-separated 1-based pages or inclusive spans, e.g."2-5,8"; spaces are allowed. Pages past the end are dropped, and the output keeps document order.- Parameters:
pageRange- the selection;nullselects every page. A malformed selection ("0","3-1","1,,2", letters), or one that selects no page, makes the export throwAxyraException- Returns:
- this builder
-
sheets
Selects sheets to export by 0-based index. Combined withsheetNames(String...)as a union in workbook order; duplicates are dropped. Listed sheets are exported even when hidden. Default: all visible sheets.- Parameters:
sheets- the indices;nullclears the selection. A negative or out-of-range index makes the export throwAxyraException- Returns:
- this builder
-
sheetNames
Selects sheets to export by name, compared case-sensitively. Combined withsheets(int...)as a union in workbook order. Listed sheets are exported even when hidden.- Parameters:
names- the names;nullclears the selection. An unknown name makes the export throwAxyraException- Returns:
- this builder
-
fitTo
Overrides the scaling of every selected sheet; each sheet's own scale and fit-to-page setting is ignored.- Parameters:
fit- the override;nullkeeps each sheet's own scaling- Returns:
- this builder
-
userPassword
Sets the password required to open the document; this turns on AES-128 encryption. Without anownerPassword(String)the owner password equals this one, so anyone who opens the file also has owner rights and theallow*flags do not restrict them.- Parameters:
password- the password;nullunsets it- Returns:
- this builder
-
ownerPassword
Sets the password that grants full access and lifts theallow*restrictions; this turns on encryption. Without a user password the document opens without a prompt, and theallow*flags apply to its readers.- Parameters:
password- the password;nullunsets it- Returns:
- this builder
-
allowPrint
Permits or forbids printing. Applies only to an encrypted document, and only to a reader without the owner password. Defaulttrue.- Parameters:
allow-falseto forbid printing- Returns:
- this builder
-
allowCopy
Permits or forbids copying and extracting content. Applies only to an encrypted document, and only to a reader without the owner password. Defaulttrue.- Parameters:
allow-falseto forbid copying- Returns:
- this builder
-
allowModify
Permits or forbids changing the document. Applies only to an encrypted document, and only to a reader without the owner password. Defaulttrue.- Parameters:
allow-falseto forbid changes- Returns:
- this builder
-
watermark
Paintstextdiagonally, in light gray, under every page's content, e.g."CONFIDENTIAL"or"DRAFT".- Parameters:
text- the watermark text;nullor an empty string paints nothing- Returns:
- this builder
-
bookmarks
Adds a PDF outline (bookmarks): one entry per exported sheet, pointing at the sheet's first page. WithpageRange(String), a sheet whose pages are all dropped loses its bookmark, and the other entries point at the renumbered pages. Defaultfalse.- Parameters:
on-trueto add the outline- Returns:
- this builder
-
fontDirs
Sets the extra directories scanned for fonts, on top of the host's own font paths, replacing any set before.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.
- Parameters:
dirs- directory paths;nullclears the list- Returns:
- this builder
-
addFontDir
Adds one directory tofontDirs(List).- Parameters:
dir- the directory path;nullor empty is ignored- Returns:
- this builder
-
pdfA
Produces a PDF/A-2b conformant document (ISO 19005-2 level B): XMP identification metadata, an sRGB output intent, a document ID and print-flagged annotations. Defaultfalse. PDF/A forbids encryption, so combiningpdfA(true)with a user or owner password makes the export throwAxyraException.- Parameters:
on-truefor PDF/A-2b- Returns:
- this builder
-
build
Builds immutable options; later builder calls do not change them.- Returns:
- the options
-