Add Logo
Aspose.Pdf.Kit provides the flexibility to developers to not only add watermark on each page of the PDF document but also the Logos (as string) at any specified location.
To add a logo in Java, just follow these steps:
- Format the text of logo string using FormattedText class. Create the FormattedText object by calling its constrcutor. We can pass the the logo text to be formatted with font color ( FontColor ), font style ( FontStyle ), encoding type ( EncodingType ) and font size information to its constrcutor. A bool value (true/false) is also passed to FormattedText constructor to tell whether the font has to be embedded or not.
- Create an object of Stamp class, bind the FormattedText object,set isBackground equal to false.
- Create an object of PdfFileStamp class by passing the input and output PDF files as file names or streams.
- Call addStamp method and pass the Stamp object.
- Close the PdfFileStamp object.
(Note: From version 1.4.2.0, Aspose.Pdf.Kit supports the addition of more than one logos at one time into the PDF document)
Aspose.Pdf.Kit provides the flexibility to developers to not only add watermark on each page of the PDF document but also the Logos (as string) at any specified location.
To add a logo in Java, just follow these steps:
- Format the text of logo string using FormattedText class. Create the FormattedText object by calling its constrcutor. We can pass the the logo text to be formatted with font color ( FontColor ), font style ( FontStyle ), encoding type ( EncodingType ) and font size information to its constrcutor. A bool value (true/false) is also passed to FormattedText constructor to tell whether the font has to be embedded or not.
- Create an object of Stamp class, bind the FormattedText object,set isBackground equal to false.
- Create an object of PdfFileStamp class by passing the input and output PDF files as file names or streams.
- Call addStamp method and pass the Stamp object.
- Close the PdfFileStamp object.
(Note: From version 1.4.2.0, Aspose.Pdf.Kit supports the addition of more than one logos at one time into the PDF document)
[Java]
fileStamp = new PdfFileStamp(inFile, outFile); Stamp logoStamp = new Stamp(); logoStamp.bindLogo(new FormattedText("Hello World!", new FontColor(180, 0, 0), FontStyle.TimesRoman, EncodingType.Winansi, false, 30)); logoStamp.setRotation(45); fileStamp.addStamp(logoStamp); fileStamp.close();
