/** * Gets the Outline root in {@link PdfOutline#pdfDoc}'s catalog entry * * @return The {@link PdfDictionary} of the document's Outline root, or {@code null} if it can't be found. */ private PdfDictionary getOutlineRoot() { if (!pdfDoc.hasOutlines()) { return null; } return pdfDoc.getCatalog().getPdfObject().getAsDictionary(PdfName.Outlines); }
if (toDocument.hasOutlines()) { List<PdfOutline> pageOutlines = page.getOutlines(false); if (pageOutlines != null)
if (!pdfDoc.hasOutlines() || isOutlineRoot()) { pdfDoc.getCatalog().remove(PdfName.Outlines); return;
/** * This method merges pages from the source document to the current one. * <br><br> * If <i>closeSourceDocuments</i> flag is set to <i>true</i> (see {@link #setCloseSourceDocuments(boolean)}), * passed {@code PdfDocument} will be closed after pages are merged. * @param from - document, from which pages will be copied. * @param pages - List of numbers of pages which will be copied. * @return this {@code PdfMerger} instance. */ public PdfMerger merge(PdfDocument from, List<Integer> pages) { if (mergeTags && from.isTagged()) { pdfDocument.setTagged(); } if (mergeOutlines && from.hasOutlines()) { pdfDocument.initializeOutlines(); } from.copyPagesTo(pages, pdfDocument); if (closeSrcDocuments) { from.close(); } return this; }
private PdfDocument createPdfDocument(PageRange currentPageRange) { PdfDocument newDocument = new PdfDocument(getNextPdfWriter(currentPageRange), new DocumentProperties().setEventCountingMetaInfo(metaInfo)); if (pdfDocument.isTagged() && preserveTagged) newDocument.setTagged(); if (pdfDocument.hasOutlines() && preserveOutlines) newDocument.initializeOutlines(); return newDocument; }