All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pdftron::PDF::ElementBuilder Class Reference

#include <ElementBuilder.h>

Public Member Functions

 ElementBuilder ()
 
 ~ElementBuilder ()
 
void Reset (GState gs=0)
 
Element CreateImage (Image &img)
 
Element CreateImage (Image &img, const Common::Matrix2D &mtx)
 
Element CreateImage (Image &img, double x, double y, double hscale, double vscale)
 
Element CreateGroupBegin ()
 
Element CreateGroupEnd ()
 
Element CreateShading (Shading &sh)
 
Element CreateForm (SDF::Obj form)
 
Element CreateForm (Page page)
 
Element CreateForm (Page page, class PDFDoc &doc)
 
Element CreateTextBegin (Font font, double font_sz)
 
Element CreateTextBegin ()
 
Element CreateTextEnd ()
 
Element CreateTextRun (const char *text_data, Font font, double font_sz)
 
Element CreateTextRun (const char *text_data, UInt32 text_data_sz, Font font, double font_sz)
 
Element CreateTextRun (const UChar *text_data, UInt32 text_data_sz, Font font, double font_sz)
 
Element CreateTextRun (const char *text_data)
 
Element CreateTextRun (const char *text_data, UInt32 text_data_sz)
 
Element CreateTextRun (const UChar *text_data, UInt32 text_data_sz)
 
Element CreateUnicodeTextRun (const Unicode *text_data, UInt32 text_data_sz)
 
Element CreateTextNewLine (double dx, double dy)
 
Element CreateTextNewLine ()
 
Element CreatePath (const std::vector< double > &points, const std::vector< unsigned char > &seg_types)
 
Element CreatePath (const double *points, int point_count, const char *seg_types, int seg_types_count)
 
Element CreateRect (double x, double y, double width, double height)
 
Element CreateEllipse (double x, double y, double width, double height)
 
void PathBegin ()
 
Element PathEnd ()
 
void MoveTo (double x, double y)
 
void LineTo (double x, double y)
 
void CurveTo (double cx1, double cy1, double cx2, double cy2, double x2, double y2)
 
void ArcTo (double x, double y, double width, double height, double start, double extent)
 
void ArcTo (double xr, double yr, double rx, bool isLargeArc, bool sweep, double endX, double endY)
 
void Ellipse (double x, double y, double width, double height)
 
void Rect (double x, double y, double width, double height)
 
void ClosePath ()
 
void Destroy ()
 

Detailed Description

ElementBuilder is used to build new PDF::Elements (e.g. image, text, path, etc) from scratch. In conjunction with ElementWriter, ElementBuilder can be used to create new page content.

Note
Analogous to ElementReader, every call to ElementBuilder.Create? method destroys the Element currently associated with the builder and all previous Element pointers are invalidated.
For C++ developers. Analogous to ElementReader, ElementBuilder is the owner of all Element objects it creates.

Definition at line 32 of file ElementBuilder.h.

Constructor & Destructor Documentation

pdftron::PDF::ElementBuilder::ElementBuilder ( )
pdftron::PDF::ElementBuilder::~ElementBuilder ( )

Member Function Documentation

void pdftron::PDF::ElementBuilder::ArcTo ( double  x,
double  y,
double  width,
double  height,
double  start,
double  extent 
)

Draw an arc with the specified parameters (lower left corner, width, height and angles).

Parameters
xThe horizontal x coordinate of the lower left corner of the ellipse encompassing rectangle
yThe horizontal y coordinate of the lower left corner of the ellipse encompassing rectangle
widthoverall width of the full ellipse (not considering the angular extents).
heightoverall height of the full ellipse (not considering the angular extents).
startstarting angle of the arc in degrees
extentangular extent of the arc in degrees
void pdftron::PDF::ElementBuilder::ArcTo ( double  xr,
double  yr,
double  rx,
bool  isLargeArc,
bool  sweep,
double  endX,
double  endY 
)

Draw an arc from the current point to the end point.

Parameters
xrx radius for the arc
yry radius for the arc
rxx-axis rotation in degrees
isLargeArcindicates if smaller or larger arc is chosen 1 - one of the two larger arc sweeps is chosen 0 - one of the two smaller arc sweeps is chosen
sweepdirection in which arc is drawn (1 - clockwise, 0 - counterclockwise)
endXx coordinate of end point
endYy coordinate of end point
Note
The Arc is defined the same way as it is specified by SVG or XPS standards. For further questions please refer to the XPS or SVG standards.
void pdftron::PDF::ElementBuilder::ClosePath ( )

