Esempio n. 1
0
        public IPDFToken Parse(Stack <IPDFToken> stack)
        {
            switch (TokenType)
            {
            case PDFTokenType.EndDictionary:
                return(PDFDictionary.Parse(stack));

            case PDFTokenType.EndList:
                return(PDFList.Parse(stack));

            case PDFTokenType.EOF:
                return(PDFTrailer.Parse(stack));

            default:
                return(this);
            }
        }
Esempio n. 2
0
        public static PDFTrailer Parse(Stack <IPDFToken> tokens)
        {
            PDFTrailer trailer = new PDFTrailer();

            trailer.TrailerOffset = (long)tokens.Pop <PDFInteger>().Value;
            tokens.Pop(PDFTokenType.StartXref);

            if (tokens.Has(PDFTokenType.Dictionary))
            {
                trailer.TrailerDictionary = tokens.Pop <PDFDictionary>();
                trailer.Xref = tokens.Pop <PDFXref>();
            }
            else if (tokens.Has(PDFTokenType.Object))
            {
                trailer.TrailerDictionary = tokens.Pop <PDFObject>();
            }
            else
            {
                throw new InvalidDataException();
            }

            return(trailer);
        }