Ipelib
|
#include <ipepdfparser.h>
Public Member Functions | |
PdfParser (DataSource &source) | |
void | getChar () |
bool | eos () const noexcept |
PdfToken | token () const noexcept |
void | getToken () |
PdfObj * | getObject (bool lateStream=false) |
PdfObj * | getObjectDef (bool lateStream) |
PdfDict * | getTrailer () |
void | skipXRef () |
std::vector< int > | readXRef () |
PDF parser.
The parser understands the syntax of PDF files, but very little of its semantics. It is meant to be able to parse PDF documents created by Ipe for loading, and to extract information from PDF files created by Pdflatex or Xelatex.
The parser reads a PDF file sequentially from front to back, ignores the contents of 'xref' sections, stores only generation 0 objects, and stops after reading the first 'trailer' section (so it cannot deal with files with incremental updates). It cannot handle stream objects whose /Length entry has been deferred (using an indirect object).
PdfParser::PdfParser | ( | DataSource & | source | ) |
Construct with a data source.
References getChar(), and getToken().
|
inline |
Referenced by getToken(), and PdfParser().
|
inlinenoexcept |
Referenced by getToken().
|
inlinenoexcept |
Referenced by ipe::PdfFile::parse().
void PdfParser::getToken | ( | ) |
Read the next token from the input stream.
References ipe::String::append(), ipe::PdfToken::EArrayBg, ipe::PdfToken::EArrayEnd, ipe::PdfToken::EDictBg, ipe::PdfToken::EDictEnd, ipe::PdfToken::EErr, ipe::PdfToken::EFalse, ipe::PdfToken::EName, ipe::PdfToken::ENull, ipe::PdfToken::ENumber, ipe::PdfToken::EOp, eos(), ipe::String::erase(), ipe::PdfToken::EString, ipe::PdfToken::EStringBinary, ipe::PdfToken::ETrue, getChar(), ipe::PdfToken::iString, and ipe::PdfToken::iType.
Referenced by getObject(), getObjectDef(), getTrailer(), PdfParser(), readXRef(), and skipXRef().
PdfObj * PdfParser::getObject | ( | bool | lateStream = false | ) |
Read one object from input stream.
References ipe::PdfToken::EArrayBg, ipe::PdfToken::EDictBg, ipe::PdfToken::EErr, ipe::PdfToken::EFalse, ipe::PdfToken::EName, ipe::PdfToken::ENull, ipe::PdfToken::ENumber, ipe::PdfToken::EString, ipe::PdfToken::EStringBinary, ipe::PdfToken::ETrue, getToken(), ipe::PdfToken::iString, ipe::PdfToken::iType, ipe::String::substr(), and ipe::Platform::toDouble().
Referenced by getObjectDef().
PdfObj * PdfParser::getObjectDef | ( | bool | lateStream | ) |
Parse an object definition (current token is object number).
References ipe::PdfObj::dict(), ipe::PdfToken::ENumber, ipe::PdfToken::EOp, getObject(), getToken(), ipe::PdfToken::iString, ipe::PdfToken::iType, and ipe::PdfDict::lateStream().
Referenced by ipe::PdfFile::parse().
PdfDict * PdfParser::getTrailer | ( | ) |
Parse trailer dictionary (current token is 'trailer')
References ipe::PdfToken::EDictBg, getToken(), and ipe::PdfToken::iType.
Referenced by ipe::PdfFile::parse().
void PdfParser::skipXRef | ( | ) |
Skip xref table (current token is 'xref')
References getToken(), and ipe::PdfToken::iString.
std::vector< int > PdfParser::readXRef | ( | ) |
Read xref table (current token is 'xref')
References getToken(), and ipe::PdfToken::iString.
Referenced by ipe::PdfFile::parse().