com.lowagie.text.pdf
Class PdfStamperImp

java.lang.Object
  extended bycom.lowagie.text.DocWriter
      extended bycom.lowagie.text.pdf.PdfWriter
          extended bycom.lowagie.text.pdf.PdfStamperImp
All Implemented Interfaces:
DocListener, ElementListener, EventListener

class PdfStamperImp
extends PdfWriter


Nested Class Summary
(package private) static class PdfStamperImp.PageStamp
           
 
Nested classes inherited from class com.lowagie.text.pdf.PdfWriter
PdfWriter.PdfBody, PdfWriter.PdfTrailer
 
Field Summary
protected  AcroFields acroFields
           
protected  boolean append
           
(package private)  boolean closed
           
protected  boolean fieldsAdded
           
protected  HashMap fieldTemplates
           
(package private)  RandomAccessFileOrArray file
           
protected  boolean flat
           
protected  int initialXrefSize
           
protected  IntHashtable marked
           
(package private)  IntHashtable myXref
           
protected  boolean namedAsNames
           
protected  int[] namePtr
           
protected  List newBookmarks
           
protected  PdfAction openAction
           
(package private)  HashMap pagesToContent
          Integer(page number) -> PageStamp
protected  HashSet partialFlattening
           
(package private)  PdfReader reader
           
(package private)  HashMap readers2file
           
(package private)  HashMap readers2intrefs
           
private  boolean rotateContents
          Holds value of property rotateContents.
protected  int sigFlags
           
protected  boolean useVp
           
protected  int vp
           
 
Fields inherited from class com.lowagie.text.pdf.PdfWriter
AllowAssembly, AllowCopy, AllowDegradedPrinting, AllowFillIn, AllowModifyAnnotations, AllowModifyContents, AllowPrinting, AllowScreenReaders, body, CenterWindow, colorNumber, crypto, currentPageNumber, currentPdfReaderInstance, defaultColorspace, DID_PRINT, DID_SAVE, directContent, directContentUnder, DirectionL2R, DirectionR2L, DisplayDocTitle, DOCUMENT_CLOSE, documentColors, documentExtGState, documentFonts, documentLayers, documentOCG, documentOCGorder, documentPatterns, documentShadingPatterns, documentShadings, documentSpotPatterns, FitWindow, fontNumber, formXObjects, formXObjectsCounter, fullCompression, group, HEADER, HideMenubar, HideToolbar, HideWindowUI, imageDictionary, importedPages, NO_SPACE_CHAR_RATIO, NonFullScreenPageModeUseNone, NonFullScreenPageModeUseOC, NonFullScreenPageModeUseOutlines, NonFullScreenPageModeUseThumbs, OCGRadioGroup, OCProperties, PAGE_CLOSE, PAGE_OPEN, PageLayoutOneColumn, PageLayoutSinglePage, PageLayoutTwoColumnLeft, PageLayoutTwoColumnRight, PageModeFullScreen, PageModeUseNone, PageModeUseOC, PageModeUseOutlines, PageModeUseThumbs, pageReferences, patternColorspaceCMYK, patternColorspaceGRAY, patternColorspaceRGB, patternNumber, pdf, PDFX1A2001, PDFX32002, PDFXKEY_CMYK, PDFXKEY_COLOR, PDFXKEY_FONT, PDFXKEY_GSTATE, PDFXKEY_IMAGE, PDFXKEY_LAYER, PDFXKEY_RGB, PDFXNONE, prevxref, root, RUN_DIRECTION_DEFAULT, RUN_DIRECTION_LTR, RUN_DIRECTION_NO_BIDI, RUN_DIRECTION_RTL, runDirection, SIGNATURE_APPEND_ONLY, SIGNATURE_EXISTS, SPACE_CHAR_RATIO_DEFAULT, STRENGTH128BITS, STRENGTH40BITS, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, ViewerPreferencesMask, WILL_PRINT, WILL_SAVE
 
Fields inherited from class com.lowagie.text.DocWriter
closeStream, document, EQUALS, FORWARD, GT, LT, NEWLINE, open, os, pageSize, pause, QUOTE, SPACE, TAB
 
Constructor Summary
(package private) PdfStamperImp(PdfReader reader, OutputStream os, char pdfVersion, boolean append)
          Creates new PdfStamperImp.
 
Method Summary
 void addAnnotation(PdfAnnotation annot)
          Adds a PdfAnnotation or a PdfFormField to the document.
(package private)  void addAnnotation(PdfAnnotation annot, int page)
           
(package private)  void addAnnotation(PdfAnnotation annot, PdfDictionary pageN)
           
 void addComments(FdfReader fdf)
           
(package private)  void addDocumentField(PdfIndirectReference ref)
           
(package private)  void addFieldResources()
           
(package private)  void alterContents()
           
(package private)  void alterResources(PdfStamperImp.PageStamp ps)
           
(package private)  void applyRotation(PdfDictionary pageN, ByteBuffer out)
           
(package private)  void close(HashMap moreInfo)
           
