![]() |
||
Home Products Purchase Downloads Demos Forums Blogs Ticket Wiki API Corporate |
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.aspose.pdf.kit.PdfFileStamp
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 |
addPageNumber(FormattedText formattedText)
Adds page number with specified format in each pages of the pdf file and save it. |
void |
addPageNumber(java.lang.String formatString)
Adds page number in each pages of the pdf file and save it. |
void |
addStamp(Stamp stamp)
Adds stamp at the specified pages of pdf file.The stamp can be added as watermark,logo and background according to the isBackground function of stamp. |
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. |
float |
getPageHeight()
Gets the page's height of pdf file which you want to be stamped. |
float |
getPageWidth()
Gets the page's width of pdf file which you want to be stamped. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PdfFileStamp(java.lang.String inputFile, java.lang.String outputFile) throws java.io.IOException, PdfKitException
inputFile
- String Source input Pdf file.outputFile
- String Output Pdf file.
java.io.IOException
PdfKitException
public PdfFileStamp(java.io.InputStream inputStream, java.io.OutputStream outputStream) throws java.io.IOException, PdfKitException
inputStream
- InputStream Source input Pdf Stream.outputStream
- OutputStream Output Pdf Stream.
java.io.IOException
PdfKitException
Method Detail |
public void addWatermark(java.lang.String imageFile, float x, float y) throws java.io.IOException, com.aspose.pdf.kit.BadElementException, java.net.MalformedURLException
imageFile
- String The path of image, the types supported are JPG,PNG,GIF.x
- float Horizon position.y
- float Vertical position.
java.io.IOException
BadElementException
java.net.MalformedURLException
public void addLogomark(FormattedText logo, float x, float y)
logo
- FormattedText The logo with font,encoding and size format.x
- float The X position.y
- float The Y position.public void close() throws PdfKitException, java.io.IOException
[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 Color(10, 30, 100),FontStyle.HelveticaOblique, EncodingType.Winansi, false, 20); fileStamp.addLogomark(logo1, 20, 50); fileStamp.addLogomark(logo2, 20, 70); fileStamp.addWatermark("imgLogoPDFKit.gif", 100,100); fileStamp.close();
PdfKitException
java.io.IOException
public void addStamp(Stamp stamp)
[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); Stamp watermarkStamp = new Stamp(); watermarkStamp.bindImage(path + "imgLogoPDFKit.gif"); logoStamp.setOrigin(100, 50); logoStamp.setRotation(15); Stamp backgroundStamp = new Stamp(); backgroundStamp.bindImage(path + "butterfly.jpg"); backgroundStamp.setImageSize(100,100); backgroundStamp.setOrigin(200,200); backgroundStamp.isBackgroud(true); Stamp pdfFileStamp = new Stamp(); pdfFileStamp.bindPdf(path + "Online.pdf", 1); pdfFileStamp.isBackground(true); pdfFileStamp.setOpacity(0.5f); fileStamp.addStamp(logoStamp); fileStamp.addStamp(watermarkStamp); fileStamp.addStamp(backgroundStamp); fileStamp.addStamp(pdfFileStamp); fileStamp.close();
stamp
- Stamp content.public void addPageNumber(java.lang.String formatString)
[SampleCode] String path = "./examples/resources/"; String inFile = path + "example2.pdf"; String outFile = path + "example2withpagenumber.pdf"; PdfFileStamp fileStamp = new PdfFileStamp(inFile, outFile); //add page number fileStamp.addPageNumber("Page # ."); fileStamp.close();
formatString
- the format of page number string, must contain one and only one "#", such as "Page #". The "#" string will be replaced with page number.public void addPageNumber(FormattedText formattedText)
[SampleCode] String path = "./examples/resources/"; String inFile = path + "example2.pdf"; String outFile = path + "example2withpagenumber.pdf"; PdfFileStamp fileStamp = new PdfFileStamp(inFile, outFile); //add page number FormattedText ft = new FormattedText("Page # .", new Color(0,0,100), FontStyle.CourierBold,EncodingType.Winansi, false, 10); fileStamp.addPageNumber(ft); fileStamp.close();
formattedText
- a FormattedText object which contain the format of page number string, must contain one and only one "#", such as "Page #". The "#" string will be replaced with page number.public float getPageHeight()
public float getPageWidth()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |