public ResourceBuilder <T> AddSimpeType1Font(string baseFont, out FontIdentifier identifier) { string name = "F" + _parent.Compositor.FontID.ToString(); identifier = new FontIdentifier { Name = name }; IndirectObject reference = _parent.Compositor.IndirectObject( _parent.Compositor.Dictionary("Font") .Set("Subtype", new NameObject("Type1")) .Set("BaseFont", new NameObject(baseFont)) ); if (_fonts == null) { _fonts = new DictionaryObject(); _me.Set("Font", _fonts); } _fonts.Set(name, reference); _parent.Compositor.FontID += 1; return(this); }
public PageCollectionBuilder(Compositor compositor) { _compositor = compositor; _ref = compositor.IndirectObject(_me = compositor.Dictionary("Pages") .Set("Kids", _kids = new ArrayObject()) .Set("Count", _count = new IntegerNumberObject()) ); }
private Compositor(int generation, int startingID) { _generation = generation; _startID = _id = startingID; _catalogReference = IndirectObject(_catalog = Dictionary("Catalog")); _rootCollection = new PageCollectionBuilder(this); _catalog.Set("Pages", _rootCollection.Reference); FontID = 1; }
private bool WriteObject(StreamObject obj) { if (obj == null) { return(false); } var options = new DictionaryObject() .Set("Length", obj.Length) /* * .Set("Filters", new ArrayObject() * .Add(new NameObject("ASCII85Decode")) * .Add(new NameObject("LZWDecode"))) */ ; WriteObject(options); WriteLine().WriteLine("stream"); /* * StringWriter w = new StringWriter(); * PdfOutput inner = new PdfOutput(w); * inner.WriteStream(obj.Value); * string raw = w.ToString(); * * // byte[] compressed = LZW.Encode(raw); * var lzwByteStream = LZW.ToByteStream(raw); * * w = new StringWriter(); * * Ascii85.Encode(lzwByteStream, w); * * int start = _writer.Position; * _writer.Write(w); * _writer.WriteLine(); * int length = _writer.Position - start; * // */ // /* int start = _writer.Position; WriteStream(obj.Value); int length = _writer.Position - start; // */ Write("endstream"); obj.Length.Get <IntegerNumberObject>().Value = length; return(true); }
public PageBuilder(PageCollectionBuilder parent) { _parent = parent; IndirectObject pageRef = _parent.Compositor.IndirectObject( _dictionary = parent.Compositor.Dictionary("Page") .Set("Parent", parent.Reference) ); parent.Kids.Add(pageRef); _dictionary.Set("Contents", parent.Compositor.StreamObject(_stream = new TextCommandStream())); }
private bool WriteObject(DictionaryObject obj) { if (obj == null) { return(false); } WriteLine("<<").Indent(); foreach (var baseObject in obj.Objects) { WriteIndent(); WriteObject(baseObject.Key); Write(" "); WriteObject(baseObject.Value); WriteLine(); } Outdent().WriteIndent().Write(">>"); return(true); }
public ResourceBuilder(T parent) { _parent = parent; parent.Dictionary.Set("Resources", _me = new DictionaryObject()); }