Class PdfStamperImp

    • Field Detail

      • readers2intrefs

        private final java.util.HashMap readers2intrefs
      • readers2file

        private final java.util.HashMap readers2file
      • pagesToContent

        private final java.util.HashMap pagesToContent
        Integer(page number) -> PageStamp
      • closed

        private boolean closed
      • rotateContents

        private boolean rotateContents
        Holds value of property rotateContents.
      • flat

        private boolean flat
      • flatFreeText

        private boolean flatFreeText
      • namePtr

        private final int[] namePtr
      • partialFlattening

        private final java.util.HashSet partialFlattening
      • useVp

        private boolean useVp
      • fieldTemplates

        private final java.util.HashMap fieldTemplates
      • fieldsAdded

        private boolean fieldsAdded
      • sigFlags

        private int sigFlags
      • append

        private final boolean append
      • initialXrefSize

        private final int initialXrefSize
    • Constructor Detail

      • PdfStamperImp

        PdfStamperImp​(PdfReader reader,
                      java.io.OutputStream os,
                      char pdfVersion,
                      boolean append,
                      java.util.Calendar globalDate)
               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

      • close

        void close​(java.util.Map moreInfo,
                   java.util.Calendar globalDate)
            throws java.io.IOException
        Throws:
        java.io.IOException
      • alterContents

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

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

        private void correctAcroFieldPages​(int page)
      • moveRectangle

        private static void moveRectangle​(PdfDictionary dic2,
                                          PdfReader r,
                                          int pageImported,
                                          PdfName key,
                                          java.lang.String name)
      • 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)
      • flatFields

        private void flatFields()
      • eliminateAcroformObjects

        private void eliminateAcroformObjects()
      • sweepKids

        private 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

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

        private void expandFields​(PdfFormField field,
                                  java.util.ArrayList allAnnots)
      • deleteOutlines

        private void deleteOutlines()
      • setJavaScript

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

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

        private void setOutlines()
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • markUsed

        protected void markUsed​(PdfObject obj)
      • 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
      • 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

        private 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 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 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