@Test public void noOutlineFlat() throws IOException { try (PDDocument doc = PDFParser.parse(SeekableSources .inMemorySeekableSourceFrom(getClass().getResourceAsStream("/pdf/test_no_outline.pdf")))) { assertTrue(OutlineUtils.getFlatOutline(doc).isEmpty()); } }
public static List<OutlineItem> getFlatOutline(PDDocument document) { return ofNullable(document.getDocumentCatalog().getDocumentOutline()).map(PDDocumentOutline::children) .map(c -> recurseFlatOutline(document, c, 1)).orElseGet(ArrayList::new).stream() .sorted(Comparator.comparingInt(i -> i.page)).filter(i -> i.page > 0).collect(Collectors.toList()); }
OutlineUtils { public static List<OutlineItem> getFlatOutline(PDDocument document) { return ofNullable(document.getDocumentCatalog().getDocumentOutline()).map(PDDocumentOutline::children) .map(c -> recurseFlatOutline(document, c, 1)).orElseGet(ArrayList::new).stream() .sorted(Comparator.comparingInt(i -> i.page)).filter(i -> i.page > 0).collect(Collectors.toList()); } }
OutlineUtils { public static List<OutlineItem> getFlatOutline(PDDocument document) { return ofNullable(document.getDocumentCatalog().getDocumentOutline()).map(PDDocumentOutline::children) .map(c -> recurseFlatOutline(document, c, 1)).orElseGet(ArrayList::new).stream() .sorted(Comparator.comparingInt(i -> i.page)).filter(i -> i.page > 0).collect(Collectors.toList()); } private  OutlineUtils(); }
OutlineUtils { public static List<OutlineItem> getFlatOutline(PDDocument document) { return ofNullable(document.getDocumentCatalog().getDocumentOutline()).map(PDDocumentOutline::children) .map(c -> recurseFlatOutline(document, c, 1)).orElseGet(ArrayList::new).stream() .sorted(Comparator.comparingInt(i -> i.page)).filter(i -> i.page > 0).collect(Collectors.toList()); } private  OutlineUtils(); static Set<Integer> getOutlineLevelsWithPageDestination(PDDocument document); static Optional<PDPageDestination> toPageDestination(PDOutlineItem current, PDDocumentCatalog catalog); static PDPageXYZDestination pageDestinationFor(PDPage page); static PDPageDestination clonePageDestination(PDPageDestination dest, PDPage destPage); static PDPage resolvePageDestination(PDPageDestination destination, PDDocument document); static void copyOutlineDictionary(PDOutlineItem from, PDOutlineItem to); static List<OutlineItem> getFlatOutline(PDDocument document); static void printOutline(PDDocument document); }
OutlineUtils { public static List<OutlineItem> getFlatOutline(PDDocument document) { return ofNullable(document.getDocumentCatalog().getDocumentOutline()).map(PDDocumentOutline::children) .map(c -> recurseFlatOutline(document, c, 1)).orElseGet(ArrayList::new).stream() .sorted(Comparator.comparingInt(i -> i.page)).filter(i -> i.page > 0).collect(Collectors.toList()); } private  OutlineUtils(); static Set<Integer> getOutlineLevelsWithPageDestination(PDDocument document); static Optional<PDPageDestination> toPageDestination(PDOutlineItem current, PDDocumentCatalog catalog); static PDPageXYZDestination pageDestinationFor(PDPage page); static PDPageDestination clonePageDestination(PDPageDestination dest, PDPage destPage); static PDPage resolvePageDestination(PDPageDestination destination, PDDocument document); static void copyOutlineDictionary(PDOutlineItem from, PDOutlineItem to); static List<OutlineItem> getFlatOutline(PDDocument document); static void printOutline(PDDocument document);  }