public override string ToString() { // Note: This never adds "N 0 obj" and "endobj". StringBuilder sb = new StringBuilder(); sb.Append("<<\r\n"); // TODO Escape illegal characters in keys foreach (string key in Entries.Keys) { PDFObject value = Entries[key]; sb.Append('/').Append(key).Append(' '); if (value.IsIndirect) { sb.Append(value.ToReferenceString()).Append("\r\n"); } else { sb.Append(value.ToString()).Append("\r\n"); } } sb.Append(">>"); return(sb.ToString()); }
public override string ToString() { // Note: This never adds "N 0 obj" and "endobj". StringBuilder sb = new StringBuilder(); int count = Array.Count; sb.Append("["); for (int i = 0; i < count; i++) { PDFObject item = Array[i]; if (item.IsIndirect) { sb.Append(item.ToReferenceString()); } else { sb.Append(item.ToString()); } if (i + 1 < count) { sb.Append(' '); } } sb.Append("]"); return(sb.ToString()); }
public void Put(string key, PDFObject value) { if (value == null) { throw new Exception($"Value is null for dictionary key '{key}'"); } // Overwrite the old value if the key already exists. // Don't use Add(key, value). It will throw if the key exists. Entries[key] = value; }