Class PdfStamperImp
java.lang.Object
com.gitlab.pdftk_java.com.lowagie.text.DocWriter
com.gitlab.pdftk_java.com.lowagie.text.pdf.PdfWriter
com.gitlab.pdftk_java.com.lowagie.text.pdf.PdfStamperImp
- All Implemented Interfaces:
DocListener
,ElementListener
,EventListener
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.gitlab.pdftk_java.com.lowagie.text.pdf.PdfWriter
PdfWriter.PdfBody, PdfWriter.PdfTrailer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AcroFields
protected boolean
(package private) boolean
protected boolean
protected HashMap
(package private) RandomAccessFileOrArray
protected boolean
protected boolean
protected int
protected IntHashtable
(package private) IntHashtable
protected boolean
protected int[]
protected List
protected PdfAction
(package private) HashMap
Integer(page number) -> PageStampprotected HashSet
(package private) PdfReader
(package private) HashMap
(package private) HashMap
private boolean
Holds value of property rotateContents.protected int
protected boolean
protected int
Fields inherited from class com.gitlab.pdftk_java.com.lowagie.text.pdf.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, compressStreams, crypto, currentPageNumber, currentPdfReaderInstance, defaultColorspace, DID_PRINT, DID_SAVE, 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_MASK, fileID, filterStreams, FitWindow, fontNumber, formXObjects, formXObjectsCounter, fullCompression, GENERATION_MAX, group, HEADER, HideMenubar, HideToolbar, HideWindowUI, imageDictionary, importedPages, INVALID_ENCRYPTION, NO_SPACE_CHAR_RATIO, NonFullScreenPageModeUseNone, NonFullScreenPageModeUseOC, NonFullScreenPageModeUseOutlines, NonFullScreenPageModeUseThumbs, OCGRadioGroup, OCProperties, PAGE_CLOSE, PAGE_OPEN, PageLayoutOneColumn, PageLayoutSinglePage, PageLayoutTwoColumnLeft, PageLayoutTwoColumnRight, PageLayoutTwoPageLeft, PageLayoutTwoPageRight, PageModeFullScreen, PageModeUseAttachments, PageModeUseNone, PageModeUseOC, PageModeUseOutlines, PageModeUseThumbs, pageReferences, patternColorspaceCMYK, patternColorspaceGRAY, patternColorspaceRGB, patternNumber, PDF_VERSION_1_2, PDF_VERSION_1_3, PDF_VERSION_1_4, PDF_VERSION_1_5, PDF_VERSION_1_6, PDF_VERSION_1_7, PDFX1A2001, PDFX32002, PDFXKEY_CMYK, PDFXKEY_COLOR, PDFXKEY_FONT, PDFXKEY_GSTATE, PDFXKEY_IMAGE, PDFXKEY_LAYER, PDFXKEY_RGB, PDFXNONE, prevxref, PrintScalingNone, 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, tagged, userunit, VERSION_1_0, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, VERSION_1_7, ViewerPreferencesMask, WILL_PRINT, WILL_SAVE, xmpMetadata
-
Constructor Summary
ConstructorsConstructorDescriptionPdfStamperImp
(PdfReader reader, OutputStream os, char pdfVersion, boolean append) Creates new PdfStamperImp. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAnnotation
(PdfAnnotation annot) Adds aPdfAnnotation
or aPdfFormField
to the document.void
addAnnotation
(PdfAnnotation annot, int page) (package private) void
addAnnotation
(PdfAnnotation annot, PdfDictionary pageN) void
addComments
(FdfReader fdf) (package private) void
(package private) void
(package private) void
(package private) void
(package private) void
applyRotation
(PdfDictionary pageN, ByteBuffer out) void
close()
Signals that theDocument
was closed and that no otherElements
will be added.void
(package private) void
correctAcroFieldPages
(int page) (package private) void
(package private) void
(package private) void
expandFields
(PdfFormField field, ArrayList allAnnots) (package private) static void
findAllObjects
(PdfReader reader, PdfObject obj, IntHashtable hits) (package private) void
private void
protected int
getNewObjectNumber
(PdfReader reader, int number, int generation) getOverContent
(int pageNum) getPageReference
(int page) Gets a reference to a page existing or not.(package private) PdfStamperImp.PageStamp
getPageStamp
(int pageNum) (package private) RandomAccessFileOrArray
getReaderFile
(PdfReader reader) getUnderContent
(int pageNum) (package private) void
insertPage
(int pageNumber, Rectangle mediabox) (package private) boolean
isAppend()
Getter for property append.(package private) boolean
(package private) boolean
Getter for property rotateContents.protected void
markUsed
(int num) protected void
private void
outlineTravel
(PRIndirectReference outline) (package private) boolean
partialFormFlattening
(String name) void
registerReader
(PdfReader reader, boolean openFile) void
setAdditionalAction
(PdfName actionType, PdfAction action) Additional-actions defining the actions to be taken in response to various trigger events affecting the document as a whole.void
setDuration
(int seconds) Always throws anUnsupportedOperationException
.(package private) void
setDuration
(int seconds, int page) Sets the display duration for the page (for presentations)void
setFormFlattening
(boolean flat) (package private) void
setFreeTextFlattening
(boolean flat) (package private) void
void
setOpenAction
(PdfAction action) When the document opens thisaction
will be invoked.void
setOpenAction
(String name) When the document opens it will jump to the destination with this name.(package private) void
(package private) void
setOutlines
(List outlines) void
setPageAction
(PdfName actionType, PdfAction action) Always throws anUnsupportedOperationException
.(package private) void
setPageAction
(PdfName actionType, PdfAction action, int page) Sets the open and close page additional action.(package private) void
setRotateContents
(boolean rotateContents) Setter for property rotateContents.void
setSigFlags
(int f) Set the signature flags.void
setTransition
(PdfTransition transition) Always throws anUnsupportedOperationException
.(package private) void
setTransition
(PdfTransition transition, int page) Sets the transition for the pagevoid
setViewerPreferences
(int preferences) Sets the viewer preferences.(package private) void
void
unRegisterReader
(PdfReader reader) Methods inherited from class com.gitlab.pdftk_java.com.lowagie.text.pdf.PdfWriter
add, addCalculationOrder, addDirectTemplateSimple, addJavaScript, addJavaScript, addJavaScript, addLocalDestinations, addOCGRadioGroup, addSharedObjectsToBody, addSimple, addSimple, addSimpleExtGState, addSimplePattern, addSimplePatternColorspace, addSimpleProperty, addSimpleShading, addSimpleShadingPattern, addToBody, addToBody, addToBody, addToBody, addToBody, addToBody, checkPDFXConformance, eliminateFontSubset, freeReader, getAcroForm, getCatalog, getColorspaceName, getCurrentDocumentSize, getCurrentPage, getCurrentPageNumber, getDefaultColorspace, getDirectContent, getDirectContentUnder, getEncryption, getExtraCatalog, getFileID, getGroup, getImageReference, getImportedPage, getIndirectReferenceNumber, getInfo, getOCProperties, getOs, getPageEvent, getPageNumber, getPdfDocument, getPdfIndirectReference, getPDFXConformance, getRoot, getRootOutline, getRunDirection, getSpaceCharRatio, getStructureTreeRoot, getUserunit, getVerticalPosition, isFullCompression, isPaused, isStrictImageSequence, isTagged, open, propertyExists, registerLayer, releaseTemplate, reorderPages, resetContent, setBoxSize, setCropBoxSize, setDefaultColorspace, setEncryption, setEncryption, setFileID, setFullCompression, setGroup, setLinearPageMode, setOutputIntents, setOutputIntents, setPageEmpty, setPageEvent, setPageLabels, setPdfVersion, setPDFXConformance, setRunDirection, setSpaceCharRatio, setStrictImageSequence, setTagged, setUserunit, setXmpMetadata
Methods inherited from class com.gitlab.pdftk_java.com.lowagie.text.DocWriter
add, addTabs, clearTextWrap, flush, getISOBytes, hasMarkupAttributes, isCloseStream, newPage, pause, resetFooter, resetHeader, resetPageCount, resume, setCloseStream, setMarginMirroring, setMargins, setPageCount, setPageSize, write, write, writeEnd, writeEnd, writeMarkupAttributes, writeStart
-
Field Details
-
readers2intrefs
HashMap readers2intrefs -
readers2file
HashMap readers2file -
file
-
reader
PdfReader reader -
myXref
IntHashtable myXref -
pagesToContent
HashMap pagesToContentInteger(page number) -> PageStamp -
closed
boolean closed -
rotateContents
private boolean rotateContentsHolds value of property rotateContents. -
acroFields
-
flat
protected boolean flat -
flatFreeText
protected boolean flatFreeText -
namePtr
protected int[] namePtr -
namedAsNames
protected boolean namedAsNames -
newBookmarks
-
partialFlattening
-
useVp
protected boolean useVp -
vp
protected int vp -
fieldTemplates
-
fieldsAdded
protected boolean fieldsAdded -
sigFlags
protected int sigFlags -
append
protected boolean append -
marked
-
initialXrefSize
protected int initialXrefSize -
openAction
-
-
Constructor Details
-
PdfStamperImp
public PdfStamperImp(PdfReader reader, OutputStream os, char pdfVersion, boolean append) throws DocumentException, IOException Creates new PdfStamperImp.- Parameters:
reader
- the read PDFos
- the output destinationpdfVersion
- the new pdf version or '\0' to keep the same version as the original documentappend
-- Throws:
DocumentException
- on errorIOException
-
-
Method Details
-
close
- Throws:
DocumentException
IOException
-
close
public void close()Description copied from class:PdfWriter
Signals that theDocument
was closed and that no otherElements
will be added.The pages-tree is built and written to the outputstream. A Catalog is constructed, as well as an Info-object, the referencetable is composed and everything is written to the outputstream embedded in a Trailer.
- Specified by:
close
in interfaceDocListener
- Overrides:
close
in classPdfWriter
-
applyRotation
-
alterContents
- Throws:
IOException
-
alterResources
-
getNewObjectNumber
- Overrides:
getNewObjectNumber
in classPdfWriter
-
getReaderFile
- Overrides:
getReaderFile
in classPdfWriter
- Throws:
IOException
-
registerReader
- Parameters:
reader
-openFile
-- Throws:
IOException
-
unRegisterReader
- Parameters:
reader
-
-
findAllObjects
-
addComments
- Parameters:
fdf
-- Throws:
IOException
-
getPageStamp
-
getUnderContent
-
getOverContent
-
correctAcroFieldPages
void correctAcroFieldPages(int page) -
insertPage
-
isRotateContents
boolean isRotateContents()Getter for property rotateContents.- Returns:
- Value of property rotateContents.
-
setRotateContents
void setRotateContents(boolean rotateContents) Setter for property rotateContents.- Parameters:
rotateContents
- New value of property rotateContents.
-
isContentWritten
boolean isContentWritten() -
getAcroFields
-
setFormFlattening
public void setFormFlattening(boolean flat) -
setFreeTextFlattening
void setFreeTextFlattening(boolean flat) -
partialFormFlattening
-
flatFields
void flatFields() -
eliminateAcroformObjects
void eliminateAcroformObjects() -
sweepKids
-
flatFreeTextFields
private void flatFreeTextFields() -
getPageReference
Description copied from class:PdfWriter
Gets 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:
getPageReference
in classPdfWriter
- Parameters:
page
- the page number. The first page is 1- Returns:
- the reference to the page
- See Also:
-
addAnnotation
Description copied from class:PdfWriter
Adds aPdfAnnotation
or aPdfFormField
to the document. Only the top parent of aPdfFormField
needs to be added.- Overrides:
addAnnotation
in classPdfWriter
- Parameters:
annot
- thePdfAnnotation
or thePdfFormField
to add- See Also:
-
addDocumentField
-
addFieldResources
void addFieldResources() -
expandFields
-
addAnnotation
-
addAnnotation
- Overrides:
addAnnotation
in classPdfWriter
-
outlineTravel
-
deleteOutlines
void deleteOutlines() -
setJavaScript
- Throws:
IOException
-
setOutlines
- Throws:
IOException
-
setOutlines
-
setViewerPreferences
public void setViewerPreferences(int preferences) Sets the viewer preferences.- Overrides:
setViewerPreferences
in classPdfWriter
- Parameters:
preferences
- the viewer preferences- See Also:
-
setSigFlags
public void setSigFlags(int f) Set the signature flags.- Overrides:
setSigFlags
in classPdfWriter
- Parameters:
f
- the flags. This flags are ORed with current ones
-
setPageAction
Always throws anUnsupportedOperationException
.- Overrides:
setPageAction
in classPdfWriter
- Parameters:
actionType
- ignoreaction
- ignore- Throws:
PdfException
- ignore- See Also:
-
setPageAction
Sets the open and close page additional action.- Parameters:
actionType
- the action type. It can bePdfWriter.PAGE_OPEN
orPdfWriter.PAGE_CLOSE
action
- the action to performpage
- the page where the action will be applied. The first page is 1- Throws:
PdfException
- if the action type is invalid
-
setDuration
public void setDuration(int seconds) Always throws anUnsupportedOperationException
.- Overrides:
setDuration
in classPdfWriter
- Parameters:
seconds
- ignore
-
setTransition
Always throws anUnsupportedOperationException
.- Overrides:
setTransition
in classPdfWriter
- Parameters:
transition
- ignore
-
setDuration
void setDuration(int seconds, int page) Sets the display duration for the page (for presentations)- Parameters:
seconds
- the number of seconds to display the page. A negative value removes the entrypage
- the page where the duration will be applied. The first page is 1
-
setTransition
Sets the transition for the page- Parameters:
transition
- the transition object. Anull
removes the transitionpage
- the page where the transition will be applied. The first page is 1
-
markUsed
-
markUsed
protected void markUsed(int num) -
isAppend
boolean isAppend()Getter for property append.- Returns:
- Value of property append.
-
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_PRINT
andDID_PRINT
.- Overrides:
setAdditionalAction
in classPdfWriter
- Parameters:
actionType
- the action typeaction
- the action to execute in response to the trigger- Throws:
PdfException
- on invalid action type
-
setOpenAction
Description copied from class:PdfWriter
When the document opens thisaction
will be invoked.- Overrides:
setOpenAction
in classPdfWriter
- Parameters:
action
- the action to be invoked- See Also:
-
setOpenAction
Description copied from class:PdfWriter
When the document opens it will jump to the destination with this name.- Overrides:
setOpenAction
in classPdfWriter
- Parameters:
name
- the name of the destination to jump to- See Also:
-