Class PdfOptions

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

public final class PdfOptions extends Object
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.WIDTH fits all columns on one page width, PdfOptions.Fit.HEIGHT all rows on one page height, PdfOptions.Fit.PAGE the 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 the allow* flags map to the standard permission bits (print / copy / modify). Flags default to allow.
  • Method Details

    • builder

      public static PdfOptions.Builder builder()
      A builder with every option unset; its result renders like the plain renderPdf(Path).
      Returns:
      a new builder
    • toBuilder

      public PdfOptions.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
    • title

      public String title()
      Document title (PDF metadata), or null.
    • author

      public String author()
      Document author (PDF metadata), or null.
    • pageRange

      public String pageRange()
      The 1-based page selection (e.g. "2-5,8"), or null.
    • sheets

      public int[] sheets()
      The selected 0-based sheet indices.
      Returns:
      a new copy, or null when not set
    • sheetNames

      public List<String> sheetNames()
      The selected sheet names.
      Returns:
      an unmodifiable list, or null when not set
    • fitTo

      public PdfOptions.Fit fitTo()
      The fit-to-page override, or null to keep each sheet's own scaling.
    • userPassword

      public String userPassword()
      The password required to open the document, or null; see PdfOptions.Builder.userPassword(String).
    • ownerPassword

      public String ownerPassword()
      The password that grants full access, or null; see PdfOptions.Builder.ownerPassword(String).
    • allowPrint

      public boolean allowPrint()
      Whether printing is permitted (encryption only; default true).
    • allowCopy

      public boolean allowCopy()
      Whether content copy and extraction is permitted (encryption only; default true).
    • allowModify

      public boolean allowModify()
      Whether document modification is permitted (encryption only; default true).
    • watermark

      public String watermark()
      Diagonal watermark text painted under every page's content, or null.
    • 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).