Esempio 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);
        }
Esempio 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);
        }
Esempio n. 3
0
        internal ContentStream(ResourceDict resources)
        {
            _resources = resources;
            _buffer    = new MemoryStream();
            _buffer.WriteByte(0x78);
            _buffer.WriteByte(0xDA);
            DeflateStream deflateStream = new DeflateStream(_buffer, CompressionMode.Compress, true);

            _contentWriter = new StreamWriter(deflateStream, Document.GetCodepage1252());
            _dict          = new GeneralDict();
        }
        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);
        }
Esempio n. 5
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");
        }
Esempio n. 6
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);
        }
Esempio n. 7
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>();
        }
 internal ResourceDict(Document document)
 {
     _document  = document;
     _resources = new GeneralDict("Resources");
     _fontNames = new Dictionary <Font, Name>();
 }