Home  Products  Purchase  Downloads  Demos  Forums  Blogs  Ticket  Wiki  API  Corporate

com.aspose.pdf.kit
Class Stamp

java.lang.Object
  extended bycom.aspose.pdf.kit.Stamp

public class Stamp
extends java.lang.Object

Represents a class for stamp content, the content is an image or a text. The content can be layed at the bottom as background,or at the top as watermark and logo of pages.


Constructor Summary
Stamp()
          Creates a Stamp object.
 
Method Summary
 void bindImage(java.io.InputStream imageStream)
          Binds an image stream as stamp content.
 void bindImage(java.lang.String imageFile)
          Binds an image file as stamp content.
 void bindLogo(FormattedText text)
          Binds a FormattedText as stamp content.
 void bindLogo(java.lang.String text)
          Binds a text as stamp content.
 void bindPdf(java.io.InputStream pdfStream, int pageNumber)
          Binds one page of PDF stream as stamp content.
 void bindPdf(java.lang.String pdfFile, int pageNumber)
          Binds one page of PDF file as stamp content.
 void isBackground(boolean isBackground)
          Sets a bool value that indicates the content is stamped as background.
 void setImageSize(float width, float height)
          Resizes the image which is bound as stamp content.
 void setOpacity(float opacity)
          Sets a float value to indicate the stamp object opacity.
 void setOrigin(float originX, float originY)
          Sets the lower-left coordinates of a rectangle which contains stamp content layed on the pages.
 void setPages(int[] pages)
          Sets the page number to indicate on which pages the stamp content are added.
 void setRotation(float rotation)
          Sets the rotation of stamp content(from 0 to 360).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Stamp

public Stamp()
Creates a Stamp object.

Method Detail

setOpacity

public void setOpacity(float opacity)
Sets a float value to indicate the stamp object opacity. The value is from 0.0f to 1.0f, the default value is 1.0f.

Parameters:
opacity -

bindPdf

public void bindPdf(java.lang.String pdfFile,
                    int pageNumber)
             throws java.io.FileNotFoundException
Binds one page of PDF file as stamp content.

 [SampleCode]
 String path = "./examples/resources/";
 String inFile = path + "text.pdf";
 String outFile = path + "stamp2.pdf";
 PdfFileStamp fileStamp = new PdfFileStamp(inFile, outFile);
 
 Stamp pdfFileStamp = new Stamp();
 pdfFileStamp.bindPdf(path + "Online.pdf", 1);
 pdfFileStamp.isBackground(true);
 pdfFileStamp.setOpacity(0.5f);
 
 fileStamp.addStamp(pdfFileStamp);
 fileStamp.close();
 

Parameters:
pdfFile - input PDf file
pageNumber - the page number of PDF file which used as stamp content
Throws:
java.io.FileNotFoundException

bindPdf

public void bindPdf(java.io.InputStream pdfStream,
                    int pageNumber)
Binds one page of PDF stream as stamp content.

Parameters:
pdfStream - input PDf stream
pageNumber - the page number of PDF file which used as stamp content

bindLogo

public void bindLogo(FormattedText text)
Binds a FormattedText as stamp content.

 [SampleCode]
 String path = "./examples/resources/";
 String inFile = path + "text.pdf";
 String outFile = path + "stamp2.pdf";
 PdfFileStamp fileStamp = new PdfFileStamp(inFile, outFile);
 
 Stamp logoStamp = new Stamp();
 logoStamp.bindLogo(new FormattedText("Hello World!", 
 	new Color(180, 0, 0), FontStyle.TimesRoman, EncodingType.Winansi, false, 30));
 logoStamp.setRotation(45);
 
 fileStamp.addStamp(logoStamp);
 fileStamp.close();
 

Parameters:
text - input FormattedText object.

bindLogo

public void bindLogo(java.lang.String text)
              throws java.io.IOException,
                     PdfKitException
Binds a text as stamp content.

Parameters:
text - input string.
Throws:
java.io.IOException
PdfKitException

bindImage

public void bindImage(java.lang.String imageFile)
               throws java.io.FileNotFoundException
Binds an image file as stamp content.

 [SampleCode]
 String path = "./examples/resources/";
 String inFile = path + "text.pdf";
 String outFile = path + "stamp2.pdf";
 PdfFileStamp fileStamp = new PdfFileStamp(inFile, outFile);
 
 Stamp watermarkStamp = new Stamp();
 watermarkStamp.bindImage(path + "imgLogoPDFKit.gif");
 logoStamp.setOrigin(100, 50);
 logoStamp.setRotation(15);
 
 fileStamp.addStamp(watermarkStamp);
 fileStamp.close();
 

Parameters:
imageFile - Input image file.
Throws:
java.io.FileNotFoundException

bindImage

public void bindImage(java.io.InputStream imageStream)
Binds an image stream as stamp content.

Parameters:
imageStream - Input image stream.

setPages

public void setPages(int[] pages)
Sets the page number to indicate on which pages the stamp content are added. By default,stamps each page .

Parameters:
pages - page number collection

isBackground

public void isBackground(boolean isBackground)
Sets a bool value that indicates the content is stamped as background.

Parameters:
isBackground - The isBackgroud to set.

setOrigin

public void setOrigin(float originX,
                      float originY)
Sets the lower-left coordinates of a rectangle which contains stamp content layed on the pages.

Parameters:
originX - The x coordinate to set.
originY - The y coordinate to set.

setRotation

public void setRotation(float rotation)
Sets the rotation of stamp content(from 0 to 360).

Parameters:
rotation - The rotation to set.

setImageSize

public void setImageSize(float width,
                         float height)
Resizes the image which is bound as stamp content.

Parameters:
width - New width of image.
height - New height of image.