Martin Ch
Martin Ch

Reputation: 1367

Page of PDF written in footer

Does anyone an idea how acrobat reader knows the page I am currently viewing? For example - I have a PDF file which contains page numbers in footer in format - 1/A or 1/1 - divided into chapters, and acrobat knows that this is number of page - it doesnt write only total number of pages from beggining to this current page.

I am writing C# apps, WinForms, where I need to get number of page - in the same way as acrobat does. I am converting each page into text with pdfLibView lib, but then, I need look at last page and use complex algorithms to find out which string in footer is page number - it can contain any other informations.

So any idea, how to get page number in format as it is written on this page?

Upvotes: 1

Views: 285

Answers (1)

Bobrovsky
Bobrovsky

Reputation: 14246

It seems like your document uses page labels feature defined in PDF specification.

8.3.1 Page Labels says:

In addition, a document may optionally define page labels (PDF 1.3) to identify each page visually on the screen or in print. Page labels and page indices need not coincide: the indices are fixed, running consecutively through the document starting from 0 for the first page, but the labels can be specified in any way that is appropriate for the particular document. For example, if the document begins with 12 pages of front matter numbered in roman numerals and the remainder of the document is numbered in arabic, the first page would have a page index of 0 and a page label of i, the twelfth page would have index 11 and label xii, and the thirteenth page would have index 12 and label 1.

You might try Docotic.Pdf library if you want to access page labels information in an existing document (disclaimer: I work for the vendor of the library).

Here is a sample for how to add Page Labels to PDF document. This sample doesn't show how to access existing labels but might give some clues for a start.

Upvotes: 1

Related Questions