PDDocumentCatalog implements COSObjectable { public PDPageLabels getPageLabels() throws IOException { COSDictionary dict = (COSDictionary) root.getDictionaryObject(COSName.PAGE_LABELS); return dict == null ? null : new PDPageLabels(document, dict); } PDDocumentCatalog(PDDocument doc);  PDDocumentCatalog(PDDocument doc, COSDictionary rootDictionary); COSDictionary getCOSObject(); PDAcroForm getAcroForm(); void setAcroForm(PDAcroForm acroForm); PDPageTree getPages(); PDViewerPreferences getViewerPreferences(); void setViewerPreferences(PDViewerPreferences prefs); PDDocumentOutline getDocumentOutline(); void setDocumentOutline(PDDocumentOutline outlines); List<PDThread> getThreads(); void setThreads(List threads); PDMetadata getMetadata(); void setMetadata(PDMetadata meta); void setOpenAction(PDDestinationOrAction action); PDDestinationOrAction getOpenAction(); PDDocumentCatalogAdditionalActions getActions(); void setActions(PDDocumentCatalogAdditionalActions actions); PDDocumentNameDictionary getNames(); PDDocumentNameDestinationDictionary getDests(); void setNames(PDDocumentNameDictionary names); PDMarkInfo getMarkInfo(); void setMarkInfo(PDMarkInfo markInfo); List<PDOutputIntent> getOutputIntents(); void addOutputIntent(PDOutputIntent outputIntent); void setOutputIntents(List<PDOutputIntent> outputIntents); PageMode getPageMode(); void setPageMode(PageMode mode); PageLayout getPageLayout(); void setPageLayout(PageLayout layout); PDURIDictionary getURI(); void setURI(PDURIDictionary uri); PDStructureTreeRoot getStructureTreeRoot(); void setStructureTreeRoot(PDStructureTreeRoot treeRoot); String getLanguage(); void setLanguage(String language); String getVersion(); void setVersion(String version); PDPageLabels getPageLabels(); void setPageLabels(PDPageLabels labels); PDOptionalContentProperties getOCProperties(); void setOCProperties(PDOptionalContentProperties ocProperties);  }
@Test public void retrievePageLabels() throws IOException { PDDocument doc = null; try { doc = PDDocument.load(TestPDDocumentCatalog.class.getResourceAsStream("/pdfbox/com/tom_roush/pdfbox/pdmodel/test_pagelabels.pdf")); PDDocumentCatalog cat = doc.getDocumentCatalog(); String[] labels = cat.getPageLabels().getLabelsByPageIndices(); assertEquals(12, labels.length); assertEquals("A1", labels[0]); assertEquals("A2", labels[1]); assertEquals("A3", labels[2]); assertEquals("i", labels[3]); assertEquals("ii", labels[4]); assertEquals("iii", labels[5]); assertEquals("iv", labels[6]); assertEquals("v", labels[7]); assertEquals("vi", labels[8]); assertEquals("vii", labels[9]); assertEquals("Appendix I", labels[10]); assertEquals("Appendix II", labels[11]); } finally { if(doc != null) { doc.close(); } } }
@Test public void retrievePageLabelsOnMalformedPdf() throws IOException { PDDocument doc = null; try { doc = PDDocument.load(TestPDDocumentCatalog.class.getResourceAsStream("/pdfbox/com/tom_roush/pdfbox/pdmodel/badpagelabels.pdf")); PDDocumentCatalog cat = doc.getDocumentCatalog(); cat.getPageLabels().getLabelsByPageIndices(); } finally { if(doc != null) { doc.close(); } } }