Class PdfADocument

  • All Implemented Interfaces:
    IEventDispatcher, java.io.Closeable, java.lang.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 Detail

      • alreadyLoggedThatObjectFlushingWasNotPerformed

        private boolean alreadyLoggedThatObjectFlushingWasNotPerformed
      • alreadyLoggedThatPageFlushingWasNotPerformed

        private boolean alreadyLoggedThatPageFlushingWasNotPerformed
      • isPdfADocument

        private boolean isPdfADocument
    • Constructor Detail

      • 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 Detail

      • 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​(java.lang.Object obj,
                                        IsoKey key,
                                        PdfResources resources,
                                        PdfStream contentStream,
                                        java.lang.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 java.io.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:
        java.io.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()
      • initTagStructureContext

        protected void initTagStructureContext()
        Initializes tagStructureContext to track necessary information of document's tag structure.
        Overrides:
        initTagStructureContext in class PdfDocument
      • 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()