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 void
addCustomMetadataExtensions
(XMPMeta xmpMeta) Adds custom XMP metadata extension.protected void
Checks whether PDF document conforms a specific standard.void
checkIsoConformance
(Object obj, IsoKey key) Checks whether PDF document conforms a specific standard.void
checkIsoConformance
(Object obj, IsoKey key, PdfResources resources, PdfStream contentStream) Checks whether PDF document conforms a specific standard.protected void
Flushes all newly added or loaded fonts.protected void
flushObject
(PdfObject pdfObject, boolean canBeInObjStm) Flush an object.Gets the PdfAConformanceLevel set in the constructor or in the metadata of thePdfReader
.protected IPdfPageFactory
Returns the factory for creating page instances.protected void
Initializes tagStructureContext to track necessary information of document's tag structure.protected void
setChecker
(PdfAConformanceLevel conformanceLevel) Sets the checker that defines the requirements of the PDF/A standard depending on conformance level.protected void
Updates XMP metadata.Methods inherited from class com.itextpdf.kernel.pdf.PdfDocument
addAssociatedFile, addEventHandler, addFileAttachment, addFont, addNamedDestination, addNewPage, addNewPage, addNewPage, addNewPage, addOutputIntent, addPage, addPage, checkAndAddPage, checkAndAddPage, checkClosingStatus, checkShowTextIsoConformance, close, copyPagesTo, copyPagesTo, copyPagesTo, copyPagesTo, copyPagesTo, copyPagesTo, copyPagesTo, copyPagesTo, createNextIndirectReference, dispatchEvent, dispatchEvent, findFont, flushCopiedObjects, getAssociatedFiles, getCatalog, getDefaultFont, getDefaultPageSize, 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, storeLinkAnnotation, 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
- thePdfWriter
object 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
- thePdfWriter
object 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
Description copied from class:PdfDocument
Checks whether PDF document conforms a specific standard. Shall be override.- Overrides:
-
checkIsoConformance
in 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) Description copied from class:PdfDocument
Checks whether PDF document conforms a specific standard. Shall be override.- Overrides:
-
checkIsoConformance
in classPdfDocument
- 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
Gets the PdfAConformanceLevel set in the constructor or in the metadata of thePdfReader
.- Returns:
-
a
PdfAConformanceLevel
-
addCustomMetadataExtensions
Description copied from class:PdfDocument
Adds custom XMP metadata extension. Useful for PDF/UA, ZUGFeRD, etc.- Overrides:
-
addCustomMetadataExtensions
in classPdfDocument
- 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 classPdfDocument
-
checkIsoConformance
protected void checkIsoConformance()Description copied from class:PdfDocument
Checks whether PDF document conforms a specific standard. Shall be override.- Overrides:
-
checkIsoConformance
in classPdfDocument
-
flushObject
Description copied from class:PdfDocument
Flush an object.- Overrides:
-
flushObject
in 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:PdfDocument
Flushes all newly added or loaded fonts.- Overrides:
-
flushFonts
in 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:
-
initTagStructureContext
in classPdfDocument
-
getPageFactory
Description copied from class:PdfDocument
Returns the factory for creating page instances.- Overrides:
-
getPageFactory
in classPdfDocument
- Returns:
-
implementation of
IPdfPageFactory
for current document
-