com.aspose.pdf.facades

Interface IPdfFileStamp

  • All Known Implementing Classes:
    PdfFileStamp, PdfFileStampWeb


    public interface IPdfFileStamp

    interface for adding stamps (watermark or background) to PDF files.

    • Method Detail

      • getKeepSecurity

        boolean getKeepSecurity()

        Keeps security if true. (This feature will be implemented in next versions).

        Returns:
        boolean value
      • setKeepSecurity

        void setKeepSecurity(boolean value)
        Set Keep Security
        Parameters:
        value - boolean value
      • getInputFile

        String getInputFile()

        Gets name and path of input file.

        Returns:
        String object
      • setInputFile

        void setInputFile(String value)

        Sets name and path of input file.

        Parameters:
        value - String value
      • getInputStream

        InputStream getInputStream()

        Gets input stream.

        Returns:
        InputStream object
      • setInputStream

        void setInputStream(InputStream value)

        Sets input stream.

        Parameters:
        value - InputStream object
      • getOutputFile

        String getOutputFile()

        Gets name and path of output file.

        Returns:
        String object
      • setOutputFile

        void setOutputFile(String value)

        Sets name and path of output file.

        Parameters:
        value - String object
      • getOutputStream

        OutputStream getOutputStream()

        Gets output stream.

        Returns:
        OutputStream object
      • setOutputStream

        void setOutputStream(OutputStream value)

        Sets or sets output stream.

        Parameters:
        value - OutputStream object
      • getPageNumberRotation

        float getPageNumberRotation()

        Gets rotation of page number. Rotation is in degrees. Default is 0.

        Returns:
        float value
      • setPageNumberRotation

        void setPageNumberRotation(float value)

        Sets rotation of page number. Rotation is in degrees. Default is 0.

        Parameters:
        value - float value
      • setConvertTo

        void setConvertTo(int value)

        Sets PDF file format. Result file will be saved in specified file format. If this property is not specified then file will be save in default PDF format without conversion.

        Parameters:
        value - PdfFormat element
        See Also:
        PdfFormat
      • getPageHeight

        float getPageHeight()

        Gets height of first page in souorce file.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
         System.out.println("Height = " + fileStamp.getPageHeight());
         fileStamp.close();
         
        Returns:
        float value
      • getPageWidth

        float getPageWidth()

        Gets width of first page in input file.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
         System.out.println("Width = " + fileStamp.getPageWidth());
         fileStamp.close();
         
        Returns:
        float value
      • getStartingNumber

        int getStartingNumber()
        Gets or sets starting number for first page in input file. Next pages will be numbered starting from this value.
        Returns:
        int value
      • setStartingNumber

        void setStartingNumber(int value)

        Sets starting number for first page in input file. Next pages will be numbered starting from this value. For example if StartingNumber is set to 100, document pages will have numbers 100, 101, 102...


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
         fileStamp.setStartingNumber(100);
         fileStamp.addPageNumber("Page #");
         fileStamp.close();
         
        Parameters:
        value - int value
      • close

        void close()

        Closes opened files and saves changes. Warning. If input or output streams are specified they are not closed by Close() method.


         
         
         PdfFileStamp stamp = new PdfFileStamp("input.pdf", "output.pdf");
         // do some work...
         stamp.close();
         
      • dispose

        void dispose()

        Closes opened files and saves changes. Warning. If input or output streams are specified they are not closed by Close() method.


         
         
         PdfFileStamp stamp = new PdfFileStamp("input.pdf", "output.pdf");
         // do some work...
         stamp.dispose();
         
      • addStamp

        void addStamp(Stamp stamp)

        Adds stamp to the file.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
         Stamp stamp = new com.aspose.pdf.facades.Stamp();
         stamp.setOrigin(140, 400);
         stamp.setImageSize(50, 50);
         stamp.setOpacity(0.8f);
         stamp.isBackground(true);
         stamp.bindImage("image.jpg");
         fileStamp.addStamp(stamp);
         fileStamp.close();
         
        Parameters:
        stamp - Stamp object which.
      • addPageNumber

        void addPageNumber(String formatString)

        Add page number to file. Page number text may contain # sign which will be replaced with number of the page. Page number is placed in the bottom of the page centered horizontally.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
         fileStamp.addPageNumber("Page #");
         fileStamp.close();
         
        Parameters:
        formatString - Text of page number
      • addPageNumber

        void addPageNumber(FormattedText formattedText)

        Adds page number to the page. Page number may contain # sign which will be replaced with page number. Page number is placed in the bottom of the page centered horizontally.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
         fileStamp.addPageNumber(new FormattedText("Page #"));
         fileStamp.close();
         
        Parameters:
        formattedText - Format string for page number representes as FormattedText.
      • addPageNumber

        void addPageNumber(String formatString,
                           int position,
                           float leftMargin,
                           float rightMargin,
                           float topMargin,
                           float bottomMargin)

        Adds page number to the pages of document.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
         fileStamp.addPageNumber("Page #", PdfFileStamp.PosBottomLeft, 100, 100, 200, 200);
         fileStamp.close();
         
        Parameters:
        formatString - Format string for page number.
        position - Position where page number will be placed on the page. 0-bottom middle, 1-bottom right, 2-upper right, 3 - sides right, 4 - upper middle,5 - bottom left,6 - sides left,7 - upper left. You can use the following constants: PosBottomMiddle = 0, PosBottomRight = 1, PosUpperRight = 2, PosSidesRight = 3, PosUpperMiddle, PosBottomLeft = 5, PosSidesLeft, PosUpperLeft
        leftMargin - Margin on the left edge of the page.
        rightMargin - Margin on the right edge of the page.
        topMargin - Margin on the top edge of the page.
        bottomMargin - Margin on the bottom edge of the page.
      • addPageNumber

        void addPageNumber(String formatString,
                           float x,
                           float y)

        Adds page number at the specified position on the page.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
         fileStamp.addPageNumber(new FormattedText("Page  #"), 123, 357);
         fileStamp.close();
         
        Parameters:
        formatString - Format string. Format string can contain # sign which will be replaced with page number.
        x - X coordinate of page number.
        y - Y coordinate of page number.
      • addPageNumber

        void addPageNumber(FormattedText formattedText,
                           int position,
                           float leftMargin,
                           float rightMargin,
                           float topMargin,
                           float bottomMargin)

        Adds page number to the pages of document.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
         fileStamp.addPageNumber(new FormattedText("Page #"), PdfFileStamp.PosBottomLeft, 100, 100, 200, 200);
         fileStamp.close();
         
        Parameters:
        formattedText - FormattedText object which represents page number format and properties iof the text.
        position - Position where page number will be placed on the page. 0-bottom middle, 1-bottom right, 2-upper right, 3 - sides right, 4 - upper middle,5 - bottom left,6 - sides left,7 - upper left. You can use the following constants: PosBottomMiddle = 0, PosBottomRight = 1, PosUpperRight = 2, PosSidesRight = 3, PosUpperMiddle, PosBottomLeft = 5, PosSidesLeft, PosUpperLeft
        leftMargin - Margin on the left edge of the page.
        rightMargin - Margin on the right edge of the page.
        topMargin - Margin on the top edge of the page.
        bottomMargin - Margin on the bottom edge of the page.
      • addPageNumber

        void addPageNumber(FormattedText formattedText,
                           float x,
                           float y)

        Adds page number at the specified position on the page.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
         fileStamp.addPageNumber(new FormattedText("Page  #"), 123, 357);
         fileStamp.close();
         
        Parameters:
        formattedText - Formatted text which represents page number format and properties of the text. Format string can contain # sign which will be replaced with page number.
        x - X coordinate of page number.
        y - Y coordinate of page number.
      • addHeader

        void addHeader(FormattedText formattedText,
                       float topMargin)

        Adds header to the page.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
         fileStamp.addHeader(new FormattedText("Head of the page"), 50);
         fileStamp.close();
         
        Parameters:
        formattedText - Text for header and properties of the text.
        topMargin - Margin on the top of page.
      • addHeader

        void addHeader(FormattedText formattedText,
                       float topMargin,
                       float leftMargin,
                       float rightMargin)

        Adds header to the pages of file.


         
         
         PdfFileStamp stamp = new PdfFileStamp("input.pdf", "output.pdf");
         stamp.addHeader(new FormattedText("Head of the page"), 10, 50, 50);
         
        Parameters:
        formattedText - Formatted text object which contains page text and its properties.
        topMargin - Margin on the top of the page.
        leftMargin - Margin on the left of the page.
        rightMargin - Margin on the right of the page.
      • addHeader

        void addHeader(String imageFile,
                       float topMargin)

        Adds image as header to the pages of the file.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", output.pdf");
         fileStamp.addHeader("image.jpg", 50);
         fileStamp.close();
         
        Parameters:
        imageFile - Path to the image file.
        topMargin - Margin at top of the page.
      • addHeader

        void addHeader(String imageFile,
                       float topMargin,
                       float leftMargin,
                       float rightMargin)

        Adds image as header on the pages.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", output.pdf");
         fileStamp.addHeader("image.jpg", 50, 100, 100);
         fileStamp.close();
         
        Parameters:
        imageFile - Path to the image file.
        topMargin - Margin at top of the page.
        leftMargin - Margin at left side of the page.
        rightMargin - Margin at right side of the page.
      • addHeader

        void addHeader(InputStream imageStream,
                       float topMargin)

        Adds image as header on the pages.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", output.pdf");
         fileStamp.addHeader(new FileInputStream("image.jpg"), 50);
         fileStamp.close();
         
        Parameters:
        imageStream - Stream of the image.
        topMargin - Margin at top of the page.
      • addHeader

        void addHeader(InputStream inputStream,
                       float topMargin,
                       float leftMargin,
                       float rightMargin)

        Adds image at the top of the page.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", output.pdf");
         fileStamp.addHeader(new FileInputStream("image.jpg"), 50, 100, 100);
         fileStamp.close();
         
        Parameters:
        inputStream - Stream which contains image data.
        topMargin - Margin at top of the page.
        leftMargin - Margin at left side of the page.
        rightMargin - Margin at right side of the page.
      • addFooter

        void addFooter(FormattedText formattedText,
                       float bottomMargin)

        Adds footer to the pages of the document.


         
         
         PdfFileStamp stamp = new PdfFileStamp("input.pdf", "output.pdf");
         stamp.addFooter(new FormattedText("Foot of the page"), 10);
         
        Parameters:
        formattedText - FormattedText object which contains text of the footer and text properties.
        bottomMargin - Margin at the top of page.
      • addFooter

        void addFooter(FormattedText formattedText,
                       float bottomMargin,
                       float leftMargin,
                       float rightMargin)

        Adds footer to the pages of the document.


         
         
         PdfFileStamp stamp = new PdfFileStamp("input.pdf", "output.pdf");
         stamp.addFooter(new FormattedText("Foot of the page"), 10, 50, 50);
         
        Parameters:
        formattedText - FormattedText object which contains footer text and text properties.
        bottomMargin - Margin at the bottom of the page.
        leftMargin - Margin at the left side of the page.
        rightMargin - Margin at the right side of the page.
      • addFooter

        void addFooter(String imageFile,
                       float bottomMargin)

        Adds image as footer to the pages of the document.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", output.pdf");
         fileStamp.addFooter("image.jpg", 50);
         fileStamp.close();
         
        Parameters:
        imageFile - Image file name and path.
        bottomMargin - Margin at the bottom of the page.
      • addFooter

        void addFooter(String imageFile,
                       float bottomMargin,
                       float leftMargin,
                       float rightMargin)

        Adds image as footer of the pages.

        Parameters:
        imageFile - Iamge file name and path.
        bottomMargin - Margin at the bottom of the page.
        leftMargin - Margin at the left side of the page.
        rightMargin - Margin at the right side of the page.
      • addFooter

        void addFooter(InputStream imageStream,
                       float bottomMargin)

        Adds image as footer of the page.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", output.pdf");
         fileStamp.addFooter(new FileInputStream("image.jpg"), 50);
         fileStamp.close();
         
        Parameters:
        imageStream - Stream contains image data.
        bottomMargin - Margin at the bottom of the page.
      • addFooter

        void addFooter(InputStream imageStream,
                       float bottomMargin,
                       float leftMargin,
                       float rightMargin)

        Adds image as footer of the page.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", output.pdf");
         fileStamp.addFooter(new FileInputStream("image.jpg"), 50, 50, 50);
         fileStamp.close();
         
        Parameters:
        imageStream - Stream contains image data.
        bottomMargin - Margin at the bottom of the page.
        leftMargin - Margin at the left side of the page.
        rightMargin - Margin at the right side of the page.
      • addPageNumber

        void addPageNumber(String formatString,
                           int position)

        Adds page number to the pages.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
         fileStamp.addPageNumber("Page #", PdfFileStamp.PosUpperRight);
         fileStamp.close();
         
        Parameters:
        formatString - Format of the page number. This text may contain # which will be replaced with page number.
        position - Position where page number will be placed on the page. 0-bottom middle, 1-bottom right, 2-upper right, 3 - sides right, 4 - upper middle,5 - bottom left,6 - sides left,7 - upper left. You can use the following constants: PosBottomMiddle = 0, PosBottomRight = 1, PosUpperRight = 2, PosSidesRight = 3, PosUpperMiddle, PosBottomLeft = 5, PosSidesLeft, PosUpperLeft
      • addPageNumber

        void addPageNumber(FormattedText formattedText,
                           int position)

        Adds page number to the pages.


         
         
         PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
         fileStamp.addPageNumber("Page #", PdfFileStamp.PosUpperRight);
         fileStamp.close();
         
        Parameters:
        formattedText - FormattedText object which contains format of the page number and text properties. This text may contain # which will be replaced with page number.
        position - Position where page number will be placed on the page. 0-bottom middle, 1-bottom right, 2-upper right, 3 - sides right, 4 - upper middle,5 - bottom left,6 - sides left,7 - upper left. You can use the following constants: PosBottomMiddle = 0, PosBottomRight = 1, PosUpperRight = 2, PosSidesRight = 3, PosUpperMiddle, PosBottomLeft = 5, PosSidesLeft, PosUpperLeft
      • getDocument

        IDocument getDocument()

        Gets the document PdfFileStamp is working on.

        Returns:
        IDocument object
      • getContentDisposition

        int getContentDisposition()

        Gets how content will be stored when result of operation is stored into HttpResponse object. Possible value: inline / attachment. Default: inline.

        Returns:
        ContentDisposition element
      • setContentDisposition

        void setContentDisposition(int value)

        Sets how content will be stored when result of operation is stored into HttpResponse object. Possible value: inline / attachment. Default: inline.

        Parameters:
        value - ContentDisposition element
        See Also:
        ContentDisposition
      • getSaveOptions

        SaveOptions getSaveOptions()

        Gets save options when result is stored as HttpResponse. Default value: PdfSaveOptions.

        Returns:
        SaveOptions object
      • setSaveOptions

        void setSaveOptions(SaveOptions value)

        Sets save options when result is stored as HttpResponse. Default value: PdfSaveOptions.

        Parameters:
        value - SaveOptions value
      • getAttachmentName

        String getAttachmentName()

        Gets name of attachment when result of operation is stored into HttpResponse objects as attachment.

        Returns:
        String value
      • setAttachmentName

        void setAttachmentName(String value)

        Sets name of attachment when result of operation is stored into HttpResponse objects as attachment.

        Parameters:
        value - String value