protected internal override void Write(PdfWriter writer) { writer.WriteKeyword(Keyword.ArrayBegin); writer.Write(PdfString.ToPdfHexadecimal(null, CreatedPart, writer.TempMemStream)); writer.WriteSpace(); writer.Write(PdfString.ToPdfHexadecimal(null, ModifiedPart, writer.TempMemStream)); writer.WriteKeyword(Keyword.ArrayEnd); }
protected internal override void Write(PdfWriter writer) { writer.WriteKeyword(Keyword.ArrayBegin); writer.Write(PdfString.ToPdfHexadecimal(new byte[] { }, CreatedPart)); writer.WriteSpace(); writer.Write(PdfString.ToPdfHexadecimal(new byte[] { }, ModifiedPart)); writer.WriteKeyword(Keyword.ArrayEnd); }
protected internal override void Write(PdfWriter writer) { Debug.Assert(!IsIndirect, "An object reference cannot be indirect"); writer.Write(refId.ObjectNumber); writer.WriteSpace(); writer.Write(refId.GenerationNumber); writer.WriteSpace(); writer.WriteKeyword(Keyword.R); }
public void Write(PdfObject obj) { Debug.Assert(obj != null); if (obj.IsIndirect || obj is PdfObjectReference) { throw new ArgumentException("Cannot write indirect PdfObject", "obj"); } streamData.Write(obj); }
protected internal override void Write(PdfWriter writer) { byte[] bytes = (byte[])data.Clone(); // Encrypt the data if required. if (!neverEncrypt) { SecurityManager sm = writer.SecurityManager; if (sm != null) { bytes = sm.Encrypt(bytes, writer.EnclosingIndirect.ObjectId); } } // Format as a PDF string. if (format == PdfStringFormat.Literal) { bytes = ToPdfLiteral(encoding.GetPreamble(), bytes); } else { bytes = ToPdfHexadecimal(encoding.GetPreamble(), bytes); } // Finally, write out the bytes. writer.Write(bytes); }
protected internal override void Write(PdfWriter writer) { writer.WriteKeywordLine(Keyword.DictionaryBegin); foreach (DictionaryEntry e in entries) { writer.Write((PdfName)e.Key); writer.WriteSpace(); writer.WriteLine((PdfObject)e.Value); } writer.WriteKeyword(Keyword.DictionaryEnd); }
protected internal void WriteIndirect(PdfWriter writer) { Debug.Assert(writer != null); Debug.Assert(IsIndirect); // Write the object number and generation number // followed by the keyword 'obj' and finally a newline. writer.Write(objectId.ObjectNumber); writer.WriteSpace(); writer.Write(objectId.GenerationNumber); writer.WriteSpace(); writer.WriteKeywordLine(Keyword.Obj); // Write the objects value, subclasses will override this. Write(writer); // Follow the objects value with a newline and then the keyword 'endobj'. writer.WriteLine(); writer.WriteKeyword(Keyword.EndObj); }
/// <summary> /// Writes the cross reference sub-section to the passed PDF writer. /// </summary> internal void Write(PdfWriter writer) { // The format of each cross-reference entry should occupy // exacty 20 ASCII bytes including the newline character. string entryFormat = "{0:0000000000} {1:00000} {2}"; if (writer.NewLine.Length == 1) { // If the newline is configured as only a single character, // then we need to add an extra space to ensure the // resulting entry is always 20 bytes long. entryFormat += " "; } // Sort the entries. entries.Sort(); // Identify the first and last entries. uint first = 0; uint last = ((Entry)entries[entries.Count - 1]).objectId.ObjectNumber; // Work out the number of entries based on the first and last object numbers. uint count = last - first + 1; // Output the first object number and the number of entries. writer.Write(first); writer.WriteSpace(); writer.WriteLine(count); // Output the head of the linked list of free entries. // Right now, this implmentation does not support free // entries properly, so we just output an empty list and // hope that only contingous entries are ever added. byte[] bytes = Encoding.ASCII.GetBytes( String.Format(entryFormat, 0, 65535, "f")); writer.WriteLine(bytes); // Output each entry. foreach (Entry entry in entries) { bytes = Encoding.ASCII.GetBytes( String.Format(entryFormat, entry.offset, entry.objectId.GenerationNumber, "n")); writer.WriteLine(bytes); } }
protected internal override void Write(PdfWriter writer) { PdfDictionary dict = new PdfDictionary(); if (parent == null) { // root Outlines object if (first != null && last != null) { dict.Add(PdfName.Names.First, first.GetReference()); dict.Add(PdfName.Names.Last, last.GetReference()); } } else { dict.Add(PdfName.Names.Title, new PdfString(title)); dict.Add(PdfName.Names.Parent, parent.GetReference()); if (first != null && last != null) { dict.Add(PdfName.Names.First, first.GetReference()); dict.Add(PdfName.Names.Last, last.GetReference()); } if (prev != null) { dict.Add(PdfName.Names.Prev, prev.GetReference()); } if (next != null) { dict.Add(PdfName.Names.Next, next.GetReference()); } if (count > 0) { dict.Add(PdfName.Names.Count, new PdfNumeric(count)); } if (actionRef != null) { dict.Add(PdfName.Names.A, actionRef); } } writer.Write(dict); }
protected internal override void Write(PdfWriter writer) { writer.WriteKeyword(Keyword.ArrayBegin); bool isFirst = true; foreach (PdfObject obj in elements) { if (!isFirst) { writer.WriteSpace(); } else { isFirst = false; } writer.Write(obj); } writer.WriteKeyword(Keyword.ArrayEnd); }
protected internal override void Write(PdfWriter writer) { //write name bytes if (bytes == null) { // Create a memory stream to hold the results. // We guess the size, based on the most likely outcome // (i.e. all ASCII characters with no escapes. MemoryStream ms = writer.TempMemStream; ms.SetLength(0);//clear // The forward slash introduces a name. ms.WriteByte((byte)'/'); // The PDF specification recommends encoding name objects using UTF8. byte[] data = Encoding.UTF8.GetBytes(name); for (int x = 0; x < data.Length; x++) { byte b = data[x]; // The PDF specification recommends using a special #hh syntax // for any bytes that are outside the range 33 to 126 and for // the # character itself (35). if (b < 34 || b > 125 || b == 35) { ms.WriteByte((byte)'#'); ms.WriteByte(HexDigits[b >> 4]); ms.WriteByte(HexDigits[b & 0x0f]); } else { ms.WriteByte(b); } } bytes = ms.ToArray(); ms.SetLength(0);//clear } writer.Write(bytes); }
protected internal override void Write(PdfWriter writer) { writer.Write(NameBytes); }
internal void InnerWrite(string s) { streamData.Write(s_defaultEnc.GetBytes(s)); }