Beispiel #1
0
        public void Test_References()
        {
            const string raw = "1 0 obj\n25\nendobj\n2 0 obj\n1 0 R\nendobj";
            var stream = new MemoryStream(Encoding.ASCII.GetBytes(raw));
            var reader = new BodyReader(stream, null);
            var body = reader.Read();

            var obj = body.GetIndirectObject(2, 0) as ReferenceObject;
            Assert.IsNotNull(obj);
            Assert.AreEqual(25, ((IntegerObject) obj.Value).Value);

            stream.Dispose();
        }
Beispiel #2
0
        public void Test_StreamReaderWithLengthInReference()
        {
            const string raw = "1 0 obj\n2\nendobj\n2 0 obj\n<</Length 1 0 R>>\nstream\r\nHi\r\nendstream\r\nendobj";
            var stream = new MemoryStream(Encoding.ASCII.GetBytes(raw));
            var reader = new BodyReader(stream, null);
            var body = reader.Read();

            var obj = body.GetIndirectObject(2, 0) as StreamObject;
            Assert.IsNotNull(obj);
            var streamContents = Encoding.ASCII.GetString(obj.Value);
            Assert.AreEqual("Hi", streamContents);

            stream.Dispose();
        }
Beispiel #3
0
        public void Test_SimpleRead()
        {
            const string raw = "1 0 obj\n1\nendobj\n2 0 obj\n(test)\nendobj\n\n";
            var stream = new MemoryStream(Encoding.ASCII.GetBytes(raw));
            var reader = new BodyReader(stream, null);
            var body = reader.Read();

            var obj = body.GetIndirectObject(1, 0);
            Assert.IsNotNull(obj);
            Assert.AreEqual(1u, obj.Number);
            Assert.AreEqual(0u, obj.Generation);
            Assert.AreEqual(1, ((IntegerObject) obj).Value);

            obj = body.GetIndirectObject(2, 0);
            Assert.IsNotNull(obj);
            Assert.AreEqual(2u, obj.Number);
            Assert.AreEqual(0u, obj.Generation);
            Assert.AreEqual("test", ((StringObject) obj).Value);

            stream.Dispose();
        }