Element is the abstract interface used to access graphical elements used to build the display list.
Just like many other classes in PDFNet (e.g. ColorSpace, Font, Annot, etc), Element class follows the composite design pattern. This means that all Elements are accessed through the same interface, but depending on the Element type (that can be obtained using GetType()), only methods related to that type can be called. For example, if GetType() returns e_image, it is illegal to call a method specific to another Element type (i.e. a call to a text specific GetTextData() will throw an Exception).
Definition at line 32 of file Element.h.
Rect pdftron::PDF::Element::GetBBox |
( |
| ) |
|
Obtains the bounding box for a graphical element.
Calculates the bounding box for a graphical element (i.e. an Element that belongs to one of following types: e_path, e_text, e_image, e_inline_image, e_shading e_form). The returned bounding box is guaranteed to encompass the Element, but is not guaranteed to be the smallest box that could contain the element. For example, for Bezier curves the bounding box will enclose all control points, not just the curve itself.
- Returns
- true if this is a graphical element and the bounding box can be calculated; false for non-graphical elements which don't have bounding box.
- Parameters
-
out_bbox | (Filled by the method) A reference to a rectangle specifying the bounding box of Element (a rectangle that surrounds the entire element). The coordinates are represented in the default PDF page coordinate system and are using units called points ( 1 point = 1/72 inch = 2.54 /72 centimeter). The bounding box already accounts for the effects of current transformation matrix (CTM), text matrix, font size, and other properties in the graphics state. If this is a non-graphical element (i.e. the method returns false) the bounding box is undefined. |
- Returns
- a CharIterator addressing the first CharData element in the text run.
CharIterator points to CharData. CharData is a data structure that contains the char_code number (used to retrieve glyph outlines, to map to Unicode, etc.), character positioning information (x, y), and the number of bytes taken by the character within the text buffer.
- Note
- CharIterator follows the standard STL forward-iterator interface.
An example of how to use CharIterator.
*
for (
CharIterator itr = element.GetCharIterator(); itr.HasNext(); itr.Next()) {
* unsigned int char_code = itr.Current().char_code;
* double char_pos_x = itr.Current().x;
* double char_pos_y = itr.Current().y;
* }
*
- Note
- Character positioning information (x, y) is represented in text space. In order to get the positioning in the user space, the returned value should be scaled using the text matrix (GetTextMatrix()) and the current transformation matrix (GetCTM()). See section 4.2 'Other Coordinate Spaces' in PDF Reference Manual for details and PDFNet FAQ - "How do I get absolute/relative text and
character positioning?".
-
within a text run a character may occupy more than a single byte (e.g. in case of composite/Type0 fonts). The role of CharIterator/CharData is to provide a uniform and easy to use interface to access character information.
bool pdftron::PDF::Element::IsWindingFill |
( |
| ) |
|
- Returns
- true if the current path should be filled using non-zero winding rule, or false if the path should be filled using even-odd rule.
According non-zero winding rule, you can determine whether a test point is inside or outside a closed curve as follows: Draw a line from a test point to a point that is distant from the curve. Count the number of times the curve crosses the test line from left to right, and count the number of times the curve crosses the test line from right to left. If those two numbers are the same, the test point is outside the curve; otherwise, the test point is inside the curve.
According to even-odd rule, you can determine whether a test point is inside or outside a closed curve as follows: Draw a line from the test point to a point that is distant from the curve. If that line crosses the curve an odd number of times, the test point is inside the curve; otherwise, the test point is outside the curve.
void pdftron::PDF::Element::SetTextMatrix |
( |
double |
a, |
|
|
double |
b, |
|
|
double |
c, |
|
|
double |
d, |
|
|
double |
h, |
|
|
double |
v |
|
) |
| |
Sets the text matrix for a text element. This method accepts text transformation matrix components directly.
A transformation matrix in PDF is specified by six numbers, usually in the form of an array containing six elements. In its most general form, this array is denoted [a b c d h v]; it can represent any linear transformation from one coordinate system to another. For more information about PDF matrices please refer to section 4.2.2 'Common Transformations' in PDF Reference Manual, and to documentation for Matrix2D class.
- Parameters
-
a | - horizontal 'scaling' component of the new text matrix. |
b | - 'rotation' component of the new text matrix. |
c | - 'rotation' component of the new text matrix. |
d | - vertical 'scaling' component of the new text matrix. |
h | - horizontal translation component of the new text matrix. |
v | - vertical translation component of the new text matrix. |