java - How to read the current page number of the pdf document using pdfbox -


the page numbers in pdf come in different variations, pdfs have initial pages roman numbers i, ii, , later page numbers 1,2,... . found function in pdfbox desired page page.get(pagenumber). problem function when write get(1), returns first page of document (which may numbered ii , not page page number 2). there way obtain page page number in pdf 2 , not second page overall?

section 12.4.2 page labels in pdf specification iso 32000-1:2008 explains how page labels (the special page numbers want understand) defined in document:

each page in pdf document shall identified integer page index expresses page’s relative position within document. in addition, document may optionally define page labels (pdf 1.3) identify each page visually on screen or in print. page labels , page indices need not coincide: indices shall fixed, running consecutively through document starting 0 first page, labels may specified in way appropriate particular document.

for purposes of page labelling, document shall divided labelling ranges, each of series of consecutive pages using same numbering system. pages within range shall numbered sequentially in ascending order. page’s label consists of numeric portion based on position within labelling range, optionally preceded label prefix denoting range itself.

a document’s labelling ranges shall defined pagelabels entry in document catalogue (see 7.7.2, “document catalog”). value of entry shall number tree (7.9.7, “number trees”), each of keys page index of first page in labelling range. corresponding value shall page label dictionary defining labelling characteristics pages in range. tree shall include value page index 0. table 159 shows contents of page label dictionary.

for more details , example cf. specification itself.

using low-level pdfbox methods should easy extract pagelabels entry in document catalogue , retrieve labeling details


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -