/** * Adds the local destinations to the body of the document. * @param dest the <CODE>Hashtable</CODE> containing the destinations * @throws IOException on error */ internal void AddLocalDestinations(OrderedTree dest) { foreach (String name in dest.Keys) { Object[] obj = (Object[])dest[name]; PdfDestination destination = (PdfDestination)obj[2]; if (destination == null) throw new Exception("The name '" + name + "' has no local destination."); if (obj[1] == null) obj[1] = PdfIndirectReference; AddToBody(destination, (PdfIndirectReference)obj[1]); } }
// constructors /** * Constructs a new <CODE>PdfBody</CODE>. * @param writer */ internal PdfBody(PdfWriter writer) { xrefs = new OrderedTree(); xrefs[new PdfCrossReference(0, 0, GENERATION_MAX)] = null; position = writer.Os.Counter; refnum = 1; this.writer = writer; }
/** * Adds the names of the named destinations to the catalog. * @param localDestinations the local destinations * @param documentJavaScript the javascript used in the document * @param writer the writer the catalog applies to */ internal void AddNames(OrderedTree localDestinations, Hashtable documentLevelJS, Hashtable 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) { Object[] obj = (Object[])localDestinations[name]; if (obj[2] == null) //no destination continue; PdfIndirectReference refi = (PdfIndirectReference)obj[1]; 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); }