com.lowagie.text.pdf

Class PdfStamperImp

class PdfStamperImp extends PdfWriter

Nested Class Summary
static classPdfStamperImp.PageStamp
Field Summary
protected AcroFieldsacroFields
protected booleanappend
booleanclosed
protected booleanfieldsAdded
protected HashMapfieldTemplates
RandomAccessFileOrArrayfile
protected booleanflat
protected booleanflatFreeText
protected intinitialXrefSize
protected IntHashtablemarked
IntHashtablemyXref
protected int[]namePtr
protected PdfActionopenAction
HashMappagesToContent
Integer(page number) -> PageStamp
protected HashSetpartialFlattening
PdfReaderreader
HashMapreaders2file
HashMapreaders2intrefs
booleanrotateContents
Holds value of property rotateContents.
protected intsigFlags
protected booleanuseVp
protected PdfViewerPreferencesImpviewerPreferences
Constructor Summary
PdfStamperImp(PdfReader reader, OutputStream os, char pdfVersion, boolean append)
Creates new PdfStamperImp.
Method Summary
voidaddAnnotation(PdfAnnotation annot)
voidaddAnnotation(PdfAnnotation annot, PdfDictionary pageN)
voidaddAnnotation(PdfAnnotation annot, int page)
voidaddComments(FdfReader fdf)
voidaddDocumentField(PdfIndirectReference ref)
voidaddFieldResources()
voidaddFileAttachments()
voidaddOrder(PdfLayer parent, PdfArray arr, Map ocgmap)
Recursive method to reconstruct the documentOCGorder variable in the writer.
voidaddViewerPreference(PdfName key, PdfObject value)
Adds a viewer preference
voidalterContents()
voidalterResources(PdfStamperImp.PageStamp ps)
voidapplyRotation(PdfDictionary pageN, ByteBuffer out)
voidclose(HashMap moreInfo)
voidcorrectAcroFieldPages(int page)
voiddeleteOutlines()
voideliminateAcroformObjects()
voidexpandFields(PdfFormField field, ArrayList allAnnots)
static voidfindAllObjects(PdfReader reader, PdfObject obj, IntHashtable hits)
voidflatFields()
voidflatFreeTextFields()
AcroFieldsgetAcroFields()
PdfContentBytegetDirectContent()
PdfContentBytegetDirectContentUnder()
protected intgetNewObjectNumber(PdfReader reader, int number, int generation)
PdfContentBytegetOverContent(int pageNum)
PdfIndirectReferencegetPageReference(int page)
PdfStamperImp.PageStampgetPageStamp(int pageNum)
MapgetPdfLayers()
Gets the PdfLayer objects in an existing document as a Map with the names/titles of the layers as keys.
RandomAccessFileOrArraygetReaderFile(PdfReader reader)
PdfContentBytegetUnderContent(int pageNum)
voidinsertPage(int pageNumber, Rectangle mediabox)
booleanisAppend()
Getter for property append.
booleanisContentWritten()
booleanisRotateContents()
Getter for property rotateContents.
voidmakePackage(PdfCollection collection)
Adds or replaces the Collection Dictionary in the Catalog.
protected voidmarkUsed(PdfObject obj)
protected voidmarkUsed(int num)
static voidmoveRectangle(PdfDictionary dic2, PdfReader r, int pageImported, PdfName key, String name)
voidoutlineTravel(PRIndirectReference outline)
booleanpartialFormFlattening(String name)
protected voidreadOCProperties()
Reads 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)
voidreplacePage(PdfReader r, int pageImported, int pageReplaced)
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 an UnsupportedOperationException.
voidsetDuration(int seconds, int page)
Sets the display duration for the page (for presentations)
voidsetFormFlattening(boolean flat)
voidsetFreeTextFlattening(boolean flat)
voidsetJavaScript()
voidsetOpenAction(PdfAction action)
voidsetOpenAction(String name)
voidsetOutlines()
voidsetPageAction(PdfName actionType, PdfAction action)
Always throws an UnsupportedOperationException.
voidsetPageAction(PdfName actionType, PdfAction action, int page)
Sets the open and close page additional action.
voidsetRotateContents(boolean rotateContents)
Setter for property rotateContents.
voidsetSigFlags(int f)
Set the signature flags.
voidsetThumbnail(Image image)
voidsetThumbnail(Image image, int page)
voidsetTransition(PdfTransition transition)
Always throws an UnsupportedOperationException.
voidsetTransition(PdfTransition transition, int page)
Sets the transition for the page
voidsetViewerPreferences(int preferences)
Sets the viewer preferences.
voidsweepKids(PdfObject obj)
voidunRegisterReader(PdfReader reader)

