Class PdfDocument

java.lang.Object
io.github.jbastgen.stemma.app.io.PdfDocument

public final class PdfDocument extends Object
Writes a PDF whose pages are pictures (JPEG): the page of the document looks exactly like what was drawn, in every script, and no font has to be embedded. The text of such a PDF cannot be selected or searched; the title, the page numbers and the creation date are real PDF text and data. Only what this needs of the format is written: catalog, pages, one image per page, the standard font Helvetica for the footer, the information dictionary, and the cross-reference table.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
     
    static final double
    A4 in points.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PdfDocument(String title, String footer, double margin)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a page: a picture centred below the top margin, with the footer under it.
    int
    The number of pages.
    byte[]
    The PDF file: header, catalog, page tree, font, information, one page with its content and image per page, the cross-reference table and the trailer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • PdfDocument

      public PdfDocument(String title, String footer, double margin)
      Parameters:
      footer - text at the bottom of every page, before "Page n of m" (plain ASCII; other characters become ?)
      margin - space around the pictures, in points
  • Method Details

    • addPage

      public void addPage(PdfDocument.Page page)
      Adds a page: a picture centred below the top margin, with the footer under it.
    • pages

      public int pages()
      The number of pages.
    • toBytes

      public byte[] toBytes() throws IOException
      The PDF file: header, catalog, page tree, font, information, one page with its content and image per page, the cross-reference table and the trailer.
      Throws:
      IOException - when writing to memory fails (does not happen in practice)