In Method: | addNames(TreeMap<String,Destination>, HashMap<String,PdfObject>, HashMap<String,PdfObject>, PdfWriter) |
Code with Finding: |
class PdfDocument.PdfCatalog {
/**
* Adds the names of the named destinations to the catalog.
* @param localDestinations the local destinations
* @param documentLevelJS the javascript used in the document
* @param documentFileAttachment the attached files
* @param writer the writer the catalog applies to
*/
void addNames(final TreeMap<String, Destination> localDestinations, final HashMap<String, PdfObject> documentLevelJS, final HashMap<String, PdfObject> documentFileAttachment, final PdfWriter writer) {
if (localDestinations.isEmpty() && documentLevelJS.isEmpty() && documentFileAttachment.isEmpty())
return;
try {
PdfDictionary names = new PdfDictionary();
if (!localDestinations.isEmpty()) {
PdfArray ar = new PdfArray();
for (Map.Entry<String, Destination> entry : localDestinations.entrySet()) {
String name = entry.getKey();
Destination dest = entry.getValue();
if (dest.destination == null) //no destination
continue;
PdfIndirectReference ref = dest.reference;
ar.add(new PdfString(name, null));
ar.add(ref);
}
if (ar.size() > 0) {
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());
}
if (names.size() > 0)
put(PdfName.NAMES, writer.addToBody(names).getIndirectReference());
}
catch (IOException e) {
throw new ExceptionConverter(e);
}
}
}
|