コード例 #1
0
ファイル: PDFContent.cs プロジェクト: klightspeed/PDFParse
        public PDFContent(byte[] data, IPDFDictionary page)
        {
            this.Data    = data;
            this.Options = page.Dict;
            ByteStreamReader reader    = new ByteStreamReader(Data);
            PDFTokenizer     tokenizer = new PDFTokenizer(reader);

            PDFContentTokenStack stack = new PDFContentTokenStack();

            foreach (IPDFToken token in tokenizer)
            {
                stack.ProcessToken(token);
            }

            this.Tokens = stack.Reverse().ToList();
        }
コード例 #2
0
        public static IEnumerable <PDFObject> FromObjStm(PDFStream sobj)
        {
            PDFInteger nobjsv;

            if (sobj.Options.TryGet("N", out nobjsv))
            {
                int           nobjs  = (int)nobjsv.Value;
                PDFObject[]   objs   = new PDFObject[nobjs];
                PDFTokenStack stack  = new PDFTokenStack();
                PDFTokenizer  tokens = new PDFTokenizer(new ByteStreamReader(sobj.Data));

                foreach (IPDFToken token in tokens)
                {
                    stack.ProcessToken(token);
                }

                for (int i = 0; i < nobjs; i++)
                {
                    objs[i] = new PDFObject {
                        Value = stack.Pop <IPDFElement>()
                    };
                }

                for (int i = 0; i < nobjs; i++)
                {
                    int offset = (int)stack.Pop <PDFInteger>().Value;
                    objs[i].ID      = (int)stack.Pop <PDFInteger>().Value;
                    objs[i].Version = 0;
                }

                return(objs);
            }
            else
            {
                return(new PDFObject[0]);
            }
        }