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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - add page numbers to existing PDF
  FAQ FAQ  Forum Search   Register Register  Login Login

add page numbers to existing PDF

 Post Reply Post Reply
Author
Message Reverse Sort Order
edvoigt View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Mar 11
Location: Berlin, Germany
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote edvoigt Quote  Post ReplyReply Direct Link To This Post Topic: add page numbers to existing PDF
    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
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jan 12 at 1:13PM
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.
Back to Top
jon_bondy View Drop Down
Beginner
Beginner


Joined: 10 Jan 12
Location: vermont
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote jon_bondy Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jan 12 at 12:33PM
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.
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jan 12 at 10:42AM
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");
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 10 Jan 12 at 10:54PM
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:


Edited by Ingo - 11 Jan 12 at 7:30AM
Back to Top
jon_bondy View Drop Down
Beginner
Beginner


Joined: 10 Jan 12
Location: vermont
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote jon_bondy Quote  Post ReplyReply Direct Link To This Post Posted: 10 Jan 12 at 10:16PM
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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store