(package private)  void deleteOutlines()
           
(package private)  void eliminateAcroformObjects()
           
(package private)  void expandFields(PdfFormField field, ArrayList allAnnots)
           
(package private) static void findAllObjects(PdfReader reader, PdfObject obj, IntHashtable hits)
           
(package private)  void flatFields()
           
(package private)  AcroFields getAcroFields()
           
protected  int getNewObjectNumber(PdfReader reader, int number, int generation)
           
(package private)  PdfContentByte getOverContent(int pageNum)
           
 PdfIndirectReference 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)
           
(package private)  PdfContentByte getUnderContent(int pageNum)
           
(package private)  void insertPage(int pageNumber, Rectangle mediabox)
           
(package private)  boolean isAppend()
          Getter for property append.
(package private)  boolean isContentWritten()
           
(package private)  boolean isRotateContents()
          Getter for property rotateContents.
protected  void markUsed(int num)
           
protected  void markUsed(PdfObject obj)
           
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 an UnsupportedOperationException.
(package private)  void setDuration(int seconds, int page)
          Sets the display duration for the page (for presentations)
(package private)  void setFormFlattening(boolean flat)
           
(package private)  void setJavaScript()
           
 void setOpenAction(PdfAction action)
          When the document opens this action will be invoked.
 void setOpenAction(String name)
          When the document opens it will jump to the destination with this name.
(package private)  void setOutlines()
           
(package private)  void setOutlines(List outlines)
           
 void setPageAction(PdfName actionType, PdfAction action)
          Always throws an UnsupportedOperationException.