Field Detail

acroFields

protected AcroFields acroFields

append

protected boolean append

closed

boolean closed

fieldsAdded

protected boolean fieldsAdded

fieldTemplates

protected HashMap fieldTemplates

file

RandomAccessFileOrArray file

flat

protected boolean flat

flatFreeText

protected boolean flatFreeText

initialXrefSize

protected int initialXrefSize

marked

protected IntHashtable marked

myXref

IntHashtable myXref

namePtr

protected int[] namePtr

openAction

protected PdfAction openAction

pagesToContent

HashMap pagesToContent
Integer(page number) -> PageStamp

partialFlattening

protected HashSet partialFlattening

reader

PdfReader reader

readers2file

HashMap readers2file

readers2intrefs

HashMap readers2intrefs

rotateContents

private boolean rotateContents
Holds value of property rotateContents.

sigFlags

protected int sigFlags

useVp

protected boolean useVp

viewerPreferences

protected PdfViewerPreferencesImp viewerPreferences

Constructor Detail

PdfStamperImp

PdfStamperImp(PdfReader reader, OutputStream os, char pdfVersion, boolean append)
Creates new PdfStamperImp.

Parameters: reader the read PDF os the output destination pdfVersion the new pdf version or '\0' to keep the same version as the original document append

Throws: DocumentException on error IOException

Method Detail

addAnnotation

public void addAnnotation(PdfAnnotation annot)

See Also: addAnnotation

addAnnotation

void addAnnotation(PdfAnnotation annot, PdfDictionary pageN)

addAnnotation

void addAnnotation(PdfAnnotation annot, int page)

addComments

public void addComments(FdfReader fdf)

Parameters: fdf

Throws: IOException

addDocumentField

void addDocumentField(PdfIndirectReference ref)

addFieldResources

void addFieldResources()

addFileAttachments

void addFileAttachments()

addOrder

private void addOrder(PdfLayer parent, PdfArray arr, Map ocgmap)
Recursive method to reconstruct the documentOCGorder variable in the writer.

Parameters: parent a parent PdfLayer (can be null) arr an array possibly containing children for the parent PdfLayer ocgmap a HashMap with indirect reference Strings as keys and PdfLayer objects as values.

Since: 2.1.2

addViewerPreference

public void addViewerPreference(PdfName key, PdfObject value)
Adds a viewer preference

Parameters: key a key for a viewer preference value the value for the viewer preference

See Also: PdfViewerPreferences

alterContents

void alterContents()

alterResources

void alterResources(PdfStamperImp.PageStamp ps)

applyRotation

void applyRotation(PdfDictionary pageN, ByteBuffer out)

close

void close(HashMap moreInfo)

correctAcroFieldPages

void correctAcroFieldPages(int page)

deleteOutlines

void deleteOutlines()

eliminateAcroformObjects

void eliminateAcroformObjects()

expandFields

void expandFields(PdfFormField field, ArrayList allAnnots)

findAllObjects

static void findAllObjects(PdfReader reader, PdfObject obj, IntHashtable hits)

flatFields

void flatFields()

flatFreeTextFields

private void flatFreeTextFields()

getAcroFields

AcroFields getAcroFields()

getDirectContent

public PdfContentByte getDirectContent()

getDirectContentUnder

public PdfContentByte getDirectContentUnder()

getNewObjectNumber

protected int getNewObjectNumber(PdfReader reader, int number, int generation)

getOverContent

PdfContentByte getOverContent(int pageNum)

