Dean Krueger wrote: > Hi. > I have a multi page PDF and would like to get the page numbers of each > page. In the PDF spec this is called Page Label. I was wondering if iText > supports the getting of these page numbers. I am looking in the book on > page > 402 it shows that I can change them on documents I create. But doesn't seem > to mention if I can get the page numbers from previously created documents. > > Any help would be great!
OK, I made a little bonus example for chapter 13 using the PDF file that is shown on page 402: http://itext.ugent.be/itext-in-action/chapter.php?chapter=13#bonus This examples uses objects and methods explained in chapter 18, and you'll also need page 595-596 of the PDF Reference to understand what it's about. When you run the example http://itext.ugent.be/itext-in-action/examples/chapterX/ExtractPageLabels.java some information about the page labels is written to the System.out. Let's go over this output: Starting from page 1 the page labels are defined like this: /S: /r The PageLabels entry in the PDF catalog contains a number tree. In this tree, the number 0 (referring to page 1) has a PDF dictionary as value. This dictionary has one entry: /S (for style) is /r (for lowercase roman numberals). The next item in the number tree is: Starting from page 5 the page labels are defined like this: /S: /D Based on this information, we know that the first four pages will be i, ii, iii, iv, but starting on page 5, we'll switch to decimal arabic numbers: 1, 2, 3 (every time you switch the style, the page number starts with 1, I, i, A, or a). Possible styles are: /D decimal arabic numbers /R uppercase roman numbers /r lowercase roman numbers /A uppercase letters /a lowercase letters Starting from page 8 the page labels are defined like this: /St: 8 /P: A- /S: /D OK, this needs some extra explanation: if you don't want the page labels to start from 1, I, i, A, or a, you can define a Start page number. In this case: 8. You can also add a text string (entry /P), in this case "A-", so starting on page 8, we'll have: A-8 A-9 A-10 ... And that's exactly what you can see on page 402. Hope this helps, Bruno ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