(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 an UnsupportedOperationException.
(package private)  void setTransition(PdfTransition transition, int page)
          Sets the transition for the page
 void setViewerPreferences(int preferences)
          Sets the viewer preferences.
(package private)  void sweepKids(PdfObject obj)
           
 void unRegisterReader(PdfReader reader)
           
 
Methods inherited from class com.lowagie.text.pdf.PdfWriter
add, add, add, addCalculationOrder, addDirectImageSimple, addDirectTemplateSimple, addJavaScript, addJavaScript, addJavaScript, addLocalDestinations, addOCGRadioGroup, addSharedObjectsToBody, addSimple, addSimple, addSimpleExtGState, addSimpleLayer, addSimplePattern, addSimplePatternColorspace, addSimpleShading, addSimpleShadingPattern, addToBody, addToBody, addToBody, addToBody, addToBody, addToBody, breakTableIfDoesntFit, checkPDFXConformance, close, eliminateFontSubset, fitsPage, fitsPage, fitsPage, fitsPage, freeReader, getAcroForm, getCatalog, getCurrentDocumentSize, getCurrentPage, getCurrentPageNumber, getDefaultColorspace, getDirectContent, getDirectContentUnder, getEncryption, getExtraCatalog, getGroup, getImageReference, getImportedPage, getIndirectReferenceNumber, getInfo, getInstance, getInstance, getOCProperties, getOs, getPageEvent, getPageNumber, getPdfDocument, getPdfIndirectReference, getPdfTable, getPDFXConformance, getRootOutline, getRunDirection, getSpaceCharRatio, getTableBottom, getVerticalPosition, isFullCompression, isPaused, isStrictImageSequence, open, registerLayer, reorderPages, resetContent, setBoxSize, setCropBoxSize, setDefaultColorspace, setEncryption, setEncryption, setFullCompression, setGroup, setLinearPageMode, setOutputIntents, setOutputIntents, setPageEmpty, setPageEvent, setPageLabels, setPdfVersion, setPDFXConformance, setRunDirection, setSpaceCharRatio, setStrictImageSequence
 
Methods inherited from class com.lowagie.text.DocWriter
add, add, addTabs, clearTextWrap, flush, getISOBytes, hasMarkupAttributes, isCloseStream, newPage, pause, removeWatermark, resetFooter, resetHeader, resetPageCount, resume, setCloseStream, setFooter, setHeader, setMarginMirroring, setMargins, setPageCount, setPageSize, write, write, writeEnd, writeEnd, writeMarkupAttributes, writeStart
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

readers2intrefs

HashMap readers2intrefs

readers2file

HashMap readers2file

file

RandomAccessFileOrArray file

reader

PdfReader reader

myXref

IntHashtable myXref

pagesToContent

HashMap pagesToContent
Integer(page number) -> PageStamp


closed

boolean closed

rotateContents

private boolean rotateContents
Holds value of property rotateContents.


acroFields

protected AcroFields acroFields

flat

protected boolean flat

namePtr

protected int[] namePtr

namedAsNames

protected boolean namedAsNames

newBookmarks

protected List newBookmarks

partialFlattening

protected HashSet partialFlattening

useVp

protected boolean useVp

vp

protected int vp

fieldTemplates

protected HashMap fieldTemplates

fieldsAdded

protected boolean fieldsAdded

sigFlags

protected int sigFlags

append

protected boolean append

marked

protected IntHashtable marked

initialXrefSize

protected int initialXrefSize

openAction

protected PdfAction openAction
Constructor Detail

PdfStamperImp

PdfStamperImp(PdfReader reader,
              OutputStream os,
              char pdfVersion,
              boolean append)
        throws DocumentException,
               IOException
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
Throws:
DocumentException - on error
IOException
Method Detail

close

void close(HashMap moreInfo)
     throws DocumentException,
            IOException
Throws:
DocumentException
IOException

applyRotation

void applyRotation(PdfDictionary pageN,
                   ByteBuffer out)

alterContents

void alterContents()
             throws IOException
Throws:
IOException

alterResources

void alterResources(PdfStamperImp.PageStamp ps)

getNewObjectNumber

protected int getNewObjectNumber(PdfReader reader,
                                 int number,
                                 int generation)
Overrides:
getNewObjectNumber in class PdfWriter

getReaderFile

RandomAccessFileOrArray getReaderFile(PdfReader reader)
Overrides:
getReaderFile in class PdfWriter

registerReader

public void registerReader(PdfReader reader,
                           boolean openFile)
                    throws IOException
Throws:
IOException

unRegisterReader

public void unRegisterReader(PdfReader reader)

findAllObjects

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

addComments

public void addComments(FdfReader fdf)
                 throws IOException
Throws:
IOException

getPageStamp

PdfStamperImp.PageStamp getPageStamp(int pageNum)

getUnderContent

PdfContentByte getUnderContent(int pageNum)

getOverContent

PdfContentByte getOverContent(int pageNum)

insertPage

void insertPage(int pageNumber,
                Rectangle mediabox)

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

AcroFields getAcroFields()

setFormFlattening

void setFormFlattening(boolean flat)

partialFormFlattening

boolean partialFormFlattening(String name)

flatFields

void flatFields()

eliminateAcroformObjects

void eliminateAcroformObjects()

sweepKids

void sweepKids(PdfObject obj)

getPageReference

public PdfIndirectReference getPageReference(int page)
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 class PdfWriter
Parameters:
page - the page number. The first page is 1
Returns:
the reference to the page

addAnnotation

public void addAnnotation(PdfAnnotation annot)
Description copied from class: PdfWriter
Adds a PdfAnnotation or a PdfFormField to the document. Only the top parent of a PdfFormField needs to be added.

Overrides:
addAnnotation in class PdfWriter
Parameters:
annot - the PdfAnnotation or the PdfFormField to add

addDocumentField

void addDocumentField(PdfIndirectReference ref)

addFieldResources

void addFieldResources()

expandFields

void expandFields(PdfFormField field,
                  ArrayList allAnnots)

addAnnotation

void addAnnotation(PdfAnnotation annot,
                   PdfDictionary pageN)

addAnnotation

void addAnnotation(PdfAnnotation annot,
                   int page)
Overrides:
addAnnotation in class PdfWriter

outlineTravel

private void outlineTravel(PRIndirectReference outline)

deleteOutlines

void deleteOutlines()

setJavaScript

void setJavaScript()
             throws IOException
Throws:
IOException

setOutlines

void setOutlines()
           throws IOException
Throws:
IOException

setOutlines

void setOutlines(List outlines)

setViewerPreferences

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

Overrides:
setViewerPreferences in class PdfWriter
Parameters:
preferences - the viewer preferences
See Also:
PdfWriter.setViewerPreferences(int)

setSigFlags

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

Overrides:
setSigFlags in class PdfWriter
Parameters:
f - the flags. This flags are ORed with current ones

setPageAction

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

Overrides:
setPageAction in class PdfWriter
Parameters:
actionType - ignore
action - ignore
Throws:
PdfException - ignore
See Also:
PdfStamper.setPageAction(PdfName, PdfAction, int)

setPageAction

void setPageAction(PdfName actionType,
                   PdfAction action,
                   int page)
             throws PdfException
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

setDuration

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

Overrides:
setDuration in class PdfWriter
Parameters:
seconds - ignore

setTransition

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

Overrides:
setTransition in class PdfWriter
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 entry
page - the page where the duration will be applied. The first page is 1

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

markUsed

protected void markUsed(PdfObject obj)

markUsed

protected void markUsed(int num)

isAppend

boolean isAppend()
Getter for property append.

Returns:
Value of property append.

setAdditionalAction

public void setAdditionalAction(PdfName actionType,
                                PdfAction action)
                         throws PdfException
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.

Overrides:
setAdditionalAction in class PdfWriter
Parameters:
actionType - the action type
action - the action to execute in response to the trigger
Throws:
PdfException - on invalid action type

setOpenAction

public void setOpenAction(PdfAction action)
Description copied from class: PdfWriter
When the document opens this action will be invoked.

Overrides:
setOpenAction in class PdfWriter
Parameters:
action - the action to be invoked

setOpenAction

public void setOpenAction(String name)
Description copied from class: PdfWriter
When the document opens it will jump to the destination with this name.

Overrides:
setOpenAction in class PdfWriter
Parameters:
name - the name of the destination to jump to