/** * Gets all the named destinations as an <CODE>HashMap</CODE>. The key is the name * and the value is the destinations array. * @param keepNames true if you want the keys to be real PdfNames instead of Strings * @return gets all the named destinations * @since 2.1.6 */ public HashMap<Object, PdfObject> getNamedDestination(final boolean keepNames) { HashMap<Object, PdfObject> names = getNamedDestinationFromNames(keepNames); names.putAll(getNamedDestinationFromStrings()); return names; }
/** * Gets all the named destinations as an <CODE>HashMap</CODE>. The key is the name * and the value is the destinations array. * @param keepNames true if you want the keys to be real PdfNames instead of Strings * @return gets all the named destinations * @since 2.1.6 */ public HashMap<Object, PdfObject> getNamedDestination(final boolean keepNames) { HashMap<Object, PdfObject> names = getNamedDestinationFromNames(keepNames); names.putAll(getNamedDestinationFromStrings()); return names; }
public static HashMap<String, String> getNamedDestination(PdfReader reader, boolean fromNames) { IntHashtable pages = new IntHashtable(); int numPages = reader.getNumberOfPages(); for (int k = 1; k <= numPages; ++k) pages.put(reader.getPageOrigRef(k).getNumber(), k); HashMap<String, PdfObject> names = fromNames ? reader.getNamedDestinationFromNames() : reader.getNamedDestinationFromStrings(); HashMap<String, String> n2 = new HashMap<String, String>(names.size()); for (Map.Entry<String, PdfObject> entry: names.entrySet()) { PdfArray arr = (PdfArray)entry.getValue(); StringBuffer s = new StringBuffer(); try { s.append(pages.get(arr.getAsIndirectObject(0).getNumber())); s.append(' ').append(arr.getPdfObject(1).toString().substring(1)); for (int k = 2; k < arr.size(); ++k) s.append(' ').append(arr.getPdfObject(k).toString()); n2.put(entry.getKey(), s.toString()); } catch (Exception e) { } } return n2; }
public static HashMap<String, String> getNamedDestination(PdfReader reader, boolean fromNames) { IntHashtable pages = new IntHashtable(); int numPages = reader.getNumberOfPages(); for (int k = 1; k <= numPages; ++k) pages.put(reader.getPageOrigRef(k).getNumber(), k); HashMap<String, PdfObject> names = fromNames ? reader.getNamedDestinationFromNames() : reader.getNamedDestinationFromStrings(); HashMap<String, String> n2 = new HashMap<String, String>(names.size()); for (Map.Entry<String, PdfObject> entry: names.entrySet()) { PdfArray arr = (PdfArray)entry.getValue(); StringBuffer s = new StringBuffer(); try { s.append(pages.get(arr.getAsIndirectObject(0).getNumber())); s.append(' ').append(arr.getPdfObject(1).toString().substring(1)); for (int k = 2; k < arr.size(); ++k) s.append(' ').append(arr.getPdfObject(k).toString()); n2.put(entry.getKey(), s.toString()); } catch (Exception e) { } } return n2; }