/// <summary> /// Write Pdf object to Pdf writer /// </summary> /// <param name="writer">Pdf Writer</param> public override void ToPdf(PdfWriter writer) { if (this.items.Count > 0) { for (int i = 0; i < this.items.Count; i++) { PdfOutlineItem item = this.items[i]; item.Parent = this; int num2 = i + 1; item.BakTitle = ((int)num2).ToString(); if (i > 0) { item.Prev = this.items[i - 1]; } if (i < (this.items.Count - 1)) { item.Next = this.items[i + 1]; } writer.WriteObject(item, false); } base[PdfName.First] = this.items[0]; base[PdfName.Last] = this.items[this.items.Count - 1]; base[PdfName.Count] = new PdfNumber((double)this.items.Count); } base.ToPdf(writer); }
/// <summary> /// Write Pdf object to Pdf writer /// </summary> /// <param name="writer">Pdf Writer</param> public override void ToPdf(PdfWriter writer) { if (this.childItems.Count > 0) { for (int i = 0; i < this.childItems.Count; i++) { PdfOutlineItem item = this.childItems[i]; item.Parent = this; item.BakTitle = this.bakTitle + "." + ((int)(i + 1)); if (i > 0) { item.Prev = this.childItems[i - 1]; } if (i < (this.childItems.Count - 1)) { item.Next = this.childItems[i + 1]; } writer.WriteObject(item, false); } base[PdfName.First] = this.childItems[0]; base[PdfName.Last] = this.childItems[this.childItems.Count - 1]; base[PdfName.Count] = new PdfNumber((double)this.childItems.Count); } if (string.IsNullOrEmpty(this.title)) { base[PdfName.Title] = new PdfString("Bookmark " + this.bakTitle); } else { base[PdfName.Title] = new PdfString(this.title); } base[PdfName.Parent] = this.parent; if (this.prev != null) { base[PdfName.Prev] = this.prev; } if (this.next != null) { base[PdfName.Next] = this.next; } if (this.dest.TargetPage != null) { base[PdfName.Dest] = this.dest; } base.ToPdf(writer); }
/// <summary> /// Scans the page tree and create outline. /// </summary> /// <param name="pages">The pages.</param> /// <param name="outline">The outline.</param> private void ScanPageTreeAndCreateOutline(PdfPageTree pages, PdfOutlineItem outline) { List <PdfOutlineItem> list = (outline == null) ? this.outlines.Items : outline.ChildItems; foreach (PdfObjectBase base2 in pages.Kids) { if (base2 is PdfPage) { list.Add(new PdfOutlineItem((PdfPage)base2)); } else { PdfOutlineItem item = new PdfOutlineItem(); list.Add(item); this.ScanPageTreeAndCreateOutline((PdfPageTree)base2, item); } } }