void addNames(TreeMap localDestinations,
HashMap documentLevelJS,
HashMap documentFileAttachment,
PdfWriter writer) {
if (localDestinations.isEmpty() && documentLevelJS.isEmpty() && documentFileAttachment.isEmpty())
return;
try {
PdfDictionary names = new PdfDictionary();
if (!localDestinations.isEmpty()) {
PdfArray ar = new PdfArray();
for (Iterator i = localDestinations.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry) i.next();
String name = (String) entry.getKey();
Object obj[] = (Object[]) entry.getValue();
PdfIndirectReference ref = (PdfIndirectReference)obj[1];
ar.add(new PdfString(name, null));
ar.add(ref);
}
PdfDictionary dests = new PdfDictionary();
dests.put(PdfName.NAMES, ar);
names.put(PdfName.DESTS, writer.addToBody(dests).getIndirectReference());
}
if (!documentLevelJS.isEmpty()) {
PdfDictionary tree = PdfNameTree.writeTree(documentLevelJS, writer);
names.put(PdfName.JAVASCRIPT, writer.addToBody(tree).getIndirectReference());
}
if (!documentFileAttachment.isEmpty()) {
names.put(PdfName.EMBEDDEDFILES, writer.addToBody(PdfNameTree.writeTree(documentFileAttachment, writer)).getIndirectReference());
}
put(PdfName.NAMES, writer.addToBody(names).getIndirectReference());
}
catch (IOException e) {
throw new ExceptionConverter(e);
}
}
Adds the names of the named destinations to the catalog. |