3
votes

I am following the example to add a footer with the page number to a page “Headers and Footers Example” from the abcpdf documentation site.

The problem is that my pdf document has multiple pages with different orientations and different page sizes.

Mostly the pages are either portrait and A4 or landscape and A3 but there is a possibility the A3 could be in portrait.

Is there a way to easily put the footer in the correct part of the document for each of these pages, particularly given that once the document has been added it doesn’t seem that I am able to tell easily what orientation/page size is being used.

Currently I am building separate documents for each section and setting the orientation and then appending them to a master document.

I need to put the page number in the format "Page X of Y", I am able to get page numbers working correctly if I do it per sub document but I need it for the overall document

1

1 Answers

0
votes

When you read the document / PDF you get access to properties such as pdf width and pdf height. the location to add an object on the header is x: 0, y:0 the footer is simply height of document - height of footer object with again a X of 0.

see this here : http://www.websupergoo.com/helppdf8net/source/2-getting_started/3-coordinates.htm

that's a good example of how to place your rect, inside your rect goes your text i.e Page 2 of 16

http://www.websupergoo.com/helppdf8net/default.htm?page=source%2F2-getting_started%2F3-coordinates.htm

cropbox is the way to get your actual size of the document, and therefore know what coordinates to enter for your rect that contains text.

however you will find it easier if you think in percentage, rather than fixed figures, 10% from the bottom is always 10% no matter what size the document is !!