/// <summary> /// Toes the PDF. /// </summary> /// <param name="writer">The writer.</param> public void ToPdf(PdfWriter writer) { PdfArray array2 = new PdfArray(); PdfString item = new PdfString(Guid.NewGuid().ToString()) { IsHexMode = true }; array2.Add(item); PdfString str2 = new PdfString(Guid.NewGuid().ToString()) { IsHexMode = true }; array2.Add(str2); PdfArray array = array2; this.dic[PdfName.ID] = array; PdfStreamWriter psw = writer.Psw; psw.WriteLineEnd(); psw.WriteBytes(trailer).WriteLineEnd(); writer.WriteObject(this.dic); psw.WriteLineEnd(); psw.WriteBytes(startxref).WriteLineEnd(); psw.WriteInt(this.Offset).WriteLineEnd(); psw.WriteBytes(eof).WriteLineEnd(); }
/// <summary> /// Write Pdf object to Pdf writer /// </summary> /// <param name="writer">Pdf Writer</param> public override void ToPdf(PdfWriter writer) { MemoryStream data = this.data; if ((this.filters != null) && (this.filters.Count > 0)) { data = new MemoryStream(); this.data.WriteTo(data); PdfArray array = new PdfArray(); while (this.filters.Count > 0) { using (MemoryStream stream2 = new MemoryStream()) { data.Seek(0L, SeekOrigin.Begin); data.WriteTo(stream2); stream2.Seek(0L, SeekOrigin.Begin); data.Dispose(); data.Dispose(); data = new MemoryStream(); PdfFilter filter = this.filters.Dequeue(); filter.Encode(stream2, data, null); array.Insert(0, filter.GetName()); continue; } } if (array.Count == 1) { this.properties.Add(PdfName.Filter, array[0]); } else { this.properties.Add(PdfName.Filter, array); } } this.properties[PdfName.Length] = new PdfNumber((double)data.Length); PdfStreamWriter psw = writer.Psw; this.properties.ToPdf(writer); psw.WriteLineEnd(); psw.WriteBytes(streamPrefix).WriteLineEnd(); data.WriteTo(psw.Stream); psw.WriteLineEnd().WriteBytes(streamSuffix); psw.WriteLineEnd(); if (data != this.data) { data.Dispose(); } }
/// <summary> /// Toes the PDF. /// </summary> /// <param name="writer">The writer.</param> public void ToPdf(PdfWriter writer) { this.ValidateEntries(); base.Sort(); PdfStreamWriter psw = writer.Psw; psw.WriteLineEnd(); psw.WriteBytes(xref).WriteLineEnd(); int index = 0; int count = 1; int num3 = 1; while (num3 < base.Count) { if ((base[index].ObjectIndex + count) != base[num3].ObjectIndex) { this.WriteCrossBlock(index, count, psw); index = num3; count = 0; } num3++; count++; } this.WriteCrossBlock(index, count, psw); }
/// <summary> /// Writes the cross block. /// </summary> /// <param name="index">The index.</param> /// <param name="count">The count.</param> /// <param name="psw">The PSW.</param> private void WriteCrossBlock(int index, int count, PdfStreamWriter psw) { psw.WriteInt(base[index].ObjectIndex).WriteSpace().WriteInt(count); for (int i = index; i < count; i++) { psw.WriteLineEnd(); psw.WriteString(((long)base[i].Offset).ToString("0000000000", CultureInfo.InvariantCulture.NumberFormat)); psw.WriteSpace(); psw.WriteString(((int)base[i].Generation).ToString("00000", CultureInfo.InvariantCulture.NumberFormat)); psw.WriteSpace(); psw.WriteByte(base[i].InUse ? nf[0] : nf[1]); } }