/** * This methods adds a new name to the specified NameTree. It throws an exception, if the name already exists. * * @param key key in the name tree * @param value value in the name tree * @param treeType type of the tree (Dests, AP, EmbeddedFiles etc). */ void addNameToNameTree(String key, PdfObject value, PdfName treeType) { getNameTree(treeType).addEntry(key, value); }
private boolean isEqualSameNameDestExist(Map<PdfPage, PdfPage> page2page, PdfDocument toDocument, String srcDestName, PdfArray srcDestArray, PdfPage oldPage) { PdfArray sameNameDest = (PdfArray) toDocument.getCatalog().getNameTree(PdfName.Dests).getNames().get(srcDestName); boolean equalSameNameDestExists = false; if (sameNameDest != null && sameNameDest.getAsDictionary(0) != null) { PdfIndirectReference existingDestPageRef = sameNameDest.getAsDictionary(0).getIndirectReference(); PdfIndirectReference newDestPageRef = page2page.get(oldPage).getPdfObject().getIndirectReference(); if (equalSameNameDestExists = existingDestPageRef.equals(newDestPageRef) && sameNameDest.size() == srcDestArray.size()) { for (int i = 1; i < sameNameDest.size(); ++i) { equalSameNameDestExists = equalSameNameDestExists && sameNameDest.get(i).equals(srcDestArray.get(i)); } } } return equalSameNameDestExists; }
/** * This method returns a complete outline tree of the whole document. * * @param updateOutlines if the flag is true, the method read the whole document and creates outline tree. * If false the method gets cached outline tree (if it was cached via calling getOutlines method before). * @return fully initialized {@link PdfOutline} object. */ PdfOutline getOutlines(boolean updateOutlines) { if (outlines != null && !updateOutlines) return outlines; if (outlines != null) { outlines.clear(); pagesWithOutlines.clear(); } outlineMode = true; PdfNameTree destsTree = getNameTree(PdfName.Dests); PdfDictionary outlineRoot = getPdfObject().getAsDictionary(PdfName.Outlines); if (outlineRoot == null) { if (null == getDocument().getWriter()) { return null; } outlines = new PdfOutline(getDocument()); } else { constructOutlines(outlineRoot, destsTree.getNames()); } return outlines; }
getDocument().getCatalog().getNameTree(PdfName.EmbeddedFiles).addEntry(description, fs.getPdfObject());
page = pdfDocument.getPage(((PdfNumber) pValue).intValue() + 1); // zero-based index is used } else if (pValue instanceof PdfString) { PdfNameTree destsTree = pdfDocument.getCatalog().getNameTree(PdfName.Dests); Map<String, PdfObject> dests = destsTree.getNames(); PdfArray pdfArray = (PdfArray) dests.get(((PdfString) pValue).getValue());
getDocument().getCatalog().getNameTree(PdfName.EmbeddedFiles).addEntry(description, fs.getPdfObject());
if (collection != null && collection.isViewHidden()) { PdfString documentName = collection.getInitialDocument(); PdfNameTree embeddedFiles = getCatalog().getNameTree(PdfName.EmbeddedFiles); String documentNameUnicode = documentName.toUnicodeString(); PdfObject fileSpecObject = embeddedFiles.getNames().get(documentNameUnicode);
PdfArray explicitCmpDest = null; PdfArray explicitOutDest = null; Map<String, PdfObject> cmpNamedDestinations = cmpDocument.getCatalog().getNameTree(PdfName.Dests).getNames(); Map<String, PdfObject> outNamedDestinations = outDocument.getCatalog().getNameTree(PdfName.Dests).getNames(); switch (cmpDestObject.getType()) { case PdfObject.ARRAY:
PdfNameTree destsTree = getNameTree(PdfName.Dests); Map<String, PdfObject> dests = destsTree.getNames(); String srcDestName = dest.isString() ? ((PdfString) dest).toUnicodeString() : ((PdfName) dest).getValue();