We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Trying to add watermark across entire page of imported PDF document

I am having some trouble figureing out how to use the Aspose toolkits to accomplish the following:

I have a bunch of pdf files that I need to process. All the documents are of potentially different dimensions. What I want to do is take a little text block, for instance:

DRAFT
This is a draft document!

I want to take that text block and print it diagonally across the center of every document (ie. from the lower left corner of the page to the upper right corner).

I can some of the way there using BindLogo in Pdf.Kit (using the opacity and angle properties). Here’s what I can’t figure out using that method:

1. How to attach multiple lines of text to my stamp.
2. How to scale the contents of my watermark across the entire page.
3. I guess as part of #2, I also need a way to get the dimensions of the content of my stamp in order to do the scale factor right. Not sure how to get those dimensions.

If there’s a better method than BindLogo to accomplish what I’m going for, than please let me know. I don’t see any demos in Pdf.Kit that seem to do exactly what I want.

Hi Jeff,

You can achieve your goal with the help of the PdfFileInfo, PdfFileStamp, FormattedText and Stamp classes. Please use the following steps to achieve this objective:

1. Create a FormattedText object with multiple lines using AddNewLineText method. See a sample here.
2. Create a Stamp object using BingLogo method and Rotation and Opacity properties. See the following samples:
Add Logo
Rotating stamp about the center point

3. In order to set the origin point of the stamp you can use SetOrigin method of the Stamp class.
4. You can use GetPageHeight and GetPageWidth methods to get the page height and width so you could place the stamp depending upon the page size.
5. Finally, you can add stamp using PdfFileStamp class’ AddStamp method. Please see an example on this link.

I hope this helps. If you have any further questions, please do let us know.
Regards,