Class PdfStamperImp

    • Field Detail

      • closed

        protected boolean closed
      • rotateContents

        private boolean rotateContents
        Holds value of property rotateContents.
      • flat

        protected boolean flat
      • flatFreeText

        protected boolean flatFreeText
      • flatannotations

        protected boolean flatannotations
      • namePtr

        protected int[] namePtr
      • partialFlattening

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

        protected boolean useVp
      • fieldTemplates

        protected java.util.HashSet<PdfTemplate> fieldTemplates
      • fieldsAdded

        protected boolean fieldsAdded
      • sigFlags

        protected int sigFlags
      • append

        protected boolean append
      • initialXrefSize

        protected int initialXrefSize
      • namedDestinations

        protected java.util.HashMap<java.lang.Object,​PdfObject> namedDestinations
      • COUNTER

        protected Counter COUNTER
      • logger

        private Logger logger
      • originalLayersAreRead

        private boolean originalLayersAreRead
      • builtInAnnotationFonts

        private java.util.HashMap<java.lang.String,​PdfIndirectReference> builtInAnnotationFonts
      • fromShortToFullAnnotationFontNames

        private static java.util.HashMap<java.lang.String,​java.lang.String> fromShortToFullAnnotationFontNames
      • DEFAULT_MATRIX

        private double[] DEFAULT_MATRIX
    • Constructor Detail

      • PdfStamperImp

        protected 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

      • readColorProfile

        protected void readColorProfile()
      • setViewerPreferences

        protected void setViewerPreferences()
      • close

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

        protected void close​(PdfIndirectReference info,
                             int skipInfo)
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • alterContents

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

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

        protected void flatFields()
      • eliminateAcroformObjects

        void eliminateAcroformObjects()
      • sweepKids

        void sweepKids​(PdfObject obj)
      • setFlatAnnotations

        public void setFlatAnnotations​(boolean flatAnnotations)
        If true, annotations with an appearance stream will be flattened.
        Parameters:
        flatAnnotations - boolean
        Since:
        5.5.3
      • flattenAnnotations

        protected void flattenAnnotations()
        If setFlatAnnotations is set to true, iText will flatten all annotations with an appearance stream
        Since:
        5.5.3
      • flattenAnnotations

        private void flattenAnnotations​(boolean flattenFreeTextAnnotations)
      • transformBBoxByMatrix

        private Rectangle transformBBoxByMatrix​(Rectangle bBox,
                                                double[] matrix)
      • transformPoint

        private Point transformPoint​(double x,
                                     double y,
                                     double[] matrix)
      • flatFreeTextFields

        protected 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

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

        void deleteOutlines()
      • setJavaScript

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

        protected 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

        protected 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.
      • getPdfReader

        public PdfReader getPdfReader()
      • 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
      • createXmpMetadata

        public void createXmpMetadata()
        Description copied from class: PdfWriter
        Use this method to creates XMP Metadata based on the metadata in the PdfDocument.
        Overrides:
        createXmpMetadata in class PdfWriter
      • getNamedDestinations

        protected java.util.HashMap<java.lang.Object,​PdfObject> getNamedDestinations()
      • updateNamedDestinations

        protected void updateNamedDestinations()
                                        throws java.io.IOException
        Throws:
        java.io.IOException