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

Free Support Forum - aspose.com

Add text to every page of a pdf using C# in Aspose.PDF for .NET

I am looking for a way to add the same text string to the top right hand corner of every page of a pdf where the pdf is made up of various page sizes and orientations.

Is there a way to accomplish this using the Pdf.Kit or another one of your products? Please advise.

Hi Jessi,

If you want to add some text on different sized pages then you’ll have to loop through all the pages and add the text on each page depending upon its size. For example, you may get an idea form this code snippet. In this code snippet, an image stamp is being added on different sized pages, however you can add a text stamp in the same way.

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

I was able to add the text to the top right hand corner of some of my test pdf documents using BindLogo with a Stamp. However, I ran into trouble when I hit a pdf document where the pdf had pages with different rotations. On the pages where the rotation was 90 instead of 0 the text was not visible. I also tried to use AddText with a PdfFileMend object but I ran into the same problem.

Is there a way to set all the page rotations to 0 before I try to add my text?

Here is some more information concerning the pages with the problem:

page rotation = 90

width = 1224

height = 792

When I try to AddText or BindLogo with an x cooridate of anything greater than 792 the text is cut off... almost as if the added text thinks it has hit the end of the page.

Hi Jessi,

Could you please share the sample input PDF file along with the code snippet which you’re using at your end, so we could investigate the issue over here? You’ll be updated with the results the earliest possible.

We’re sorry for the inconvenience.

I've attached a junk PDF with three pages.

The second page has a rotation of 90 degrees. On this page the page width is 612 and the height is 792. If I try to stamp text with a y coordinate greater than 612 the text is cut off even though the page height is actually 792.

- - -

Aspose.Pdf.Kit.PdfFileInfo PdfFileInfo = new Aspose.Pdf.Kit.PdfFileInfo("...test.pdf");

int pagecount = PdfFileInfo.NumberofPages;

Aspose.Pdf.Kit.PdfFileStamp stamper = new Aspose.Pdf.Kit.PdfFileStamp("...test.pdf", "...outputStamp.pdf");

Aspose.Pdf.Kit.FormattedText formText = new Aspose.Pdf.Kit.FormattedText("TEST Text", Color.AntiqueWhite, Color.Red);

float textWidth = formText.TextWidth;

float textHeight = formText.TextHeight;

for (int i = 1; i <= pagecount; i++)


Aspose.Pdf.Kit.Stamp stamp = new Aspose.Pdf.Kit.Stamp();


if (PdfFileInfo.GetPageRotation(i) == 90)


stamp.SetOrigin(PdfFileInfo.GetPageWidth(i) - 10 - textWidth, 610);




stamp.SetOrigin(PdfFileInfo.GetPageWidth(i) - 10 - textWidth, PdfFileInfo.GetPageHeight(i) - 10 - textHeight);


stamp.Pages = new int[] { i };




Sorry. My reply seems to have posted four times... Feel free to delete the repeats. I was not able to do so.

Thanks for your help!

Hi Jessi,

Thank you very much for sharing the PDF and code snippet. I have attached a sample project. Please add the reference to the Aspose.Pdf.Kit DLL in the project. I have also included the output produced at my end.

I have tried to add the text at the top-right corner of every page, whether it is rotated or not. Please see if this is what you want to achieve? Please note that on the second page there is some problem showing the added text; we need to investigate that issue separately once we’re sure about your actual requirement.

Now, if you see at the top-right corner of every page, you’ll find the text; on the second page just try to select the area in the same top right corner and copy the text. Although, it is not visible at the moment, but it is still there. You can paste the text in the notepad.

Please see if this is what you’re trying to achieve? If so, then we’ll have to further investigate that why the text is not showing on the second page. If you think that this is not what you’re trying to achieve then please do let us know.

We’re looking forward to help you out.

Yes, that is exactly what I am trying to achieve… and the results you received match mine. Thank you for looking into this issue for me. Please keep me posted concerning a solution or work around.

Hi Jessi,

Thank you very much for the confirmation. I have logged this issue as PDFKITNET-28722 in our issue tracking system. Our team will look into this issue and you’ll be updated via this forum thread once it is resolved.

We’re sorry for the inconvenience.

Thanks. Would you be able to give me an estimate on when a solution might be available? Is it more likely to be a number of days, weeks or months?

Hi Jessi,

I would like to share with you that our team still needs to investigate this issue in detail. I’m afraid, it is not feasible for us to share the estimate at the moment. It usually, depends upon the complexity of the issue and the fact that how many issues and features are already in the queue.

I have asked our team to share the ETA of this issue. You’ll be updated as soon as the response is received. Please spare us some time for the investigation.

If you have any further questions, please do let us know.

The issues you have found earlier (filed as 28722) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Thank you for getting back to me.

When I click the link above I am directed to Aspose.PDF version 6.2.0. This confuses me a little because the issue concerned an Aspose.PDF.Kit.Stamp... is there a new version of the PDF.Kit too?

Hi Jessi,

In fact, we have merged Aspose.Pdf and Aspose.Pdf.Kit for .NET into a single Aspose.Pdf for .NET component. Aspose.Pdf.Kit for .NET will be discontinued from October 2011. That’s why, we have fixed this issue in the merged version because that’s the one which is going to stay. So, please download Aspose.Pdf for .NET 6.2.0 and try at your end.

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

I'm sorry to take up so much of your time but I'm having trouble updating my code to work with the new version of the Aspose.Pdf dll. The following code worked for me using an older version of the dll but it will not work with the newer version. Is there documentation on how to convert existing code? Aspose.Pdf.Pdf doesn't appear to exist anymore...

Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();

// Bind XML file to PDF and save

pdf.BindXML(xmlDocFilename, null);


I'm also using the following and will need to know how to change them:






Thanks again for your help.

Hi Jessi,

With the merged version, the Aspose.Pdf namespace has been moved under Aspose.Pdf.Generator, while Aspose.Pdf.Kit has been moved under Aspose.Pdf.Facades namespace. Once you change the namespaces, your code will be working fine. You may find the details in this post.

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