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

org.apache.fop.pdf

## Class PDFEncryptionJCE

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

- All Implemented Interfaces:
    PDFEncryption, PDFWritable

      public final class PDFEncryptionJCE
      extends PDFObject
      implements PDFEncryption

  An implementation of the Standard Security Handler.

- - ### Field Summary

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

      `log`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `applyFilter(AbstractPDFStream stream)` Adds a PDFFilter to the PDFStream object
    `byte[]` | `encrypt(byte[] data, PDFObject refObj)` Encrypt an array of bytes using a reference PDFObject for calculating the encryption key.
    `Version` | `getPDFVersion()` Returns the PDF version required by the current encryption algorithm.
    `String` | `getTrailerEntry()` Returns the /Encrypt entry in the file trailer dictionary.
    `static PDFEncryption` | `make(PDFObjectNumber objectNumber, PDFEncryptionParams params, PDFDocument pdf)` Creates and returns an encryption object.
    `boolean` | `supportsObjectStream()`
    `byte[]` | `toPDF()` Prepares the encryption dictionary for output to a PDF file.

    - ### 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, toPDFString`

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

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

- - ### Method Detail

    - #### make

          public static PDFEncryption make(PDFObjectNumber objectNumber,
                                           PDFEncryptionParams params,
                                           PDFDocument pdf)

      Creates and returns an encryption object.
      Parameters:
        `objectNumber` - the object number for the encryption dictionary
        `params` - the encryption parameters
        `pdf` - the PDF document to be encrypted
      Returns:
        the newly created encryption object

    - #### encrypt

          public byte[] encrypt(byte[] data,
                                PDFObject refObj)

      Encrypt an array of bytes using a reference PDFObject for calculating the encryption key.
      Specified by:
        `encrypt` in interface `PDFEncryption`
      Parameters:
        `data` - data to encrypt
        `refObj` - reference PDFObject
      Returns:
        byte[] the encrypted data

    - #### applyFilter

          public void applyFilter(AbstractPDFStream stream)

      Adds a PDFFilter to the PDFStream object
      Specified by:
        `applyFilter` in interface `PDFEncryption`
      Parameters:
        `stream` - the stream to add an encryption filter to

    - #### toPDF

          public byte[] toPDF()

      Prepares the encryption dictionary for output to a PDF file.
      Overrides:
        `toPDF` in class `PDFObject`
      Returns:
        the encryption dictionary as a byte array

    - #### getTrailerEntry

          public String getTrailerEntry()

      Returns the /Encrypt entry in the file trailer dictionary.
      Specified by:
        `getTrailerEntry` in interface `PDFEncryption`
      Returns:
        the string "/Encrypt n g R\n" where n and g are the number and generation of the document's encryption dictionary

    - #### getPDFVersion

          public Version getPDFVersion()

      Returns the PDF version required by the current encryption algorithm.
      Specified by:
        `getPDFVersion` in interface `PDFEncryption`
      Returns:
        the PDF Version

    - #### supportsObjectStream

          public boolean supportsObjectStream()

      Overrides:
        `supportsObjectStream` in class `PDFObject`

Copyright © 2025 Apache Software Foundation. All rights reserved.