Class PdfADocument

All Implemented Interfaces:
IEventDispatcher, Closeable, AutoCloseable
Direct Known Subclasses:
PdfAAgnosticPdfDocument

public class PdfADocument extends PdfDocument
This class extends PdfDocument and is in charge of creating files that comply with the PDF/A standard. Client code is still responsible for making sure the file is actually PDF/A compliant: multiple steps must be undertaken (depending on the PdfAConformanceLevel) to ensure that the PDF/A standard is followed. This class will throw exceptions, mostly PdfAConformanceException, and thus refuse to output a PDF/A file if at any point the document does not adhere to the PDF/A guidelines specified by the PdfAConformanceLevel.
  • Field Details

    • pdfAPageFactory

      private static IPdfPageFactory pdfAPageFactory
    • checker

      protected PdfAChecker checker
    • alreadyLoggedThatObjectFlushingWasNotPerformed

      private boolean alreadyLoggedThatObjectFlushingWasNotPerformed
    • alreadyLoggedThatPageFlushingWasNotPerformed

      private boolean alreadyLoggedThatPageFlushingWasNotPerformed
    • isPdfADocument

      private boolean isPdfADocument
  • Constructor Details

    • PdfADocument

      public PdfADocument(PdfWriter writer, PdfAConformanceLevel conformanceLevel, PdfOutputIntent outputIntent)
      Constructs a new PdfADocument for writing purposes, i.e. from scratch. A PDF/A file has a conformance level, and must have an explicit output intent.
      Parameters:
      writer - the PdfWriter object to write to
      conformanceLevel - the generation and strictness level of the PDF/A that must be followed.
      outputIntent - a PdfOutputIntent
    • PdfADocument

      public PdfADocument(PdfWriter writer, PdfAConformanceLevel conformanceLevel, PdfOutputIntent outputIntent, DocumentProperties properties)
      Constructs a new PdfADocument for writing purposes, i.e. from scratch. A PDF/A file has a conformance level, and must have an explicit output intent.
      Parameters:
      writer - the PdfWriter object to write to
      conformanceLevel - the generation and strictness level of the PDF/A that must be followed.
      outputIntent - a PdfOutputIntent
      properties - a DocumentProperties
    • PdfADocument

      public PdfADocument(PdfReader reader, PdfWriter writer)
      Opens a PDF/A document in the stamping mode.
      Parameters:
      reader - PDF reader.
      writer - PDF writer.
    • PdfADocument

      public PdfADocument(PdfReader reader, PdfWriter writer, StampingProperties properties)
      Opens a PDF/A document in stamping mode.
      Parameters:
      reader - PDF reader.
      writer - PDF writer.
      properties - properties of the stamping process
    • PdfADocument

      PdfADocument(PdfReader reader, PdfWriter writer, StampingProperties properties, boolean tolerant)
  • Method Details

    • getDefaultFont

      public PdfFont getDefaultFont()
      No default font for PDF/A documents.
      Overrides:
      getDefaultFont in class PdfDocument
      Returns:
      null.
    • getConformanceLevel

      public IConformanceLevel getConformanceLevel()
      Overrides:
      getConformanceLevel in class PdfDocument
      Returns:
      the IConformanceLevel will be null if the document does not have a conformance level specified
    • addOutputIntent

      public void addOutputIntent(PdfOutputIntent outputIntent)
      Adds PdfOutputIntent that shall specify the colour characteristics of output devices on which the document might be rendered.
      Overrides:
      addOutputIntent in class PdfDocument
      Parameters:
      outputIntent - PdfOutputIntent to add.
      See Also:
    • logThatPdfAPageFlushingWasNotPerformed

      void logThatPdfAPageFlushingWasNotPerformed()
    • addCustomMetadataExtensions

      protected void addCustomMetadataExtensions(XMPMeta xmpMeta)
      Description copied from class: PdfDocument
      Adds custom XMP metadata extension. Useful for PDF/UA, ZUGFeRD, etc.
      Overrides:
      addCustomMetadataExtensions in class PdfDocument
      Parameters:
      xmpMeta - XMPMeta to add custom metadata to.
    • updateXmpMetadata

      protected void updateXmpMetadata()
      Description copied from class: PdfDocument
      Updates XMP metadata. Shall be overridden.
      Overrides:
      updateXmpMetadata in class PdfDocument
    • checkIsoConformance

      protected void checkIsoConformance()
      Description copied from class: PdfDocument
      Checks whether PDF document conforms to a specific standard.
      Overrides:
      checkIsoConformance in class PdfDocument
    • checkIsoConformance

      public void checkIsoConformance(Object obj, IsoKey key, PdfResources resources, PdfStream contentStream, Object extra)
      Description copied from class: PdfDocument
      Checks whether PDF document conforms a specific standard.
      Overrides:
      checkIsoConformance in class PdfDocument
      Parameters:
      obj - an object to conform.
      key - type of object to conform.
      resources - PdfResources associated with an object to check.
      contentStream - current content stream.
      extra - extra data required for the check.
    • flushObject

      protected void flushObject(PdfObject pdfObject, boolean canBeInObjStm) throws IOException
      Description copied from class: PdfDocument
      Flush an object.
      Overrides:
      flushObject in class PdfDocument
      Parameters:
      pdfObject - object to flush.
      canBeInObjStm - indicates whether object can be placed into object stream.
      Throws:
      IOException - on error.
    • setChecker

      protected void setChecker(PdfAConformanceLevel conformanceLevel)
      Sets the checker that defines the requirements of the PDF/A standard depending on conformance level.
      Parameters:
      conformanceLevel - PdfAConformanceLevel
    • setChecker

      protected void setChecker(PdfAChecker checker)
    • setCheckerIfChanged

      private void setCheckerIfChanged()
    • getCorrectCheckerFromConformance

      private static PdfAChecker getCorrectCheckerFromConformance(PdfAConformanceLevel conformanceLevel)
    • initTagStructureContext

      protected void initTagStructureContext()
      Initializes tagStructureContext to track necessary information of document's tag structure.
      Overrides:
      initTagStructureContext in class PdfDocument
    • getPageFactory

      protected IPdfPageFactory getPageFactory()
      Description copied from class: PdfDocument
      Returns the factory for creating page instances.
      Overrides:
      getPageFactory in class PdfDocument
      Returns:
      implementation of IPdfPageFactory for current document
    • flushInfoDictionary

      protected void flushInfoDictionary(boolean appendMode)
      Flush info dictionary if needed.
      Overrides:
      flushInfoDictionary in class PdfDocument
      Parameters:
      appendMode - true if the document is edited in append mode.
    • isClosing

      boolean isClosing()
    • getPdfVersionForPdfA

      private static PdfVersion getPdfVersionForPdfA(PdfAConformanceLevel conformanceLevel)