Closes the current subpath.

Element pdftron::PDF::ElementBuilder::CreateEllipse ( double  x,
double  y,
double  width,
double  height 
)

Create an ellipse (or circle, if width == height) path Element.

Parameters
xThe horizontal x coordinate of the ellipse center.
yThe vertical y coordinate of the ellipse center.
widthThe width of the ellipse rectangle.
heightThe height of the ellipse rectangle.
Returns
the path Element
Element pdftron::PDF::ElementBuilder::CreateForm ( SDF::Obj  form)

Create a Form XObject Element.

Parameters
forma Form XObject content stream
Element pdftron::PDF::ElementBuilder::CreateForm ( Page  page)

Create a Form XObject Element using the content of the existing page. This method assumes that the XObject will be used in the same document as the given page. If you need to create the Form XObject in a different document use CreateForm(Page, Doc) method.

Parameters
pageA page used to create the Form XObject.
Element pdftron::PDF::ElementBuilder::CreateForm ( Page  page,
class PDFDoc doc 
)

Create a Form XObject Element using the content of the existing page. Unlike CreateForm(Page) method, you can use this method to create form in another document.

Parameters
pageA page used to create the Form XObject.
docDestination document for the Form XObject.
Element pdftron::PDF::ElementBuilder::CreateGroupBegin ( )

Create e_group_begin Element (i.e. 'q' operator in PDF content stream). The function saves the current graphics state.

Element pdftron::PDF::ElementBuilder::CreateGroupEnd ( )

Create e_group_end Element (i.e. 'Q' operator in PDF content stream). The function restores the previous graphics state.

Element pdftron::PDF::ElementBuilder::CreateImage ( Image img)

Create a content image Element out of a given document Image.

Parameters
imgthe given image.
Element pdftron::PDF::ElementBuilder::CreateImage ( Image img,
const Common::Matrix2D mtx 
)

Create a content image Element out of a given document Image.

Parameters
imgthe given image.
mtxthe image transformation matrix.
Element pdftron::PDF::ElementBuilder::CreateImage ( Image img,
double  x,
double  y,
double  hscale,
double  vscale 
)

Create a content image Element out of a given document Image with the lower left corner at (x, y), and scale factors (hscale, vscale).

Parameters
imgthe given image.
xThe horizontal x position to place the lower left corner of the image
yThe vertical x position to place the lower left corner of the image
hscaleThe horizontal scale of the image
vscaleThe vertical scale of the image
Element pdftron::PDF::ElementBuilder::CreatePath ( const std::vector< double > &  points,
const std::vector< unsigned char > &  seg_types 
)

Create a path Element using given path segment data

Returns
the path Element
Element pdftron::PDF::ElementBuilder::CreatePath ( const double *  points,
int  point_count,
const char *  seg_types,
int  seg_types_count 
)
Element pdftron::PDF::ElementBuilder::CreateRect ( double  x,
double  y,
double  width,
double  height 
)

Create a rectangle path Element.

Parameters
xThe horizontal coordinate of the lower left corner of the rectangle.
yThe vertical coordinate of the lower left corner of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
Returns
the path Element
Element pdftron::PDF::ElementBuilder::CreateShading ( Shading sh)
Parameters
shA Shading object. Shading objects represent a flat interface around all PDF shading types (e_function_shading, e_axial_shading, etc.) Create a shading Element.
Element pdftron::PDF::ElementBuilder::CreateTextBegin ( Font  font,
double  font_sz 
)

Start a text block ('BT' operator in PDF content stream). The function installs the given font in the current graphics state.

Parameters
fontfont to set the text in the text block to
font_szsize to set the text in the text block to
Element pdftron::PDF::ElementBuilder::CreateTextBegin ( )

Start a text block ('BT' operator in PDF content stream).

Element pdftron::PDF::ElementBuilder::CreateTextEnd ( )

Ends a text block.

Element pdftron::PDF::ElementBuilder::CreateTextNewLine ( double  dx,
double  dy 
)

Create e_text_new_line Element (i.e. a Td operator in PDF content stream). Move to the start of the next line, offset from the start of the current line by (dx , dy). dx and dy are numbers expressed in unscaled text space units.

