PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

Inserting page numbers on an existing pdf
http://forum.pdfsharp.de/viewtopic.php?f=2&t=805
Page 1 of 1

Author:  researcher [ Sat Jul 25, 2009 9:21 pm ]
Post subject:  Inserting page numbers on an existing pdf

Hi. Really impressed with PDFSharp and have managed to get it to do what I want (merging pdf files together) but I can't figure out how to work with MigraDoc to number pages. I am using VB.Net

I found the code to number pages at viewtopic.php?p=1712#p1712

Code:
Dim style As Style
        pdfDocument = New Document()
       
        [.......]

        Dim section As Section
        Dim r As Row
        Dim c As Column

        section = pdfDocument.AddSection()

        [...........]

        'Aggiungo il numero di pagina in basso a destra
        p = New Paragraph()
        p.AddText("Pag. ")
        p.AddPageField()
        p.AddText(" di ")
        p.AddNumPagesField()
        p.Format.Alignment = ParagraphAlignment.Right
        section.Footers.Primary.Add(p)


And I want to number pages on an existing PDF.

I have:

Code:
For Each page As PdfPage In readDocument.Pages
        document.AddPage(page)
Next page


and I'd like to number each page in that For/Next routine. How do I pass the page to MigraDoc and number it?

Thanks.

Author:  Thomas Hoevel [ Mon Jul 27, 2009 9:11 am ]
Post subject:  Re: Inserting page numbers on an existing pdf

MigraDoc can only create new PDF documents.

The TwoPagesOnOne sample shows how to add page numbers (using PDFsharp).

Author:  researcher [ Mon Jul 27, 2009 10:03 am ]
Post subject:  Re: Inserting page numbers on an existing pdf

Thanks for the reply.

Yes, have found out how to do it using DrawString and it works!

Author:  researcher [ Tue Jul 28, 2009 1:19 pm ]
Post subject:  Re: Inserting page numbers on an existing pdf

I was also wondering if it is possible to set the page number property of a page within a PDF document?

Not adding the physical text (have done that and it works perfectly) but the number of the page as used to navigate the PDF document?

With Acrobat, you can use the 'Number Pages' option. Specifically, I want the first few pages to be numbered i,ii, iii, etc and then the rest to be 1 to whatever so that the page numbers recognized in Adobe Reader match the physical pages numbers. Basically so somebody can use Adobe Reader to jump to page 1 even if it is physically the fourth page of the PDF document e.g., Acrobat shows "1 (4 of 168)" in its page navigation tab.

Thanks, and again PDFSharp is really impressive. Well done!

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/