getPageReference

public PdfIndirectReference getPageReference(int page)

See Also: PdfWriter

getPageStamp

PdfStamperImp.PageStamp getPageStamp(int pageNum)

getPdfLayers

public Map getPdfLayers()
Gets the PdfLayer objects in an existing document as a Map with the names/titles of the layers as keys.

Returns: a Map with all the PdfLayers in the document (and the name/title of the layer as key)

Since: 2.1.2

getReaderFile

RandomAccessFileOrArray getReaderFile(PdfReader reader)

getUnderContent

PdfContentByte getUnderContent(int pageNum)

insertPage

void insertPage(int pageNumber, Rectangle mediabox)

isAppend

boolean isAppend()
Getter for property append.

Returns: Value of property append.

isContentWritten

boolean isContentWritten()

isRotateContents

boolean isRotateContents()
Getter for property rotateContents.

Returns: Value of property rotateContents.

makePackage

void makePackage(PdfCollection collection)
Adds or replaces the Collection Dictionary in the Catalog.

Parameters: collection the new collection dictionary.

markUsed

protected void markUsed(PdfObject obj)

markUsed

protected void markUsed(int num)

moveRectangle

private static void moveRectangle(PdfDictionary dic2, PdfReader r, int pageImported, PdfName key, String name)

outlineTravel

private void outlineTravel(PRIndirectReference outline)

partialFormFlattening

boolean partialFormFlattening(String name)

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

registerReader

public void registerReader(PdfReader reader, boolean openFile)

Parameters: reader openFile

Throws: IOException

replacePage

void replacePage(PdfReader r, int pageImported, int pageReplaced)

setAdditionalAction

public 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. The actions types allowed are: DOCUMENT_CLOSE, WILL_SAVE, DID_SAVE, WILL_PRINT and DID_PRINT.

Parameters: actionType the action type action the action to execute in response to the trigger

Throws: PdfException on invalid action type

setDuration

public void setDuration(int seconds)
Always throws an UnsupportedOperationException.

Parameters: seconds 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 entry page the page where the duration will be applied. The first page is 1

setFormFlattening

void setFormFlattening(boolean flat)

setFreeTextFlattening

void setFreeTextFlattening(boolean flat)

setJavaScript

void setJavaScript()

setOpenAction

public void setOpenAction(PdfAction action)

See Also: setOpenAction

setOpenAction

public void setOpenAction(String name)

See Also: PdfWriter

setOutlines

void setOutlines()

setPageAction

public void setPageAction(PdfName actionType, PdfAction action)
Always throws an UnsupportedOperationException.

Parameters: actionType ignore action ignore

Throws: PdfException ignore

See Also: PdfStamper

setPageAction

void setPageAction(PdfName actionType, PdfAction action, int page)
Sets the open and close page additional action.

Parameters: actionType the action type. It can be PdfWriter.PAGE_OPEN or PdfWriter.PAGE_CLOSE action the action to perform page the page where the action will be applied. The first page is 1

Throws: PdfException if the action type is invalid

setRotateContents

void setRotateContents(boolean rotateContents)
Setter for property rotateContents.

Parameters: rotateContents New value of property rotateContents.

setSigFlags

public void setSigFlags(int f)
Set the signature flags.

Parameters: f the flags. This flags are ORed with current ones

setThumbnail

public void setThumbnail(Image image)

See Also: setThumbnail

setThumbnail

void setThumbnail(Image image, int page)

setTransition

public void setTransition(PdfTransition transition)
Always throws an UnsupportedOperationException.

Parameters: transition ignore

setTransition

void setTransition(PdfTransition transition, int page)
Sets the transition for the page

Parameters: transition the transition object. A null removes the transition page the page where the transition will be applied. The first page is 1

setViewerPreferences

public void setViewerPreferences(int preferences)
Sets the viewer preferences.

Parameters: preferences the viewer preferences

See Also: PdfWriter

sweepKids

void sweepKids(PdfObject obj)

unRegisterReader

public void unRegisterReader(PdfReader reader)

Parameters: reader