Class PdfADocument

java.lang.Object
com.itextpdf.kernel.pdf.PdfDocument
com.itextpdf.pdfa.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

  • 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
  • Method Details

    • checkIsoConformance

      public void checkIsoConformance (Object obj, IsoKey key)
      Description copied from class: PdfDocument
      Checks whether PDF document conforms a specific standard. Shall be override.
      Overrides:
      checkIsoConformance in class PdfDocument
      Parameters:
      obj - An object to conform.
      key - type of object to conform.
    • checkIsoConformance

      public void checkIsoConformance (Object obj, IsoKey key, PdfResources resources, PdfStream contentStream)
      Description copied from class: PdfDocument
      Checks whether PDF document conforms a specific standard. Shall be override.
      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
    • getConformanceLevel

      public PdfAConformanceLevel getConformanceLevel()
      Gets the PdfAConformanceLevel set in the constructor or in the metadata of the PdfReader.
      Returns:
      a PdfAConformanceLevel
    • 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 override.
      Overrides:
      updateXmpMetadata in class PdfDocument
    • checkIsoConformance

      protected void checkIsoConformance()
      Description copied from class: PdfDocument
      Checks whether PDF document conforms a specific standard. Shall be override.
      Overrides:
      checkIsoConformance in class PdfDocument
    • 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.
    • flushFonts

      protected void flushFonts()
      Description copied from class: PdfDocument
      Flushes all newly added or loaded fonts.
      Overrides:
      flushFonts in class PdfDocument
    • 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
    • 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