public class ElementReader
extends java.lang.Object
...
ElementReader reader=new ElementReader();
reader.Begin(page);
for (Element element=reader.next(); element!=null;element=reader.next()) {
Rect bbox;
if((bbox=element.getBBox())!=null) System.out.println("Bounding Box: " + bbox.getRectangle());
switch (element.getType()) {
case Element.e_path: { // Process path data...
double[] data = element.getPathPoints();
}
break;
case Element.e_text:
// ...
break;
}
}
reader.End();
For a full sample, please refer to ElementReader and ElementReaderAdv sample projects.Constructor and Description |
---|
ElementReader()
Instantiates a new element reader.
|
Modifier and Type | Method and Description |
---|---|
void |
begin(Obj content_stream)
Begin processing given content stream.
|
void |
begin(Obj content_stream,
Obj resource_dict)
Begin processing given content stream.
|
void |
begin(Obj content_stream,
Obj resource_dict,
Context ctx)
Begin processing given content stream.
|
void |
begin(Page page)
Begin processing a page.
|
void |
begin(Page page,
Context ctx)
Begin processing a page.
|
void |
clearChangeList()
Clear the list containing identifiers of modified graphics state attributes.
|
Element |
current()
get current page element
|
void |
destroy()
Frees the native memory of the object.
|
boolean |
end()
Close the current display list.
|
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.
|
GSChangesIterator |
getChangesIterator()
Get the changes iterator.
|
Obj |
getColorSpace(java.lang.String name)
Get the color space.
|
Obj |
getExtGState(java.lang.String name)
Get the ext GState.
|
Obj |
getFont(java.lang.String name)
Get the specified font.
|
Obj |
getPattern(java.lang.String name)
Get the pattern.
|
Obj |
getShading(java.lang.String name)
Get the specified shading object.
|
Obj |
getXObject(java.lang.String name)
Get the specified XObject.
|
boolean |
isChanged(int gstate_attrib)
Checks if given GState attribute is changed.
|
Element |
next()
Get next page element
|
void |
patternBegin(boolean fill_pattern)
Pattern begin.
|
void |
patternBegin(boolean fill_pattern,
boolean reset_ctm_tfm)
A method used to spawn the sub-display list representing the tiling pattern
of the current element in the ElementReader.
|
void |
type3FontBegin(CharData char_data)
pawn a sub-display list representing a Type3 Font glyph.
|
void |
type3FontBegin(CharData char_data,
Obj resource_dict)
A method used to spawn a sub-display list representing a Type3 Font glyph.
|
public ElementReader() throws PDFNetException
PDFNetException
public void destroy() throws PDFNetException
PDFNetException
public void begin(Page page) throws PDFNetException
Note: When page processing is completed, make sure to call ElementReader.End().
page
- the page to start processing.PDFNetException
public void begin(Page page, Context ctx) throws PDFNetException
Note: When page processing is completed, make sure to call ElementReader.End().
page
- the page to start processing.ctx
- the Optional Content (OC) Context that should be used when processing
the page. 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 contextPDFNetException
public void begin(Obj content_stream) throws PDFNetException
Note: When page processing is completed, make sure to call ElementReader.End().
content_stream
- - A stream object representing the content stream (usually
a Form XObject).PDFNetException
public void begin(Obj content_stream, Obj resource_dict) throws PDFNetException
Note: When page processing is completed, make sure to call ElementReader.End().
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.PDFNetException
public void begin(Obj content_stream, Obj resource_dict, Context ctx) throws PDFNetException
Note: When page processing is completed, make sure to call ElementReader.End().
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.ctx
- The Optional Content (OC) Context that should be used when processing
the page. 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.PDFNetException
public Element next() throws PDFNetException
Note: Every call to ElementReader::Next() destroys the current Element. Therefore, an Element becomes invalid after subsequent ElementReader::Next() operation.
PDFNetException
public Element current() throws PDFNetException
Note: Every call to ElementReader::Next() destroys the current Element. Therefore, an Element becomes invalid after subsequent ElementReader::Next() operation.
PDFNetException
public void formBegin() throws PDFNetException
PDFNetException
public void patternBegin(boolean fill_pattern, boolean reset_ctm_tfm) throws PDFNetException
fill_pattern
- If true, the filling pattern of the current element will
be spawned; otherwise, the stroking pattern of the current element will be
spawned. Note that the graphics state will be inherited from the parent content
stream (the content stream in which the pattern is defined as a resource) automatically.reset_ctm_tfm
- An optional parameter used to indicate whether the pattern's
display list should set its initial CTM and transformation matrices to identity matrix.
In general, we should leave it to be false.
To open a tiling pattern sub-display list use PatternBegin() method.
The Next() returned Element will be the first Element in the pattern display list.
Subsequent calls to Next() will traverse pattern's display list until NULL is
encountered. At any point you can close the pattern sub-list using
ElementReader::End() method. After the pattern display list is closed,
the processing will return to the parent display list at the point where
pattern display list was spawned.PDFNetException
public void patternBegin(boolean fill_pattern) throws PDFNetException
fill_pattern
- If true, the filling pattern of the current element will
be spawned; otherwise, the stroking pattern of the current element will be
spawned. Note that the graphics state will be inherited from the parent content
stream (the content stream in which the pattern is defined as a resource) automatically.PDFNetException
public void type3FontBegin(CharData char_data, Obj resource_dict) throws PDFNetException
char_data
- The information about the glyph to process. You can get this information
by dereferencing a CharIterator.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.
To open a Type3 font sub-display list use Type3FontBegin() method. The Next()
returned Element will be the first Element in the glyph's display list.
Subsequent calls to Next() will traverse glyph's display list until NULL is
returned. At any point you can close the glyph sub-list using ElementReader::End()
method. After the glyph display list is closed, the processing will return to the
parent display list at the point where glyph display list was spawned.PDFNetException
public void type3FontBegin(CharData char_data) throws PDFNetException
char_data
- PDFNetException
public boolean end() throws PDFNetException
PDFNetException
public GSChangesIterator getChangesIterator() throws PDFNetException
PDFNetException
public boolean isChanged(int gstate_attrib) throws PDFNetException
gstate_attrib
- the given GState attributePDFNetException
public void clearChangeList() throws PDFNetException
PDFNetException
public Obj getFont(java.lang.String name) throws PDFNetException
name
- the font namePDFNetException
public Obj getXObject(java.lang.String name)
name
- the name of the XObjectgetFont(java.lang.String)
public Obj getShading(java.lang.String name)
name
- the name of the shading objectgetFont(java.lang.String)
public Obj getColorSpace(java.lang.String name)
name
- the name of the color spacegetFont(java.lang.String)
public Obj getPattern(java.lang.String name)
name
- the pattern namegetFont(java.lang.String)
public Obj getExtGState(java.lang.String name)
name
- the GState namegetFont(java.lang.String)