Class PdfOptions.Builder

java.lang.Object
io.keikai.axyra.sheets.io.PdfOptions.Builder
Enclosing class:
PdfOptions

public static final class PdfOptions.Builder extends Object
Fluent builder for PdfOptions; see PdfOptions.builder().
  • Method Details

    • title

      public PdfOptions.Builder title(String title)
      Sets the document title in the PDF metadata.
      Parameters:
      title - the title; null leaves it unset
      Returns:
      this builder
    • author

      public PdfOptions.Builder author(String author)
      Sets the document author in the PDF metadata.
      Parameters:
      author - the author; null leaves it unset
      Returns:
      this builder
    • pageRange

      public PdfOptions.Builder pageRange(String 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; null selects every page. A malformed selection ("0", "3-1", "1,,2", letters), or one that selects no page, makes the export throw AxyraException
      Returns:
      this builder
    • sheets

      public PdfOptions.Builder sheets(int... sheets)
      Selects sheets to export by 0-based index. Combined with sheetNames(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; null clears the selection. A negative or out-of-range index makes the export throw AxyraException
      Returns:
      this builder
    • sheetNames

      public PdfOptions.Builder sheetNames(String... names)
      Selects sheets to export by name, compared case-sensitively. Combined with sheets(int...) as a union in workbook order. Listed sheets are exported even when hidden.
      Parameters:
      names - the names; null clears the selection. An unknown name makes the export throw AxyraException
      Returns:
      this builder
    • fitTo

      public PdfOptions.Builder fitTo(PdfOptions.Fit fit)
      Overrides the scaling of every selected sheet; each sheet's own scale and fit-to-page setting is ignored.
      Parameters:
      fit - the override; null keeps each sheet's own scaling
      Returns:
      this builder
    • userPassword

      public PdfOptions.Builder userPassword(String password)
      Sets the password required to open the document; this turns on AES-128 encryption. Without an ownerPassword(String) the owner password equals this one, so anyone who opens the file also has owner rights and the allow* flags do not restrict them.
      Parameters:
      password - the password; null unsets it
      Returns:
      this builder
    • ownerPassword

      public PdfOptions.Builder ownerPassword(String password)
      Sets the password that grants full access and lifts the allow* restrictions; this turns on encryption. Without a user password the document opens without a prompt, and the allow* flags apply to its readers.
      Parameters:
      password - the password; null unsets it
      Returns:
      this builder
    • allowPrint

      public PdfOptions.Builder allowPrint(boolean allow)
      Permits or forbids printing. Applies only to an encrypted document, and only to a reader without the owner password. Default true.
      Parameters:
      allow - false to forbid printing
      Returns:
      this builder
    • allowCopy

      public PdfOptions.Builder allowCopy(boolean allow)
      Permits or forbids copying and extracting content. Applies only to an encrypted document, and only to a reader without the owner password. Default true.
      Parameters:
      allow - false to forbid copying
      Returns:
      this builder
    • allowModify

      public PdfOptions.Builder allowModify(boolean allow)
      Permits or forbids changing the document. Applies only to an encrypted document, and only to a reader without the owner password. Default true.
      Parameters:
      allow - false to forbid changes
      Returns:
      this builder
    • watermark

      public PdfOptions.Builder watermark(String text)
      Paints text diagonally, in light gray, under every page's content, e.g. "CONFIDENTIAL" or "DRAFT".
      Parameters:
      text - the watermark text; null or an empty string paints nothing
      Returns:
      this builder
    • bookmarks

      public PdfOptions.Builder bookmarks(boolean on)
      Adds a PDF outline (bookmarks): one entry per exported sheet, pointing at the sheet's first page. With pageRange(String), a sheet whose pages are all dropped loses its bookmark, and the other entries point at the renumbered pages. Default false.
      Parameters:
      on - true to add the outline
      Returns:
      this builder
    • fontDirs

      public PdfOptions.Builder fontDirs(List<String> dirs)
      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; null clears the list
      Returns:
      this builder
    • addFontDir

      public PdfOptions.Builder addFontDir(String dir)
      Adds one directory to fontDirs(List).
      Parameters:
      dir - the directory path; null or empty is ignored
      Returns:
      this builder
    • pdfA

      public PdfOptions.Builder 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. Default false. PDF/A forbids encryption, so combining pdfA(true) with a user or owner password makes the export throw AxyraException.
      Parameters:
      on - true for PDF/A-2b
      Returns:
      this builder
    • build

      public PdfOptions build()
      Builds immutable options; later builder calls do not change them.
      Returns:
      the options