Class PdfAStamperImp
java.lang.Object
com.itextpdf.text.DocWriter
com.itextpdf.text.pdf.PdfWriter
com.itextpdf.text.pdf.PdfAStamperImp
- All Implemented Interfaces:
DocListener, ElementListener, PdfAnnotations, PdfDocumentActions, PdfEncryptionSettings, PdfPageActions, PdfRunDirection, PdfVersion, PdfViewerPreferences, EventListener
Extension to PdfStamperImp that will attempt to keep a file
in conformance with the PDF/A standard.
-
Nested Class Summary
Nested classes/interfaces inherited from class PdfWriter
PdfWriter.PdfBody, PdfWriter.PdfTrailer -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AcroFieldsprotected booleanprotected booleanprotected Counterprotected booleanprotected HashSet<PdfTemplate> protected RandomAccessFileOrArrayprotected booleanprotected booleanprotected booleanprotected intprotected IntHashtableprotected int[]protected PdfActionprotected intprotected booleanprotected PdfViewerPreferencesImpFields inherited from class PdfWriter
ALLOW_ASSEMBLY, ALLOW_COPY, ALLOW_DEGRADED_PRINTING, ALLOW_FILL_IN, ALLOW_MODIFY_ANNOTATIONS, ALLOW_MODIFY_CONTENTS, ALLOW_PRINTING, ALLOW_SCREENREADERS, AllowAssembly, AllowCopy, AllowDegradedPrinting, AllowFillIn, AllowModifyAnnotations, AllowModifyContents, AllowPrinting, AllowScreenReaders, body, CenterWindow, colorNumber, colorProfile, compressionLevel, crypto, currentPageNumber, currentPdfReaderInstance, defaultColorspace, DID_PRINT, DID_SAVE, directContent, directContentUnder, DirectionL2R, DirectionR2L, DisplayDocTitle, DO_NOT_ENCRYPT_METADATA, DOCUMENT_CLOSE, documentColors, documentExtGState, documentFonts, documentOCG, documentOCGorder, documentPatterns, documentProperties, documentShadingPatterns, documentShadings, documentSpotPatterns, EMBEDDED_FILES_ONLY, ENCRYPTION_AES_128, ENCRYPTION_AES_256, extraCatalog, FitWindow, fontNumber, formXObjects, formXObjectsCounter, fullCompression, GENERATION_MAX, group, HideMenubar, HideToolbar, HideWindowUI, imageDictionary, JBIG2Globals, markAll, markInlineElementsOnly, newBookmarks, NO_SPACE_CHAR_RATIO, NonFullScreenPageModeUseNone, NonFullScreenPageModeUseOC, NonFullScreenPageModeUseOutlines, NonFullScreenPageModeUseThumbs, OCGLocked, OCGRadioGroup, OCProperties, originalFileID, PAGE_CLOSE, PAGE_OPEN, pageDictEntries, PageLayoutOneColumn, PageLayoutSinglePage, PageLayoutTwoColumnLeft, PageLayoutTwoColumnRight, PageLayoutTwoPageLeft, PageLayoutTwoPageRight, PageModeFullScreen, PageModeUseAttachments, PageModeUseNone, PageModeUseOC, PageModeUseOutlines, PageModeUseThumbs, pageReferences, patternColorspaceCMYK, patternColorspaceGRAY, patternColorspaceRGB, patternNumber, pdf, pdf_version, PDF_VERSION_1_2, PDF_VERSION_1_3, PDF_VERSION_1_4, PDF_VERSION_1_5, PDF_VERSION_1_6, PDF_VERSION_1_7, pdfIsoConformance, PDFX1A2001, PDFX32002, PDFXNONE, prevxref, PrintScalingNone, readerInstances, root, RUN_DIRECTION_DEFAULT, RUN_DIRECTION_LTR, RUN_DIRECTION_NO_BIDI, RUN_DIRECTION_RTL, runDirection, SIGNATURE_APPEND_ONLY, SIGNATURE_EXISTS, SPACE_CHAR_RATIO_DEFAULT, STANDARD_ENCRYPTION_128, STANDARD_ENCRYPTION_40, STRENGTH128BITS, STRENGTH40BITS, structureTreeRoot, tabs, tagged, taggingMode, ttfUnicodeWriter, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, VERSION_1_7, WILL_PRINT, WILL_SAVE, xmpMetadata, xmpWriter -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAnnotation(PdfAnnotation annot) Use this methods to add aPdfAnnotationor aPdfFormFieldto the document.voidaddComments(FdfReader fdf) protected voidprotected voidvoidaddViewerPreference(PdfName key, PdfObject value) Adds a viewer preferenceprotected voidprotected voidcacheObject(PdfIndirectObject iobj) Use this method for caching objects.protected voidclose(PdfIndirectReference info, int skipInfo) protected voidcreateAnnotation(float llx, float lly, float urx, float ury, PdfAction action, PdfName subtype) A wrapper around PdfAnnotation constructor.createAnnotation(float llx, float lly, float urx, float ury, PdfString title, PdfString content, PdfName subtype) A wrapper around PdfAnnotation constructor.createAnnotation(Rectangle rect, PdfName subtype) A wrapper around PdfAnnotation constructor.voidUse this method to creates XMP Metadata based on the metadata in the PdfDocument.protected XmpWritercreateXmpWriter(ByteArrayOutputStream baos, PdfDictionary info) protected XmpWritercreateXmpWriter(ByteArrayOutputStream baos, HashMap<String, String> info) protected voidprotected voidprotected voidIf setFlatAnnotations is set to true, iText will flatten all annotations with an appearance streamprotected CounterUse this method to get the direct content for this document.Use this method to get the direct content under for this document.protected intgetNewObjectNumber(PdfReader reader, int number, int generation) getPageReference(int page) Use this method to get a reference to a page existing or not.Gets the PdfLayer objects in an existing document as a Map with the names/titles of the layers as keys.protected TtfUnicodeWriterprotected PdfIsoConformanceprotected voidmarkUsed(int num) protected voidprotected voidprotected voidReads the OCProperties dictionary from the catalog of the existing document and fills the documentOCG, documentOCGorder and OCGRadioGroup variables in PdfWriter.voidregisterReader(PdfReader reader, boolean openFile) voidsetAdditionalAction(PdfName actionType, PdfAction action) Additional-actions defining the actions to be taken in response to various trigger events affecting the document as a whole.voidsetDuration(int seconds) Always throws anUnsupportedOperationException.voidsetFlatAnnotations(boolean flatAnnotations) If true, annotations with an appearance stream will be flattened.protected voidvoidsetOpenAction(PdfAction action) When the document opens thisactionwill be invoked.voidsetOpenAction(String name) When the document opens it will jump to the destination with this name.protected voidvoidsetOutputIntents(String outputConditionIdentifier, String outputCondition, String registryName, String info, ICC_Profile colorProfile) Sets the values of the output intent dictionary.voidsetPageAction(PdfName actionType, PdfAction action) Always throws anUnsupportedOperationException.voidsetPDFXConformance(int pdfx) Always throws an exception since PDF/X conformance level cannot be set for PDF/A conformant documents.voidsetSigFlags(int f) Set the signature flags.voidsetThumbnail(Image image) Use this method to set the thumbnail image for the current page.voidsetTransition(PdfTransition transition) Always throws anUnsupportedOperationException.protected voidvoidsetViewerPreferences(int preferences) Sets the viewer preferences.voidunRegisterReader(PdfReader reader) protected voidMethods inherited from class PdfWriter
add, addCalculationOrder, addDeveloperExtension, addDirectImageSimple, addDirectImageSimple, addFileAttachment, addFileAttachment, addFileAttachment, addJavaScript, addJavaScript, addJavaScript, addJavaScript, addJavaScript, addJavaScript, addNamedDestination, addNamedDestinations, addOCGRadioGroup, addPageDictEntry, addSharedObjectsToBody, addToBody, addToBody, addToBody, addToBody, addToBody, addToBody, addXFormsToBody, buildStructTreeRootForTagged, checkElementRole, checkPdfIsoConformance, checkPdfIsoConformance, clearTextWrap, close, fillOCProperties, flushAcroFields, flushTaggedObjects, freeReader, getAcroForm, getBoxSize, getBoxSize, getCatalog, getColorProfile, getCompressionLevel, getCurrentDocumentSize, getCurrentPageNumber, getDefaultColorspace, getExtraCatalog, getGroup, getImportedPage, getIndirectReferenceNumber, getInfo, getInstance, getInstance, getNameString, getOCProperties, getOs, getPageDictEntries, getPageEvent, getPageNumber, getPageSize, getPdfIndirectReference, getPdfReaderInstance, getPDFXConformance, getReferenceJBIG2Globals, getRootOutline, getRunDirection, getSpaceCharRatio, getStandardStructElems, getStructureTreeRoot, getTabs, getVerticalPosition, getXmpWriter, isFullCompression, isPageEmpty, isPdfIso, isPdfX, isRgbTransparencyBlending, isStrictImageSequence, isTagged, isUserProperties, lockLayer, needToBeMarkedInContent, open, releaseTemplate, reorderPages, resetPageDictEntries, setAtLeastPdfVersion, setBoxSize, setCollection, setCompressionLevel, setCropBoxSize, setDefaultColorspace, setEncryption, setEncryption, setEncryption, setEncryption, setEncryption, setFullCompression, setGroup, setInitialLeading, setLanguage, setLinearPageMode, setOutlines, setOutputIntents, setOutputIntents, setPageEmpty, setPageEvent, setPageLabels, setPageViewport, setPageXmpMetadata, setPdfVersion, setPdfVersion, setRgbTransparencyBlending, setRunDirection, setSpaceCharRatio, setStrictImageSequence, setTabs, setTagged, setTagged, setUserProperties, setUserunit, setXmpMetadata, useExternalCacheForTagStructure, writeKeyInfo, writeOutlinesMethods inherited from class DocWriter
add, addTabs, flush, getISOBytes, isCloseStream, isPaused, newPage, pause, resetPageCount, resume, setCloseStream, setMarginMirroring, setMarginMirroringTopBottom, setMargins, setPageCount, setPageSize, write, write, writeEnd, writeEnd, writeMarkupAttributes, writeStart
-
Field Details
-
COUNTER
-
file
-
closed
protected boolean closed -
acroFields
-
flat
protected boolean flat -
flatFreeText
protected boolean flatFreeText -
flatannotations
protected boolean flatannotations -
namePtr
protected int[] namePtr -
partialFlattening
-
useVp
protected boolean useVp -
viewerPreferences
-
fieldTemplates
-
fieldsAdded
protected boolean fieldsAdded -
sigFlags
protected int sigFlags -
append
protected boolean append -
marked
-
initialXrefSize
protected int initialXrefSize -
openAction
-
namedDestinations
-
-
Method Details
-
readColorProfile
protected void readColorProfile() -
setOutputIntents
public void setOutputIntents(String outputConditionIdentifier, String outputCondition, String registryName, String info, ICC_Profile colorProfile) throws IOException Description copied from class:PdfWriterSets the values of the output intent dictionary. Null values are allowed to suppress any key.- Overrides:
setOutputIntentsin classPdfWriter- Parameters:
outputConditionIdentifier- a valueoutputCondition- a valueregistryName- a valueinfo- a valuecolorProfile- a value- Throws:
IOException- on error- See Also:
-
setPDFXConformance
public void setPDFXConformance(int pdfx) Always throws an exception since PDF/X conformance level cannot be set for PDF/A conformant documents.- Overrides:
setPDFXConformancein classPdfWriter- Parameters:
pdfx-- See Also:
-
getTtfUnicodeWriter
- Overrides:
getTtfUnicodeWriterin classPdfWriter- See Also:
-
createXmpWriter
protected XmpWriter createXmpWriter(ByteArrayOutputStream baos, PdfDictionary info) throws IOException - Overrides:
createXmpWriterin classPdfWriter- Throws:
IOException- See Also:
-
createXmpWriter
protected XmpWriter createXmpWriter(ByteArrayOutputStream baos, HashMap<String, String> info) throws IOException- Overrides:
createXmpWriterin classPdfWriter- Throws:
IOException
-
initPdfIsoConformance
- Overrides:
initPdfIsoConformancein classPdfWriter- See Also:
-
getCounter
-
cacheObject
Description copied from class:PdfWriterUse this method for caching objects.- Overrides:
cacheObjectin classPdfWriter- Parameters:
iobj- @see PdfIndirectObject
-
close
- Throws:
IOException
-
createAnnotation
Description copied from class:PdfWriterA wrapper around PdfAnnotation constructor. It is recommended to use this wrapper instead of direct constructor as this is a convenient way to override PdfAnnotation construction when needed.- Overrides:
createAnnotationin classPdfWriter- Parameters:
rect-subtype-- Returns:
-
createAnnotation
public PdfAnnotation createAnnotation(float llx, float lly, float urx, float ury, PdfString title, PdfString content, PdfName subtype) Description copied from class:PdfWriterA wrapper around PdfAnnotation constructor. It is recommended to use this wrapper instead of direct constructor as this is a convenient way to override PdfAnnotation construction when needed.- Overrides:
createAnnotationin classPdfWriter- Parameters:
llx-lly-urx-ury-title-content-subtype-- Returns:
-
createAnnotation
public PdfAnnotation createAnnotation(float llx, float lly, float urx, float ury, PdfAction action, PdfName subtype) Description copied from class:PdfWriterA wrapper around PdfAnnotation constructor. It is recommended to use this wrapper instead of direct constructor as this is a convenient way to override PdfAnnotation construction when needed.- Overrides:
createAnnotationin classPdfWriter- Parameters:
llx-lly-urx-ury-action-subtype-- Returns:
-
getXmpMeta
-
setViewerPreferences
protected void setViewerPreferences() -
close
- Throws:
IOException
-
alterContents
- Throws:
IOException
-
getNewObjectNumber
- Overrides:
getNewObjectNumberin classPdfWriter
-
registerReader
- Parameters:
reader-openFile-- Throws:
IOException
-
unRegisterReader
- Parameters:
reader-
-
addComments
- Parameters:
fdf-- Throws:
IOException
-
flatFields
protected void flatFields() -
setFlatAnnotations
public void setFlatAnnotations(boolean flatAnnotations) If true, annotations with an appearance stream will be flattened.- Parameters:
flatAnnotations- boolean- Since:
- 5.5.3
-
flattenAnnotations
protected void flattenAnnotations()If setFlatAnnotations is set to true, iText will flatten all annotations with an appearance stream- Since:
- 5.5.3
-
flatFreeTextFields
protected void flatFreeTextFields() -
getPageReference
Description copied from class:PdfWriterUse this method to get a reference to a page existing or not. If the page does not exist yet the reference will be created in advance. If on closing the document, a page number greater than the total number of pages was requested, an exception is thrown.- Overrides:
getPageReferencein classPdfWriter- Parameters:
page- the page number. The first page is 1- Returns:
- the reference to the page
- See Also:
-
addAnnotation
Description copied from interface:PdfAnnotationsUse this methods to add aPdfAnnotationor aPdfFormFieldto the document. Only the top parent of aPdfFormFieldneeds to be added.- Specified by:
addAnnotationin interfacePdfAnnotations- Overrides:
addAnnotationin classPdfWriter- Parameters:
annot- thePdfAnnotationor thePdfFormFieldto add- See Also:
-
addFieldResources
- Throws:
IOException
-
setJavaScript
- Throws:
IOException
-
addFileAttachments
- Throws:
IOException
-
setOutlines
- Throws:
IOException
-
setViewerPreferences
public void setViewerPreferences(int preferences) Sets the viewer preferences.- Specified by:
setViewerPreferencesin interfacePdfViewerPreferences- Overrides:
setViewerPreferencesin classPdfWriter- Parameters:
preferences- the viewer preferences- See Also:
-
addViewerPreference
Adds a viewer preference- Specified by:
addViewerPreferencein interfacePdfViewerPreferences- Overrides:
addViewerPreferencein classPdfWriter- Parameters:
key- a key for a viewer preferencevalue- the value for the viewer preference- See Also:
-
setSigFlags
public void setSigFlags(int f) Set the signature flags.- Specified by:
setSigFlagsin interfacePdfAnnotations- Overrides:
setSigFlagsin classPdfWriter- Parameters:
f- the flags. This flags are ORed with current ones- See Also:
-
setPageAction
Always throws anUnsupportedOperationException.- Specified by:
setPageActionin interfacePdfPageActions- Overrides:
setPageActionin classPdfWriter- Parameters:
actionType- ignoreaction- ignore- Throws:
PdfException- ignore- See Also:
-
setDuration
public void setDuration(int seconds) Always throws anUnsupportedOperationException.- Specified by:
setDurationin interfacePdfPageActions- Overrides:
setDurationin classPdfWriter- Parameters:
seconds- ignore- See Also:
-
setTransition
Always throws anUnsupportedOperationException.- Specified by:
setTransitionin interfacePdfPageActions- Overrides:
setTransitionin classPdfWriter- Parameters:
transition- ignore- See Also:
-
markUsed
-
markUsed
protected void markUsed(int num) -
getPdfReader
-
setAdditionalAction
Additional-actions defining the actions to be taken in response to various trigger events affecting the document as a whole. The actions types allowed are:DOCUMENT_CLOSE,WILL_SAVE,DID_SAVE,WILL_PRINTandDID_PRINT.- Specified by:
setAdditionalActionin interfacePdfDocumentActions- Overrides:
setAdditionalActionin classPdfWriter- Parameters:
actionType- the action typeaction- the action to execute in response to the trigger- Throws:
PdfException- on invalid action type- See Also:
-
setOpenAction
Description copied from interface:PdfDocumentActionsWhen the document opens thisactionwill be invoked.- Specified by:
setOpenActionin interfacePdfDocumentActions- Overrides:
setOpenActionin classPdfWriter- Parameters:
action- the action to be invoked- See Also:
-
setOpenAction
Description copied from interface:PdfDocumentActionsWhen the document opens it will jump to the destination with this name.- Specified by:
setOpenActionin interfacePdfDocumentActions- Overrides:
setOpenActionin classPdfWriter- Parameters:
name- the name of the destination to jump to- See Also:
-
setThumbnail
Description copied from class:PdfWriterUse this method to set the thumbnail image for the current page.- Overrides:
setThumbnailin classPdfWriter- Parameters:
image- the image- See Also:
-
getDirectContentUnder
Description copied from class:PdfWriterUse this method to get the direct content under for this document. There is only one direct content, multiple calls to this method will always retrieve the same object.- Overrides:
getDirectContentUnderin classPdfWriter- Returns:
- the direct content
-
getDirectContent
Description copied from class:PdfWriterUse this method to get the direct content for this document. There is only one direct content, multiple calls to this method will allways retrieve the same object.- Overrides:
getDirectContentin classPdfWriter- Returns:
- the direct content
-
readOCProperties
protected void readOCProperties()Reads the OCProperties dictionary from the catalog of the existing document and fills the documentOCG, documentOCGorder and OCGRadioGroup variables in PdfWriter. Note that the original OCProperties of the existing document can contain more information.- Since:
- 2.1.2
-
getPdfLayers
-
createXmpMetadata
public void createXmpMetadata()Description copied from class:PdfWriterUse this method to creates XMP Metadata based on the metadata in the PdfDocument.- Overrides:
createXmpMetadatain classPdfWriter
-
getNamedDestinations
-
updateNamedDestinations
- Throws:
IOException
-