@Test public void fallbackHandlesBrokenDestinations() throws IOException { try (PDDocument document = PDFParser.parse(SeekableSources.inMemorySeekableSourceFrom( getClass().getClassLoader().getResourceAsStream("pdf/page_dests_with_number_insteadof_refs.pdf")))) { for (PDPage current : document.getPages()) { mapping.addLookupEntry(current, new PDPage()); } PDDocumentOutline outline = new PDDocumentOutline(); new OutlineDistiller(document).appendRelevantOutlineTo(outline, mapping); assertTrue(outline.hasChildren()); } }
public void appendRelevantOutlineTo(PDOutlineNode to, LookupTable<PDPage> pagesLookup) { requireNonNull(to, "Unable to merge relevant outline items to a null outline."); if (!pagesLookup.isEmpty()) { ofNullable(document.getDocumentCatalog().getDocumentOutline()).ifPresent(outline -> { for (PDOutlineItem child : outline.children()) { cloneNode(child, pagesLookup).ifPresent(c -> to.addLast(c)); } LOG.debug("Appended relevant outline items"); }); } }
OutlineDistiller { public void appendRelevantOutlineTo(PDOutlineNode to, LookupTable<PDPage> pagesLookup) { requireNonNull(to, "Unable to merge relevant outline items to a null outline."); if (!pagesLookup.isEmpty()) { ofNullable(document.getDocumentCatalog().getDocumentOutline()).ifPresent(outline -> { for (PDOutlineItem child : outline.children()) { cloneNode(child, pagesLookup).ifPresent(c -> to.addLast(c)); } LOG.debug("Appended relevant outline items"); }); } } }
OutlineDistiller { public void appendRelevantOutlineTo(PDOutlineNode to, LookupTable<PDPage> pagesLookup) { requireNonNull(to, "Unable to merge relevant outline items to a null outline."); if (!pagesLookup.isEmpty()) { ofNullable(document.getDocumentCatalog().getDocumentOutline()).ifPresent(outline -> { for (PDOutlineItem child : outline.children()) { cloneNode(child, pagesLookup).ifPresent(c -> to.addLast(c)); } LOG.debug("Appended relevant outline items"); }); } } OutlineDistiller(PDDocument document); }
OutlineDistiller { public void appendRelevantOutlineTo(PDOutlineNode to, LookupTable<PDPage> pagesLookup) { requireNonNull(to, "Unable to merge relevant outline items to a null outline."); if (!pagesLookup.isEmpty()) { ofNullable(document.getDocumentCatalog().getDocumentOutline()).ifPresent(outline -> { for (PDOutlineItem child : outline.children()) { cloneNode(child, pagesLookup).ifPresent(c -> to.addLast(c)); } LOG.debug("Appended relevant outline items"); }); } } OutlineDistiller(PDDocument document); void appendRelevantOutlineTo(PDOutlineNode to, LookupTable<PDPage> pagesLookup); }
OutlineDistiller { public void appendRelevantOutlineTo(PDOutlineNode to, LookupTable<PDPage> pagesLookup) { requireNonNull(to, "Unable to merge relevant outline items to a null outline."); if (!pagesLookup.isEmpty()) { ofNullable(document.getDocumentCatalog().getDocumentOutline()).ifPresent(outline -> { for (PDOutlineItem child : outline.children()) { cloneNode(child, pagesLookup).ifPresent(c -> to.addLast(c)); } LOG.debug("Appended relevant outline items"); }); } } OutlineDistiller(PDDocument document); void appendRelevantOutlineTo(PDOutlineNode to, LookupTable<PDPage> pagesLookup);  }