Class PdfStamperImp

    • Field Detail

      • flat

        protected boolean flat
      • flatFreeText

        protected boolean flatFreeText
      • namePtr

        protected int[] namePtr
      • partialFlattening

        protected java.util.Set<java.lang.String> partialFlattening
      • useVp

        protected boolean useVp
      • fieldTemplates

        protected java.util.Map<PdfTemplate,​java.lang.Object> fieldTemplates
      • fieldsAdded

        protected boolean fieldsAdded
      • sigFlags

        protected int sigFlags
      • append

        protected boolean append
      • initialXrefSize

        protected int initialXrefSize
      • closed

        boolean closed
      • rotateContents

        private boolean rotateContents
        Holds value of property rotateContents.
      • includeFileID

        private boolean includeFileID
      • overrideFileId

        private PdfObject overrideFileId
      • modificationDate

        private java.util.Calendar modificationDate
      • updateMetadata

        private boolean updateMetadata
      • updateDocInfo

        private boolean updateDocInfo
    • Constructor Detail

      • PdfStamperImp

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

      • moveRectangle

        private static void moveRectangle​(PdfDictionary dic2,
                                          PdfReader r,
                                          int pageImported,
                                          PdfName key,
                                          java.lang.String name)
      • close

        void close​(java.util.Map<java.lang.String,​java.lang.String> moreInfo)
            throws java.io.IOException
        Throws:
        java.io.IOException
      • getInfoDictionary

        PdfDictionary getInfoDictionary​(PdfDictionary oldInfo,
                                        PdfDate modificationDate,
                                        java.lang.String producer,
                                        java.util.Map<java.lang.String,​java.lang.String> moreInfo)
      • alterContents

        void alterContents()
                    throws java.io.IOException
        Throws:
        java.io.IOException
      • removeEncryption

        public void removeEncryption()
                              throws DocumentException
        Removes the encryption from the document (and also inherently the permissions)
        Throws:
        DocumentException
      • registerReader

        public void registerReader​(PdfReader reader,
                                   boolean openFile)
                            throws java.io.IOException
        Parameters:
        reader -
        openFile -
        Throws:
        java.io.IOException
      • unRegisterReader

        public void unRegisterReader​(PdfReader reader)
        Parameters:
        reader -
      • addComments

        public void addComments​(FdfReader fdf)
                         throws java.io.IOException
        Parameters:
        fdf -
        Throws:
        java.io.IOException
      • correctAcroFieldPages

        void correctAcroFieldPages​(int page)
      • replacePage

        void replacePage​(PdfReader r,
                         int pageImported,
                         int pageReplaced)
      • 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()
      • setFormFlattening

        void setFormFlattening​(boolean flat)
      • setFreeTextFlattening

        void setFreeTextFlattening​(boolean flat)
      • partialFormFlattening

        boolean partialFormFlattening​(java.lang.String name)
      • flatFields

        void flatFields()
      • eliminateAcroformObjects

        void eliminateAcroformObjects()
      • sweepKids

        void sweepKids​(PdfObject obj)
      • flatFreeTextFields

        private void flatFreeTextFields()
      • getPageReference

        public PdfIndirectReference getPageReference​(int page)
        Description copied from class: PdfWriter
        Use 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:
        getPageReference in class PdfWriter
        Parameters:
        page - the page number. The first page is 1
        Returns:
        the reference to the page
        See Also:
        PdfWriter.getPageReference(int)
      • addFieldResources

        void addFieldResources()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • addAnnotationToDocument

        private void addAnnotationToDocument​(PdfAnnotation annot)
        Allows to add e.g. a Radiogroup without specifying a page for the data field parent. The parent (data) form field isn't located on a page thus it doesn't make sense to specify one.
        Parameters:
        annot - annotation to be added
      • deleteOutlines

        void deleteOutlines()
      • setJavaScript

        void setJavaScript()
                    throws java.io.IOException
        Throws:
        java.io.IOException
      • addFileAttachments

        void addFileAttachments()
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • makePackage

        void makePackage​(PdfCollection collection)
        Adds or replaces the Collection Dictionary in the Catalog.
        Parameters:
        collection - the new collection dictionary.
      • setOutlines

        void setOutlines()
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • 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

        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.
      • getDirectContentUnder

        public PdfContentByte getDirectContentUnder()
        Description copied from class: PdfWriter
        Use 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:
        getDirectContentUnder in class PdfWriter
        Returns:
        the direct content
      • getDirectContent

        public PdfContentByte getDirectContent()
        Description copied from class: PdfWriter
        Use 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:
        getDirectContent in class PdfWriter
        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
      • addOrder

        private void addOrder​(PdfLayer parent,
                              PdfArray arr,
                              java.util.Map<java.lang.String,​PdfLayer> 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
      • getPdfLayers

        public java.util.Map<java.lang.String,​PdfLayer> 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
      • isIncludeFileID

        public boolean isIncludeFileID()
        These methods are used by PdfStamper to override some PDF properties when signing PDF files.
      • setIncludeFileID

        public void setIncludeFileID​(boolean includeFileID)
      • getOverrideFileId

        public PdfObject getOverrideFileId()
      • setOverrideFileId

        public void setOverrideFileId​(PdfObject overrideFileId)
      • getModificationDate

        public java.util.Calendar getModificationDate()
      • setModificationDate

        public void setModificationDate​(java.util.Calendar modificationDate)
      • isUpdateMetadata

        public boolean isUpdateMetadata()
      • setUpdateMetadata

        public void setUpdateMetadata​(boolean updateMetadata)
      • isUpdateDocInfo

        public boolean isUpdateDocInfo()
      • setUpdateDocInfo

        public void setUpdateDocInfo​(boolean updateDocInfo)