Package com.itextpdf.pdfa
Class PdfADocument
java.lang.Object
com.itextpdf.kernel.pdf.PdfDocument
com.itextpdf.pdfa.PdfADocument
- All Implemented Interfaces:
-
IEventDispatcher,Closeable,AutoCloseable
- Direct Known Subclasses:
-
PdfAAgnosticPdfDocument
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 Summary
FieldsFields inherited from class com.itextpdf.kernel.pdf.PdfDocument
catalog, closed, closeReader, closeWriter, eventDispatcher, fingerPrint, flushUnusedObjects, info, isClosing, pdfVersion, properties, reader, serializeOptions, structParentIndex, structTreeRoot, tagStructureContext, trailer, writer, xmpMetadata -
Constructor Summary
ConstructorsConstructorDescriptionPdfADocument(PdfReader reader, PdfWriter writer) Opens a PDF/A document in the stamping mode.PdfADocument(PdfReader reader, PdfWriter writer, StampingProperties properties) Opens a PDF/A document in stamping mode.PdfADocument(PdfWriter writer, PdfAConformanceLevel conformanceLevel, PdfOutputIntent outputIntent) Constructs a new PdfADocument for writing purposes, i.e.PdfADocument(PdfWriter writer, PdfAConformanceLevel conformanceLevel, PdfOutputIntent outputIntent, DocumentProperties properties) Constructs a new PdfADocument for writing purposes, i.e. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddCustomMetadataExtensions(XMPMeta xmpMeta) Adds custom XMP metadata extension.voidaddOutputIntent(PdfOutputIntent outputIntent) AddsPdfOutputIntentthat shall specify the colour characteristics of output devices on which the document might be rendered.protected voidChecks whether PDF document conforms a specific standard.voidcheckIsoConformance(Object obj, IsoKey key) Checks whether PDF document conforms a specific standard.voidcheckIsoConformance(Object obj, IsoKey key, PdfResources resources, PdfStream contentStream) Checks whether PDF document conforms a specific standard.voidcheckIsoConformance(Object obj, IsoKey key, PdfResources resources, PdfStream contentStream, Object extra) Checks whether PDF document conforms a specific standard.protected voidFlushes all newly added or loaded fonts.protected voidflushInfoDictionary(boolean appendMode) Flush info dictionary if needed.protected voidflushObject(PdfObject pdfObject, boolean canBeInObjStm) Flush an object.Gets the PdfAConformanceLevel set in the constructor or in the metadata of thePdfReader.protected IPdfPageFactoryReturns the factory for creating page instances.protected voidInitializes tagStructureContext to track necessary information of document's tag structure.protected voidsetChecker(PdfAConformanceLevel conformanceLevel) Sets the checker that defines the requirements of the PDF/A standard depending on conformance level.protected voidUpdates XMP metadata.Methods inherited from class com.itextpdf.kernel.pdf.PdfDocument
addAssociatedFile, addEventHandler, addFileAttachment, addFont, addNamedDestination, addNamedDestination, addNewPage, addNewPage, addNewPage, addNewPage, addPage, addPage, checkAndAddPage, checkAndAddPage, checkClosingStatus, checkShowTextIsoConformance, close, copyPagesTo, copyPagesTo, copyPagesTo, copyPagesTo, copyPagesTo, copyPagesTo, copyPagesTo, copyPagesTo, createNextIndirectReference, dispatchEvent, dispatchEvent, findFont, flushCopiedObjects, getAssociatedFiles, getCatalog, getDefaultFont, getDefaultPageSize, getDiContainer, getDocumentFonts, getDocumentId, getDocumentIdWrapper, getDocumentInfo, getEncryptedPayloadDocument, getFingerPrint, getFirstPage, getFont, getLastPage, getModifiedDocumentId, getNextStructParentIndex, getNumberOfPages, getNumberOfPdfObjects, getOriginalDocumentId, getOutlines, getPage, getPage, getPageLabels, getPageNumber, getPageNumber, getPdfObject, getPdfVersion, getReader, getSerializeOptions, getStructTreeRoot, getTagStructureContext, getTrailer, getWriter, getXmpMetadata, getXmpMetadata, hasEventHandler, hasOutlines, initializeOutlines, isAppendMode, isClosed, isCloseReader, isCloseWriter, isFlushUnusedObjects, isTagged, listIndirectReferences, markObjectAsMustBeFlushed, markStreamAsEmbeddedFile, movePage, movePage, open, registerProduct, removeAllHandlers, removeEventHandler, removePage, removePage, setCloseReader, setCloseWriter, setDefaultPageSize, setEncryptedPayload, setFlushUnusedObjects, setSerializeOptions, setTagged, setUserProperties, setXmpMetadata, setXmpMetadata, setXmpMetadata, storeDestinationToReaddress, tryInitTagStructure, updateDefaultXmpMetadata
-
Field Details
-
checker
-
-
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- thePdfWriterobject to write to -
conformanceLevel- the generation and strictness level of the PDF/A that must be followed. -
outputIntent- aPdfOutputIntent
-
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- thePdfWriterobject to write to -
conformanceLevel- the generation and strictness level of the PDF/A that must be followed. -
outputIntent- aPdfOutputIntent -
properties- aDocumentProperties
-
PdfADocument
Opens a PDF/A document in the stamping mode.- Parameters:
-
reader- PDF reader. -
writer- PDF writer.
-
PdfADocument
Opens a PDF/A document in stamping mode.- Parameters:
-
reader- PDF reader. -
writer- PDF writer. -
properties- properties of the stamping process
-
-
Method Details
-
checkIsoConformance
Checks whether PDF document conforms a specific standard. Shall be overridden.- Overrides:
-
checkIsoConformancein classPdfDocument - Parameters:
-
obj- An object to conform. -
key- type of object to conform.
-
checkIsoConformance
public void checkIsoConformance(Object obj, IsoKey key, PdfResources resources, PdfStream contentStream) Checks whether PDF document conforms a specific standard. Shall be overridden.- Overrides:
-
checkIsoConformancein classPdfDocument - Parameters:
-
obj- an object to conform. -
key- type of object to conform. -
resources-PdfResourcesassociated with an object to check. -
contentStream- current content stream
-
checkIsoConformance
public void checkIsoConformance(Object obj, IsoKey key, PdfResources resources, PdfStream contentStream, Object extra) Checks whether PDF document conforms a specific standard. Shall be overridden.- Overrides:
-
checkIsoConformancein classPdfDocument - Parameters:
-
obj- an object to conform. -
key- type of object to conform. -
resources-PdfResourcesassociated with an object to check. -
contentStream- current content stream. -
extra- extra data required for the check.
-
getConformanceLevel
Gets the PdfAConformanceLevel set in the constructor or in the metadata of thePdfReader.- Returns:
-
a
PdfAConformanceLevel
-
addOutputIntent
AddsPdfOutputIntentthat shall specify the colour characteristics of output devices on which the document might be rendered.- Overrides:
-
addOutputIntentin classPdfDocument - Parameters:
-
outputIntent-PdfOutputIntentto add. - See Also:
-
addCustomMetadataExtensions
Description copied from class:PdfDocumentAdds custom XMP metadata extension. Useful for PDF/UA, ZUGFeRD, etc.- Overrides:
-
addCustomMetadataExtensionsin classPdfDocument - Parameters:
-
xmpMeta-XMPMetato add custom metadata to.
-
updateXmpMetadata
protected void updateXmpMetadata()Description copied from class:PdfDocumentUpdates XMP metadata. Shall be overridden.- Overrides:
-
updateXmpMetadatain classPdfDocument
-
checkIsoConformance
protected void checkIsoConformance()Description copied from class:PdfDocumentChecks whether PDF document conforms a specific standard. Shall be overridden.- Overrides:
-
checkIsoConformancein classPdfDocument
-
flushObject
Description copied from class:PdfDocumentFlush an object.- Overrides:
-
flushObjectin classPdfDocument - 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:PdfDocumentFlushes all newly added or loaded fonts.- Overrides:
-
flushFontsin classPdfDocument
-
setChecker
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:
-
initTagStructureContextin classPdfDocument
-
getPageFactory
Description copied from class:PdfDocumentReturns the factory for creating page instances.- Overrides:
-
getPageFactoryin classPdfDocument - Returns:
-
implementation of
IPdfPageFactoryfor current document
-
flushInfoDictionary
protected void flushInfoDictionary(boolean appendMode) Flush info dictionary if needed.- Overrides:
-
flushInfoDictionaryin classPdfDocument - Parameters:
-
appendMode-trueif the document is edited in append mode.
-