PDFPages (Apache FOP Core 2.11 API)
Date: 2025-04-24

org.apache.fop.pdf

## Class PDFPages

- java.lang.Object
- - org.apache.fop.pdf.PDFObject
  - - org.apache.fop.pdf.PDFPages

- All Implemented Interfaces:
    PDFWritable

      public class PDFPages
      extends PDFObject

  class representing a /Pages object. A /Pages object is an ordered collection of pages (/Page objects) (Actually, /Pages can contain further /Pages as well but this implementation doesn't allow this)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `count` the number of /Page objects
    `protected List` | `kids` the /Page objects

    - ### Fields inherited from class org.apache.fop.pdf.PDFObject

      `log`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PDFPages(PDFDocument document)` create a /Pages object.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addPage(PDFPage page)` add a /Page object.
    `int` | `getCount()` get the count of /Page objects
    `void` | `incrementCount()` increment the count of /Page objects
    `void` | `notifyKidRegistered(PDFPage page)` Use this method to notify the PDFPages object that a child page
    `String` | `toPDFString()` This method returns a String representation of the PDF object.

    - ### Methods inherited from class org.apache.fop.pdf.PDFObject

      `contentEquals, encode, encodeBinaryToHexString, encodeString, encodeText, formatObject, getChildren, getDocument, getDocumentSafely, getGeneration, getObjectID, getObjectNumber, getParent, hasObjectNumber, makeReference, output, outputInline, referencePDF, setDocument, setObjectNumber, setObjectNumber, setObjectNumber, setParent, supportsObjectStream, toPDF`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### kids

          protected List kids

      the /Page objects

    - #### count

          protected int count

      the number of /Page objects

  - ### Constructor Detail

    - #### PDFPages

          public PDFPages(PDFDocument document)

      create a /Pages object. NOTE: The PDFPages object must be created before the PDF document is generated, but it is not written to the stream immediately. It must also be allocated an object ID (so that the kids can refer to the parent) so that the XRef table needs to be updated before this object is written.

  - ### Method Detail

    - #### addPage

          public void addPage(PDFPage page)

      add a /Page object.
      Parameters:
        `page` - the PDFPage to add.

    - #### notifyKidRegistered

          public void notifyKidRegistered(PDFPage page)

      Use this method to notify the PDFPages object that a child page
      Parameters:
        `page` - the child page

    - #### getCount

          public int getCount()

      get the count of /Page objects
      Returns:
        the number of pages

    - #### incrementCount

          public void incrementCount()

      increment the count of /Page objects

    - #### toPDFString

          public String toPDFString()

      This method returns a String representation of the PDF object. The result is normally converted/encoded to a byte array by toPDF(). Only use this method to implement the serialization if the object can be fully represented as text. If the PDF representation of the object contains binary content use toPDF() or output(OutputStream) instead. This applies to any object potentially containing a string object because string object are encrypted and therefore need to be binary.
      Overrides:
        `toPDFString` in class `PDFObject`
      Returns:
        String the String representation

Copyright © 2025 Apache Software Foundation. All rights reserved.