![]() |
#include <ElementReader.h>
Public Member Functions | |
ElementReader () | |
~ElementReader () | |
void | Begin (const Page &page, OCG::Context *ocg_context=0) |
Begin processing a page. | |
void | Begin (SDF::Obj content_stream, SDF::Obj resource_dict=0, OCG::Context *ocg_context=0) |
Begin processing given content stream. | |
Element | Next () |
Element | Current () |
void | FormBegin () |
When the current element is a form XObject you have the option to skip form processing (by not calling FormBegin()) or to open the form stream and continue Element traversal into the form. | |
GState | PatternBegin (SDF::Obj pattern, bool inherit_gs=true) |
A method used to spawn a sub-display list representing a tiling pattern. | |
void | Type3FontBegin (SDF::Obj glyph_stream, SDF::Obj font, SDF::Obj resource_dict=0) |
A method used to spawn a sub-display list representing a Type3 Font glyph. | |
bool | End () |
Close the current display list. | |
GSChangesIterator | GetChangesIterator () |
bool | IsChanged (GState::GStateAttribute attrib) |
void | ClearChangeList () |
Clear the list containing identifiers of modified graphics state attributes. | |
SDF::Obj | GetFont (const char *name) |
SDF::Obj | GetXObject (const char *name) |
SDF::Obj | GetShading (const char *name) |
SDF::Obj | GetColorSpace (const char *name) |
SDF::Obj | GetPattern (const char *name) |
SDF::Obj | GetExtGState (const char *name) |
ElementReader provides a convenient interface used to traverse the Element display list of a page. The display list representing graphical elements (such as text-runs, paths, images, shadings, forms, etc) is accessed using the intrinsic iterator. ElementReader automatically concatenates page contents spanning multiple streams and provides a mechanism to parse contents of sub-display lists (e.g. forms XObjects and Type3 fonts).
A sample use case for ElementReader is given below:
... ElementReader reader; reader.Begin(page); for (Element element=reader.Next(); element; element = reader.Next()) // Read page contents { switch (element.GetType()) { case Element::e_path: { // Process path data... const double* data = element.GetPathPoints(); int sz = element.GetPointCount(); } break; case Element::e_text: // ... break; } } reader.End();
For a full sample, please refer to ElementReader and ElementReaderAdv sample projects.
pdftron::PDF::ElementReader::ElementReader | ( | ) |
pdftron::PDF::ElementReader::~ElementReader | ( | ) |
void pdftron::PDF::ElementReader::Begin | ( | const Page & | page, | |
OCG::Context * | ocg_context = 0 | |||
) |
Begin processing a page.
page | A page to start processing. | |
ocg_context | An optional parameter used to specify the Optional Content (OC) Context that should be used when processing the page. When the OCG::Context is specified, Element::IsOCVisible() will return 'true' or 'false' depending on the visibility of the current Optional Content Group (OCG) and the states of flags in the given context. |
void pdftron::PDF::ElementReader::Begin | ( | SDF::Obj | content_stream, | |
SDF::Obj | resource_dict = 0 , |
|||
OCG::Context * | ocg_context = 0 | |||
) |
Begin processing given content stream.
The content stream may be a Form XObject, Type3 glyph stream, pattern stream or any other content stream.
content_stream | - A stream object representing the content stream (usually a Form XObject). | |
resource_dict | - An optional '/Resource' dictionary parameter. If content stream refers to named resources that are not present in the local Resource dictionary, the names are looked up in the supplied resource dictionary. | |
ocg_context | An optional parameter used to specify the Optional Content (OC) Context that should be used when processing the page. When the OCG::Context is specified, Element::IsOCVisible() will return 'true' or 'false' depending on the visibility of the current Optional Content Group (OCG) and the states of flags in the given context. |
Element pdftron::PDF::ElementReader::Next | ( | ) |
Element pdftron::PDF::ElementReader::Current | ( | ) |
void pdftron::PDF::ElementReader::FormBegin | ( | ) |
When the current element is a form XObject you have the option to skip form processing (by not calling FormBegin()) or to open the form stream and continue Element traversal into the form.
To open a form XObject display list use FormBegin() method. The Next() returned Element will be the first Element in the form XObject display list. Subsequent calls to Next() will traverse form's display list until NULL is returned. At any point you can close the form sub-list using ElementReader::End() method. After the form display list is closed (using End()) the processing will return to the parent display list at the point where it left off before entering the form XObject.
A method used to spawn a sub-display list representing a tiling pattern.
You can call this method at any point during processing of the parent display list.
pattern | the Pattern SDF/Cos stream in the Resource dictionary (e.g. which can be obtained through GState interface of the current Element or through some other means). | |
inherit_gs | An optional parameter used to indicate whether the pattern should inherit the graphics state from the parent content stream (the content stream in which the pattern is defined as a resource). By default, inherit_gs is 'true'. |
void pdftron::PDF::ElementReader::Type3FontBegin | ( | SDF::Obj | glyph_stream, | |
SDF::Obj | font, | |||
SDF::Obj | resource_dict = 0 | |||
) |
A method used to spawn a sub-display list representing a Type3 Font glyph.
You can call this method at any point during processing of the parent display list.
glyph_stream | SDF/Cos stream containing glyph description (e.g. returned by Font::GetType3GlyphStream()). | |
font | SDF/Cos object representing the Type3 font (e.g. returned by Font::GetSDFObj()). | |
resource_dict | - An optional '/Resource' dictionary parameter. If any glyph descriptions refer to named resources but Font Resource dictionary is absent, the names are looked up in the supplied resource dictionary. |
bool pdftron::PDF::ElementReader::End | ( | ) |
Close the current display list.
If the current display list is a sub-list created using FormBegin(), PatternBegin(), or Type3FontBegin() methods, the function will end the sub-list and will return processing to the parent display list at the point where it left off before entering the sub-list.
GSChangesIterator pdftron::PDF::ElementReader::GetChangesIterator | ( | ) |
bool pdftron::PDF::ElementReader::IsChanged | ( | GState::GStateAttribute | attrib | ) |
void pdftron::PDF::ElementReader::ClearChangeList | ( | ) |
Clear the list containing identifiers of modified graphics state attributes.
The list of modified attributes is then accumulated during a subsequent call(s) to ElementReader.Next().
SDF::Obj pdftron::PDF::ElementReader::GetFont | ( | const char * | name | ) |
SDF::Obj pdftron::PDF::ElementReader::GetXObject | ( | const char * | name | ) |
SDF::Obj pdftron::PDF::ElementReader::GetShading | ( | const char * | name | ) |
SDF::Obj pdftron::PDF::ElementReader::GetColorSpace | ( | const char * | name | ) |
SDF::Obj pdftron::PDF::ElementReader::GetPattern | ( | const char * | name | ) |
SDF::Obj pdftron::PDF::ElementReader::GetExtGState | ( | const char * | name | ) |