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
Fields 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
ConstructorDescriptionPdfADocument
(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.void
addOutputIntent
(PdfOutputIntent outputIntent) AddsPdfOutputIntent
that shall specify the colour characteristics of output devices on which the document might be rendered.protected void
Checks whether PDF document conforms to a specific standard.void
checkIsoConformance
(Object obj, IsoKey key, PdfResources resources, PdfStream contentStream, Object extra) Checks whether PDF document conforms a specific standard.protected void
flushInfoDictionary
(boolean appendMode) Flush info dictionary if needed.protected void
flushObject
(PdfObject pdfObject, boolean canBeInObjStm) Flush an object.Get theIConformanceLevel
No default font for PDF/A documents.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
setChecker
(PdfAChecker checker) protected void
Updates 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, checkIsoConformance, checkIsoConformance, checkShowTextIsoConformance, close, copyPagesTo, copyPagesTo, copyPagesTo, copyPagesTo, copyPagesTo, copyPagesTo, copyPagesTo, copyPagesTo, createNextIndirectReference, dispatchEvent, dispatchEvent, findFont, flushCopiedObjects, flushFonts, getAssociatedFiles, getCatalog, getDefaultPageSize, getDiContainer, getDocumentFonts, getDocumentId, getDocumentIdWrapper, getDocumentInfo, getEncryptedPayloadDocument, getFingerPrint, getFirstPage, getFont, getLastPage, getMemoryLimitsAwareHandler, 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
- 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
-
getDefaultFont
No default font for PDF/A documents.- Overrides:
-
getDefaultFont
in classPdfDocument
- Returns:
-
null
.
-
getConformanceLevel
Get theIConformanceLevel
- Overrides:
-
getConformanceLevel
in classPdfDocument
- Returns:
-
the
IConformanceLevel
will be null if the document does not have a conformance level specified
-
addOutputIntent
AddsPdfOutputIntent
that shall specify the colour characteristics of output devices on which the document might be rendered.- Overrides:
-
addOutputIntent
in classPdfDocument
- Parameters:
-
outputIntent
-PdfOutputIntent
to add. - See Also:
-
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 overridden.- Overrides:
-
updateXmpMetadata
in classPdfDocument
-
checkIsoConformance
protected void checkIsoConformance()Description copied from class:PdfDocument
Checks whether PDF document conforms to a specific standard.- Overrides:
-
checkIsoConformance
in classPdfDocument
-
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 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. -
extra
- extra data required for the check.
-
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.
-
setChecker
Sets the checker that defines the requirements of the PDF/A standard depending on conformance level.- Parameters:
-
conformanceLevel
-PdfAConformanceLevel
-
setChecker
-
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
-
flushInfoDictionary
protected void flushInfoDictionary(boolean appendMode) Flush info dictionary if needed.- Overrides:
-
flushInfoDictionary
in classPdfDocument
- Parameters:
-
appendMode
-true
if the document is edited in append mode.
-