Esempio n. 1
0
        public static PdfStartXRef Parse(Parsing.Lexer lexer)
        {
            var n = PdfNumeric.Parse(lexer);

            return(new PdfStartXRef(n));
        }
Esempio n. 2
0
 private PdfStartXRef(PdfNumeric value)
     : base(PdfObjectType.StartXRef)
 {
     IsContainer = true;
     Numeric     = value;
 }
Esempio n. 3
0
        public static PdfObject ParseAny(Lexer lexer, string endToken)
        {
            string token = lexer.ReadToken();

            if (token is null)
            {
                return(null);
            }

            switch (token)
            {
            case "null": return(PdfNull.Null);     // null object

            case "true":
            case "false":
                return(PdfBoolean.Parse(token));

            case "/": return(PdfName.Parse(lexer));

            case "%": return(PdfComment.Parse(lexer));

            case "<": return(PdfHexadecimalString.Parse(lexer));

            case "(": return(PdfLiteralString.Parse(lexer));

            case "xref":
                return(PdfXRef.Parse(lexer));

            case "trailer":
                return(PdfTrailer.Parse(lexer));

            case "<<":
                var dic = PdfDictionary.Parse(lexer);

                // check for stream and combine put dictionary into stream object
                token = lexer.PeekToken1();

                if (token == "stream")
                {
                    return(PdfStream.Parse(dic, lexer));
                }

                return(dic);

            case "[": return(PdfArray.Parse(lexer));

            case "startxref":
                return(PdfStartXRef.Parse(lexer));

            case ")":
            case ">":
            case ">>":
            case "]":
            case "}":
            case "stream":
            case "endstream":
            case "endobj":
                if (endToken == token)
                {
                    return(null);    // expected end
                }

                throw new ParsingException("Out of sync");

            default:
                // must be an integer or double value
                PdfNumeric num = PdfNumeric.Parse(token);
                if (num.IsInteger)
                {
                    string token2 = lexer.PeekToken2();
                    switch (token2)
                    {
                    case "obj":
                        return(PdfIndirectObject.Parse(lexer, num.ToInt32()));

                    case "R":
                        PdfIndirectReference ir = PdfIndirectReference.Parse(lexer, num.ToInt32());
                        ir.Resolver = lexer.IndirectReferenceResolver;

                        return(ir);

                    default:
                        // ignore;
                        return(num);
                    }
                }
                else
                {
                    return(num);
                }
            }

            throw new ParsingException("Could not read object");
        }