Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
add page numbers to existing PDF |
Post Reply |
Author | |
edvoigt
Senior Member Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
Post Options
Thanks(0)
Posted: 11 Jan 12 at 1:48PM |
Hi,
Andrew is right. If you don't want that your pagenumber is drawn with the last on the page used font, size and color, you should set it inside the loop. I see no easy way, to embrace the old content of the pages with SaveState and LoadState to prevent your settings for changes. Werner |
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
I believe you need to do this for each page with the drawing commands.
SetTextColor(1,0,0); // will set the text color to red. NOTE : Each colour component has a range of 0.0 to 1.0 and not 0 to 255 like many other libraries. Andrew.
|
|
jon_bondy
Beginner Joined: 10 Jan 12 Location: vermont Status: Offline Points: 2 |
Post Options
Thanks(0)
|
Andrew - Exactly what I was looking for!
Would it also work if the fonts were selected and sized outside of the loop, or must this be done on a per-page basis? In my code I set the text and fill colors, but those changes never took affect: everything appears in black. |
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
Here is some simple C# code that will add page numbers to each page. To do this properly you should follow some of Ingo's advice as well. You can also check the "Quick PDF Library 8 Developer Guide.pdf" file that is installed with QuickPDF. This has lots of sample code examples. Another option to learn is to read through the FAQ at http://www.quickpdflibrary.com/faq/index.php QP.LoadFromFile("file.pdf"); int id = QP.AddStandardFont(4); for (int i=1;i<=QP.PageCount();i++) { QP.SelectPage(i); QP.NormalizePage(0); QP.SetOrigin(1); QP.SelectFont(id); QP.SetTextSize(12); double ph = QP.PageWidth(); double pw = QP.PaheHeight(); QP.DrawText(pw - 30, ph - 20, "Page" + i.ToString(); } QP.SaveToFile("newfile.pdf");
|
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi Jon!
Use the search function on the top right: http://www.quickpdf.org/forum/delete-object_topic2025_post8611.html?KW=page+numbers#8611 Check the draw-functionalities in the online reference. There's not a ready made function doing this. Check the page dimensions. Check the length of your page number string. Don't forget to use SetOrigin. Do some calculations where start drawing. Set font, height, colour ... Paint the top or bottom area in white to hide older/other numbers you don't want. Draw your page number strings on each page. This is the sample you can change with less efforts
for your needs:
http://www.quickpdflibrary.com/faq/how-to-add-a-header-comprising-of-a-logo-and-a-passed-text-to-each-page-of-an-exi.php Cheers and welcome here, Ingo Edited by Ingo - 11 Jan 12 at 7:30AM |
|
jon_bondy
Beginner Joined: 10 Jan 12 Location: vermont Status: Offline Points: 2 |
Post Options
Thanks(0)
|
The documentation for this product is simply amazing, but I find myself unable to do the simple things! I want to open an existing PDF and write page numbers on each page. Is there an example showing how to access the pages in a PDF after it is opened?
Thank you! Jon
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store