Home  Products  Purchase  Downloads  Demos  Forums  Blogs  Ticket  Wiki  API  Corporate

com.aspose.pdf.kit
Class PdfFileStamp

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

public class PdfFileStamp
extends java.lang.Object

Represents a class for adding watermark or logo at (x,y) on each page of Pdf file. The logo is a string of characters.


Constructor Summary
PdfFileStamp(java.io.InputStream inputStream, java.io.OutputStream outputStream)
          Creates a PdfFileStamp object instance.
PdfFileStamp(java.lang.String inputFile, java.lang.String outputFile)
          Creates a PdfFileStamp object instance.
 
Method Summary
 void addLogomark(FormattedText logo, float x, float y)
          Adds a logo on each page of the Pdf fila at (x,y).
 void addWatermark(java.lang.String imageFile, float x, float y)
          Adds a watermark on each page of the Pdf file at (x,y).
 void close()
          Closes the PdfFileStamp object,writes the watermark and logo to the Pdf document.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PdfFileStamp

public PdfFileStamp(java.lang.String inputFile,
                    java.lang.String outputFile)
             throws java.io.IOException,
                    PdfKitException
Creates a PdfFileStamp object instance.

Parameters:
inputFile - String Source input Pdf file.
outputFile - String Output Pdf file.
Throws:
java.io.IOException
PdfKitException

PdfFileStamp

public PdfFileStamp(java.io.InputStream inputStream,
                    java.io.OutputStream outputStream)
             throws java.io.IOException,
                    PdfKitException
Creates a PdfFileStamp object instance.

Parameters:
inputStream - InputStream Source input Pdf Stream.
outputStream - OutputStream Output Pdf Stream.
Throws:
java.io.IOException
PdfKitException
Method Detail

addWatermark

public void addWatermark(java.lang.String imageFile,
                         float x,
                         float y)
                  throws java.io.IOException,
                         com.aspose.pdf.kit.BadElementException,
                         java.net.MalformedURLException
Adds a watermark on each page of the Pdf file at (x,y).

Parameters:
imageFile - String The path of image, the types supported are JPG,PNG,GIF.
x - float Horizon position.
y - float Vertical position.
Throws:
java.io.IOException
BadElementException
java.net.MalformedURLException

addLogomark

public void addLogomark(FormattedText logo,
                        float x,
                        float y)
Adds a logo on each page of the Pdf fila at (x,y).

Parameters:
logo - FormattedText The logo with font,encoding and size format.
x - float The X position.
y - float The Y position.

close

public void close()
           throws PdfKitException,
                  java.io.IOException
Closes the PdfFileStamp object,writes the watermark and logo to the Pdf document.

 [SampleCode]
 String inFile = "example2.pdf";
 String outFile = "kitOut.pdf";
 PdfFileStamp fileStamp = new PdfFileStamp(inFile, outFile);
 FormattedText logo1 = new FormattedText("Evaluation Only. Created with Aspose.Pdf.Kit. Copyright 2002-2005 Aspose Pty Ltd",new FontColor(0, 20, 180),
 FontStyle.TimesRoman,EncodingType.Winansi, false, 12);
 FormattedText logo2 = new FormattedText("Aspose.Pdf.Kit",new FontColor(10, 30, 100),FontStyle.HelveticaOblique,
 EncodingType.Winansi, false, 20);
 fileStamp.addLogomark(logo1, 20, 50);
 fileStamp.addLogomark(logo2, 20, 70);
 fileStamp.addWatermark("imgLogoPDF.gif", 100,100);
 fileStamp.close();
 

Throws:
PdfKitException
java.io.IOException