internal void AddNames(SortedDictionary<string,Destination> localDestinations, Dictionary<String, PdfObject> documentLevelJS, Dictionary<String, PdfObject> documentFileAttachment, PdfWriter writer)
{
if (localDestinations.Count == 0 && documentLevelJS.Count == 0 && documentFileAttachment.Count == 0)
return;
PdfDictionary names = new PdfDictionary();
if (localDestinations.Count > 0) {
PdfArray ar = new PdfArray();
foreach (String name in localDestinations.Keys) {
Destination dest;
if (!localDestinations.TryGetValue(name, out dest))
continue;
PdfIndirectReference refi = dest.reference;
ar.Add(new PdfString(name, null));
ar.Add(refi);
}
if (ar.Size > 0) {
PdfDictionary dests = new PdfDictionary();
dests.Put(PdfName.NAMES, ar);
names.Put(PdfName.DESTS, writer.AddToBody(dests).IndirectReference);
}
}
if (documentLevelJS.Count > 0) {
PdfDictionary tree = PdfNameTree.WriteTree(documentLevelJS, writer);
names.Put(PdfName.JAVASCRIPT, writer.AddToBody(tree).IndirectReference);
}
if (documentFileAttachment.Count > 0) {
names.Put(PdfName.EMBEDDEDFILES, writer.AddToBody(PdfNameTree.WriteTree(documentFileAttachment, writer)).IndirectReference);
}
if (names.Size > 0)
Put(PdfName.NAMES, writer.AddToBody(names).IndirectReference);
}