Exemplo n.º 1
0
        public PdfObject Parse(long offset)
        {
            if (offset >= 0)
            {
                _lexer.SetPosition(offset);
            }
            PdfToken t = _lexer.GetNextToken();

            return(new PdfObject());
        }
Exemplo n.º 2
0
 private PdfToken matchKeyword(int ch)
 {
     _buffer.Clear();
     while (true)
     {
         ch = readByte();
         if (ch == CHAR_EOF || isWhiteSpace(ch) || isDelimiter(ch))
         {
             putBack();
             PdfToken token = new PdfToken(PdfToken.TokenType.KEYWORD, _buffer.ToArray());
         }
         else
         {
             _buffer.Add((byte)ch);
         }
     }
 }
Exemplo n.º 3
0
        private PdfToken matchNumber(int ch)
        {
            _buffer.Clear();
            while (true)
            {
                _buffer.Add((byte)ch);
                ch = readByte();
                if (ch == CHAR_EOF || isWhiteSpace(ch) || isDelimiter(ch))
                {
                    putBack();

                    if (_buffer.Count == 0)
                    {
                        throw new Exception("Invalid number object: The number cannot be null.");
                    }

                    byte[] data = _buffer.ToArray();
                    string val  = Encoding.ASCII.GetString(data);

                    if (val.Contains("."))
                    {
                        try {
                            double   n     = double.Parse(val);
                            PdfToken token = new PdfToken(PdfToken.TokenType.NUMBER, data, PdfToken.TokenSubType.REAL, n);
                            return(token);
                        }
                        catch (Exception ex) {
                            throw new Exception("Invalid number object: '" + val + "' is not a valid number.", ex);
                        }
                    }
                    else
                    {
                        try {
                            int      n     = int.Parse(val);
                            PdfToken token = new PdfToken(PdfToken.TokenType.NUMBER, data, PdfToken.TokenSubType.INTEGER, n);
                            return(token);
                        }
                        catch (Exception ex) {
                            throw new Exception("Invalid number object: '" + val + "' is not a valid number.", ex);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
 private PdfToken matchName()
 {
     _buffer.Clear();
     while (true)
     {
         int ch = readByte();
         if (ch == CHAR_EOF || isWhiteSpace(ch) || isDelimiter(ch))
         {
             putBack();
             if (_buffer.Count == 0)
             {
                 throw new Exception("Invalid name object: The name cannot be null.");
             }
             PdfToken token = new PdfToken(PdfToken.TokenType.NAME, _buffer.ToArray());
             return(token);
         }
         else
         {
             _buffer.Add((byte)ch);
         }
     }
 }
Exemplo n.º 5
0
 private void SetTokenPosition(PdfToken token)
 {
     token.Offset = _tokenStart;
     token.Length = this.GetPosition() - _tokenStart;
 }