pdftron::PDF::ElementBuilder Class Reference

ElementBuilder is used to build new PDF::Elements (e.g. More...

#include <ElementBuilder.h>

List of all members.

Public Member Functions

 ElementBuilder ()
 ~ElementBuilder ()
void Reset (GState gs=0)
 The function sets the graphics state of this Element to the given value.
Element CreateImage (Image &img)
 Create a content image Element out of a given document Image.
Element CreateImage (Image &img, const Common::Matrix2D &mtx)
 Create a content image Element out of a given document Image.
Element 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).
Element CreateGroupBegin ()
 Create e_group_begin Element (i.e.
Element CreateGroupEnd ()
 Create e_group_end Element (i.e.
Element CreateShading (Shading &sh)
 Create a shading Element.
Element CreateForm (SDF::Obj form)
 Create a Form XObject Element.
Element CreateForm (Page page)
 Create a Form XObject Element using the content of the existing page.
Element CreateForm (Page page, class PDFDoc &doc)
 Create a Form XObject Element using the content of the existing page.
Element CreateTextBegin (Font font, double font_sz)
 Start a text block ('BT' operator in PDF content stream).
Element CreateTextBegin ()
 Start a text block ('BT' operator in PDF content stream).
Element CreateTextEnd ()
 Ends a text block.
Element CreateTextRun (const char *text_data, Font font, double font_sz)
 Create a text run using the given font.
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)
 Create a new text run.
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)
 Create a new Unicode text run.
Element CreateTextNewLine (double dx, double dy)
 Create e_text_new_line Element (i.e.
Element CreateTextNewLine ()
 Create e_text_new_line Element (i.e.
Element CreatePath (const double *points, int point_count, const char *seg_types, int seg_types_count)
 Create a path Element using given path segment data.
Element CreateRect (double x, double y, double width, double height)
 Create a rectangle path Element.
Element CreateEllipse (double cx, double cy, double rx, double ry)
 Create an ellipse (or circle, if rx == ry) path Element.
void PathBegin ()
 Starts building a new path Element that can contain an arbitrary sequence of lines, curves, and rectangles.
Element PathEnd ()
 Finishes building of the path Element.
void MoveTo (double x, double y)
 Set the current point.
void LineTo (double x, double y)
 Draw a line from the current point to the given point.
void 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.
void 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).
void 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.
void Ellipse (double cx, double cy, double rx, double ry)
 Add an ellipse (or circle, if rx == ry) to the current path as a complete subpath.
void Rect (double x, double y, double width, double height)
 Add a rectangle to the current path as a complete subpath.
void ClosePath ()
 Closes the current subpath.


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.


Constructor & Destructor Documentation

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

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


Member Function Documentation

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.

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

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

Element pdftron::PDF::ElementBuilder::CreateImage ( Image img,
const Common::Matrix2D mtx 
)

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

Parameters:
mtx the 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).

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::CreateShading ( Shading sh  ) 

Create a shading Element.

Element pdftron::PDF::ElementBuilder::CreateForm ( SDF::Obj  form  ) 

Create a Form XObject Element.

Parameters:
form a 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:
page A 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:
page A page used to create the Form XObject.
doc Destination document for the Form XObject.

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.

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::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_data pointer to Unicode text
text_data_sz number 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

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.

Element pdftron::PDF::ElementBuilder::CreateTextNewLine (  ) 

Create e_text_new_line Element (i.e.

a T* operator in PDF content stream).

Element pdftron::PDF::ElementBuilder::CreatePath ( const double *  points,
int  point_count,
const char *  seg_types,
int  seg_types_count 
)

Create a path Element using given path segment data.

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

Create a rectangle path Element.

Parameters:
x,y The coordinates of the lower left corner of the rectangle.
width,height - The width and height of the rectangle.

Element pdftron::PDF::ElementBuilder::CreateEllipse ( double  cx,
double  cy,
double  rx,
double  ry 
)

Create an ellipse (or circle, if rx == ry) path Element.

Parameters:
cx,cy The coordinates of the ellipse center.
rx,ry - The width and height of the ellipse rectangle.

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::MoveTo ( double  x,
double  y 
)

Set the current point.

void pdftron::PDF::ElementBuilder::LineTo ( double  x,
double  y 
)

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

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.

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:
x,y coordinates of the lower left corner of the ellipse encompassing rectangle
width,height overall width and height of the full ellipse (not considering the angular extents).
start starting angle of the arc in degrees
extent angular 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:
xr,yr x and y radius for the arc
rx x-axis rotation in degrees
isLargeArc indicates 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
sweep direction in which arc is drawn (1 - clockwise, 0 - counterclockwise)
endX,endY 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::Ellipse ( double  cx,
double  cy,
double  rx,
double  ry 
)

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:
cx,cy The coordinates of the ellipse center.
rx,ry - The radii of the ellipse.

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:
x,y The coordinates of the lower left corner of the rectangle.
width,height - The width and height of the rectangle.

void pdftron::PDF::ElementBuilder::ClosePath (  ) 

Closes the current subpath.


© 2002-2010 PDFTron Systems Inc.