Exemplo n.º 1
0
        void IWritable.Write(StreamWriter writer)
        {
            var dict = new GeneralDict("Pages");

            dict.Add("Count", _pages.Count);
            dict.Add("Kids", _pages);
            ((IWritable)dict).Write(writer);
        }
Exemplo n.º 2
0
        void IWritable.Write(StreamWriter writer)
        {
            GeneralDict dict = new GeneralDict("Font");

            dict.Add("Subtype", new Name(Subtype));
            dict.Add("BaseFont", new Name(Name));
            dict.Add("Encoding", new Name(Encoding));
            ((IWritable)dict).Write(writer);
        }
Exemplo n.º 3
0
        private void WriteTrailer(StreamWriter writer, long xrefOffset)
        {
            GeneralDict dict = new GeneralDict();

            dict.Add("Root", _catalogRef);
            dict.Add("Info", _documentInfoRef);
            dict.Add("Size", _references.Count);
            writer.Write("trailer\n");
            ((IWritable)dict).Write(writer);
            writer.Write("startxref\n");
            writer.Write($"{xrefOffset}\n");
            writer.Write("%%EOF\n");
        }
Exemplo n.º 4
0
        void IWritable.Write(StreamWriter writer)
        {
            _contentWriter.Close();

            _dict.Add("Length", _buffer.Length);
            _dict.Add("Filter", new Name("FlateDecode"));
            ((IWritable)_dict).Write(writer);

            writer.Write("stream\r\n");
            writer.Flush();
            _buffer.Seek(0, SeekOrigin.Begin);
            _buffer.CopyTo(writer.BaseStream);
            writer.Write("\r\nendstream\n");

            _contentWriter.Dispose();
            _contentWriter = null;
        }
Exemplo n.º 5
0
        internal Page(Document document, Reference parent, float width, float height)
        {
            _dict = new GeneralDict("Page");
            _dict.Add("Parent", parent);
            _dict.Add("MediaBox", new List <float> {
                0, 0, width, height
            });

            ResourceDict resources    = new ResourceDict(document);
            Reference    resourcesRef = document.CreateReference(resources);

            _dict.Add("Resources", resourcesRef);

            Contents = new ContentStream(resources);
            Reference contentsRef = document.CreateReference(Contents);

            _dict.Add("Contents", contentsRef);
        }
Exemplo n.º 6
0
        public Document(string title)
        {
            _references = new List <Reference>();
            CreateReference(null); // dummy reference with index 0

            GeneralDict catalog = new GeneralDict("Catalog");

            catalog.Add("Version", new Name("1.4"));
            _catalogRef = CreateReference(catalog);

            GeneralDict documentInfo = new GeneralDict();

            _documentInfoRef = CreateReference(documentInfo);
            documentInfo.Add("Title", title);

            _pages    = new PageCollection(this);
            _pagesRef = CreateReference(_pages);
            catalog.Add("Pages", _pagesRef);

            _fontReferences = new Dictionary <Font, Reference>();
        }
Exemplo n.º 7
0
        void IWritable.Write(StreamWriter writer)
        {
            GeneralDict fontDict = new GeneralDict();

            foreach (KeyValuePair <Font, Name> e in _fontNames)
            {
                fontDict.Add(e.Value.Value, _document.GetOrCreateFontReference(e.Key));
            }
            _resources.Add("Font", fontDict);

            (_resources as IWritable).Write(writer);
        }