/// <summary>
        /// Finish the pdf document
        /// </summary>
        public void Finish()
        {
            foreach (PdfDirectObject obj in objects)
            {
                if (obj.HaveToWrite)
                {
                    obj.Write(this, baseStream.Position);
                }
            }

            long xrefPos = baseStream.Position;

            WriteLn("xref");
            Write("0 "); WriteLn(objects.Count + 1);
            WriteLn("0000000000 65535 f");
            foreach (PdfDirectObject obj in objects)
            {
                Write(PrepXRefPos(obj.Offset));
                WriteLn(" 00000 n");
            }

            trailer["Size"] = new PdfNumeric(objects.Count + 1);
            trailer["ID"]   = new PdfTrailerId();

            WriteLn("trailer");
            trailer.Write(this);
            WriteLn();
            WriteLn("startxref");
            WriteLn(xrefPos);
            WriteLn("%%EOF");
        }
Esempio n. 2
0
 /// <summary>
 /// Initialize a new instance
 /// </summary>
 public PdfImage()
 {
     Compress                 = false;
     this["Type"]             = new PdfName("XObject");
     this["Subtype"]          = new PdfName("Image");
     this["ColorSpace"]       = new PdfName("DeviceRGB");
     this["BitsPerComponent"] = new PdfNumeric(8);
     this["Filter"]           = new PdfName("DCTDecode");
     this["Interpolate"]      = new PdfBoolean(true);
 }
Esempio n. 3
0
        internal void ParseDocument()
        {
            _doc.Version = ParseHeader();

            _lexer.SeekToXref();

            _lexer.Next();

            bool streamXref = false;

            if (Accept(TokenType.Xref))
            {
                _doc.Xref = new XrefObject(ParseXref());

                // ParseXref overreads, so no need to _lexer.Next() here
                Expect(TokenType.Trailer);

                _lexer.Next();
                Expect(TokenType.Dict);
                _doc.Trailer = new Trailer(ParseDictionary());

                if (_doc.Trailer.ContainsKey("/XRefStm"))
                {
                    streamXref = true;
                    PdfNumeric offset = _doc.Trailer["/XRefStm"] as PdfNumeric;
                    _lexer.Seek(offset);
                    _lexer.Next();
                }
            }
            else if (IsIndirectObjectDefinition())
            {
                streamXref = true;
            }
            else
            {
                throw new ParserException("No cross-reference table found");
            }

            if (streamXref)
            {
                _doc.Xref    = ParseIndirectObjectDefinition(null).Object as XrefObject;
                _doc.Trailer = new Trailer((_doc.Xref as IPdfTypedObject).Dict);
            }

            // Load all the indirect objects. If they are out of order then PdfDocument reference handling will lazy load dependents
            foreach (PdfCrossReference obj in _doc.GetObjects())
            {
                ParseIndirectObjectDefinition(obj);
            }
        }
Esempio n. 4
0
 internal PdfRotate(PdfNumeric value)
     : base(PdfObjectType.Rotate)
 {
     Value = value.ToInt32();
 }
Esempio n. 5
0
 public void ToInt32Tests()
 {
     Assert.Equal(1, PdfNumeric.Parse("1").ToInt32());
     Assert.Equal(1000, PdfNumeric.Parse("1000").ToInt32());
 }
Esempio n. 6
0
 public void IsIntergerTests()
 {
     Assert.True(PdfNumeric.Parse("1").IsInteger);
 }
Esempio n. 7
0
 public void IsRealTests()
 {
     Assert.True(PdfNumeric.Parse("1.1").IsReal);
 }
Esempio n. 8
0
 public void CanCastImplictlyToDouble()
 {
     Assert.Equal(1.1d, PdfNumeric.Parse("1.1"));
     Assert.Equal(1000d, PdfNumeric.Parse("1000"));
 }
Esempio n. 9
0
 public PdfCount(PdfNumeric count)
     : base(PdfObjectType.Count)
 {
     Value = count.ToInt32();
 }
Esempio n. 10
0
 internal PdfRotate(PdfNumeric value)
     : base(PdfObjectType.Rotate)
 {
     Value = Convert.ToInt32(value.Value);
 }
Esempio n. 11
0
 /// <summary>
 /// Write this object to stream
 /// </summary>
 /// <param name="writer"></param>
 public override void Write(PdfWriter writer)
 {
     this["Count"] = new PdfNumeric(kids.Count);
     base.Write(writer);
 }