Parameters
dxThe horizontal x offset from the start of the current line
dyThe vertical y offset from the start of the current line
Returns
the path Element
Element pdftron::PDF::ElementBuilder::CreateTextNewLine ( )

Create e_text_new_line Element (i.e. a T* operator in PDF content stream).

Returns
the path Element
Element pdftron::PDF::ElementBuilder::CreateTextRun ( const char *  text_data,
Font  font,
double  font_sz 
)

Create a text run using the given font.

Note
a text run can be created only within a text block
Element pdftron::PDF::ElementBuilder::CreateTextRun ( const char *  text_data,
UInt32  text_data_sz,
Font  font,
double  font_sz 
)
Element pdftron::PDF::ElementBuilder::CreateTextRun ( const UChar text_data,
UInt32  text_data_sz,
Font  font,
double  font_sz 
)
Element pdftron::PDF::ElementBuilder::CreateTextRun ( const char *  text_data)

Create a new text run.

Note
a text run can be created only within a text block
you must set the current Font and font size before calling this function.
Element pdftron::PDF::ElementBuilder::CreateTextRun ( const char *  text_data,
UInt32  text_data_sz 
)
Element pdftron::PDF::ElementBuilder::CreateTextRun ( const UChar text_data,
UInt32  text_data_sz 
)
Element pdftron::PDF::ElementBuilder::CreateUnicodeTextRun ( const Unicode text_data,
UInt32  text_data_sz 
)

Create a new Unicode text run.

Parameters
text_datapointer to Unicode text
text_data_sznumber of characters (not bytes) in text_data
Note
you must set the current Font and font size before calling this function and the font must be created using Font::CreateCIDTrueTypeFont() method.
a text run can be created only within a text block
void pdftron::PDF::ElementBuilder::CurveTo ( double  cx1,
double  cy1,
double  cx2,
double  cy2,
double  x2,
double  y2 
)

Draw a Bezier curve from the current point to the given point (x2, y2) using (cx1, cy1) and (cx2, cy2) as control points.

Parameters
cx1The x component of the first control point
cy1The y component of the first control point
cx2The x component of the second control point
cy2The y component of the second control point
x2The horizontal x component of the goal point
y2The vertical y component of the goal point
void pdftron::PDF::ElementBuilder::Destroy ( )

Frees the native memory of the object.

void pdftron::PDF::ElementBuilder::Ellipse ( double  x,
double  y,
double  width,
double  height 
)

Add an ellipse (or circle, if rx == ry) to the current path as a complete subpath. Setting the current point is not required before using this function.

Parameters
xThe x coordinate of the ellipse center.
yThe y coordinate of the ellipse center.
widthThe x radii of the ellipse.
heightThe y radii of the ellipse.
void pdftron::PDF::ElementBuilder::LineTo ( double  x,
double  y 
)

Draw a line from the current point to the given point.

Parameters
xThe horizontal x component of the goal point
yThe vertical y component of the goal point
void pdftron::PDF::ElementBuilder::MoveTo ( double  x,
double  y 
)

Set the current point.

Parameters
xThe horizontal x component of the point
yThe vertical y component of the point
void pdftron::PDF::ElementBuilder::PathBegin ( )

Starts building a new path Element that can contain an arbitrary sequence of lines, curves, and rectangles.

Element pdftron::PDF::ElementBuilder::PathEnd ( )

Finishes building of the path Element.

Returns
the path Element
void pdftron::PDF::ElementBuilder::Rect ( double  x,
double  y,
double  width,
double  height 
)

Add a rectangle to the current path as a complete subpath. Setting the current point is not required before using this function.

Parameters
xThe x coordinate of the lower left corner of the rectangle.
yThe y coordinate of the lower left corner of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
void pdftron::PDF::ElementBuilder::Reset ( GState  gs = 0)

The function sets the graphics state of this Element to the given value. If 'gs' parameter is not specified or is NULL the function resets the graphics state of this Element to the default graphics state (i.e. the graphics state at the beginning of the display list).

The function can be used in situations where the same ElementBuilder is used to create content on several pages, XObjects, etc. If the graphics state is not Reset() when moving to a new display list, the new Element will have the same graphics state as the last Element in the previous display list (and this may or may not be your intent).

Another use of Reset(gs) is to make sure that two Elements have the graphics state.

Parameters
gsGState (graphics state) object. If NULL or unspecified, resets graphics state to default.

The documentation for this class was generated from the following file: