예제 #1
0
        protected virtual IPDFToken ProcessKeyword(PDFKeyword token)
        {
            switch (token.Name)
            {
            case "true": return(new PDFBoolean {
                    Value = true
                });

            case "false": return(new PDFBoolean {
                    Value = false
                });

            case "null": return(new PDFNull());

            case "obj": return(new PDFToken(PDFTokenType.StartObject));

            case "xref": return(new PDFToken(PDFTokenType.Xref));

            case "startxref": return(new PDFToken(PDFTokenType.StartXref));

            case "endobj": return(PDFObject.Parse(this));

            case "trailer": return(PDFXref.Parse(this));

            case "n": return(PDFXrefEntry.Parse(this, PDFTokenType.XrefEntryInUse));

            case "f": return(PDFXrefEntry.Parse(this, PDFTokenType.XrefEntryFree));

            case "R": return(PDFObjRef.Parse(this));

            default: throw new InvalidDataException(String.Format("Unknown keyword '{0}'", token.Name));
            }
        }
예제 #2
0
        public static PDFObject Parse(Stack <IPDFToken> tokens)
        {
            PDFObject obj = new PDFObject();

            obj.Value = tokens.TryPop <IPDFElement>();

            tokens.Pop(PDFTokenType.StartObject);

            obj.Version = (int)tokens.Pop <PDFInteger>().Value;
            obj.ID      = (int)tokens.Pop <PDFInteger>().Value;

            return(obj);
        }
예제 #3
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]);
            }
        }
예제 #4
0
 public PDFObject AddRef(PDFObject parent)
 {
     this.RefCount++;
     this.ReferencedBy.Add(parent);
     return(this);
 }