Loading...
Searching...
No Matches
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 | CreateShapedTextRun (ShapedText text_data)
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 ()
Element | CreateMarkedContentBeginInlineProperties (const char *tag)
Element | CreateMarkedContentBegin (const char *tag, SDF::Obj property_dict)
Element | CreateMarkedContentEnd ()
Element | CreateMarkedContentPointInlineProperties (const char *tag)
Element | CreateMarkedContentPoint (const char *tag, SDF::Obj property_dict)
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 33 of file ElementBuilder.h.

## Constructor & Destructor Documentation

## ◆ ElementBuilder()

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

## ◆ ~ElementBuilder()

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

## Member Function Documentation

## ◆ ArcTo() [1/2]

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 | The horizontal x coordinate of the lower left corner of the ellipse encompassing rectangle
  y | The horizontal y coordinate of the lower left corner of the ellipse encompassing rectangle
  width | overall width of the full ellipse (not considering the angular extents).
  height | overall 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

## ◆ ArcTo() [2/2]

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 | x radius for the arc
  yr | y radius for the arc
  rx | x-axis rotation in radians
  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 | x coordinate of end point
  endY | y 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.

## ◆ ClosePath()

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

Closes the current subpath.

## ◆ CreateEllipse()

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

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

Parameters

  x | The horizontal x coordinate of the ellipse center.
  y | The vertical y coordinate of the ellipse center.
  width | The width of the ellipse rectangle.
  height | The height of the ellipse rectangle.

Returns
  the path Element

## ◆ CreateForm() [1/3]

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.

## ◆ CreateForm() [2/3]

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.

## ◆ CreateForm() [3/3]

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

Create a Form XObject Element.

Parameters

  form | a Form XObject content stream

## ◆ CreateGroupBegin()

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.

## ◆ CreateGroupEnd()

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.

## ◆ CreateImage() [1/3]

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

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

Parameters

  img | the given image.

## ◆ CreateImage() [2/3]

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

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

Parameters

  img | the given image.
  mtx | the image transformation matrix.

## ◆ CreateImage() [3/3]

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

  img | the given image.
  x | The horizontal x position to place the lower left corner of the image
  y | The vertical x position to place the lower left corner of the image
  hscale | The horizontal scale of the image
  vscale | The vertical scale of the image

## ◆ CreateMarkedContentBegin()

Element pdftron::PDF::ElementBuilder::CreateMarkedContentBegin | ( | const char * | tag,
|  | SDF::Obj | property_dict )

Create e_marked_content_begin element with an associated property dictionary (i.e. BMC or BDC operator in PDF content stream).

Parameters

  tag | the tag entry for this element.
  property_dict | the property dictionary.

Returns
  the marked content begin element.

## ◆ CreateMarkedContentBeginInlineProperties()

Element pdftron::PDF::ElementBuilder::CreateMarkedContentBeginInlineProperties | ( | const char * | tag | ) |

Create e_marked_content_begin element with an inline property dictionary (i.e. BDC operator in PDF content stream).

Parameters

  tag | the tag entry for this element.

Returns
  the marked content begin element.

Note
  The inline property dictionary can be accessed and edited using element.GetMCPropertyDict()

## ◆ CreateMarkedContentEnd()

Element pdftron::PDF::ElementBuilder::CreateMarkedContentEnd | ( |  | ) |

Create e_marked_content_end element (i.e. EMC operator in PDF content stream).

Returns
  the marked content end element.

## ◆ CreateMarkedContentPoint()

Element pdftron::PDF::ElementBuilder::CreateMarkedContentPoint | ( | const char * | tag,
|  | SDF::Obj | property_dict )

Create e_marked_content_point element with an associated property dictionary (i.e. MP or DP operator in PDF content stream).

Parameters

  tag | the tag entry for this element.
  property_dict | the property dictionary.

Returns
  the marked content point element.

## ◆ CreateMarkedContentPointInlineProperties()

Element pdftron::PDF::ElementBuilder::CreateMarkedContentPointInlineProperties | ( | const char * | tag | ) |

Create e_marked_content_point element with an inline property dictionary (i.e. DP operator in PDF content stream).

Parameters

  tag | the tag entry for this element.

Returns
  the marked content point element.

Note
  The inline property dictionary can be accessed and edited using element.GetMCPropertyDict()

## ◆ CreatePath() [1/2]

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

## ◆ CreatePath() [2/2]

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

## ◆ CreateRect()

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

Create a rectangle path Element.

Parameters

  x | The horizontal coordinate of the lower left corner of the rectangle.
  y | The vertical coordinate of the lower left corner of the rectangle.
  width | The width of the rectangle.
  height | The height of the rectangle.

Returns
  the path Element

## ◆ CreateShading()

Element pdftron::PDF::ElementBuilder::CreateShading | ( | Shading & | sh | ) |

Parameters

  sh | A Shading object. Shading objects represent a flat interface around all PDF shading types (e_function_shading, e_axial_shading, etc.) Create a shading Element.

## ◆ CreateShapedTextRun()

Element pdftron::PDF::ElementBuilder::CreateShapedTextRun | ( | ShapedText | text_data | ) |

Create a new text run from shaped text. Shaped Text can be created with an approriate Font, using the Font::GetShapedText() method.

Parameters

  text_data | the shaped 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, and should be the same font used to generate the shaped text content.
  For best results, the font should be encoded using the e_Indices encoding scheme.
  a text run can be created only within a text block

## ◆ CreateTextBegin() [1/2]

Element pdftron::PDF::ElementBuilder::CreateTextBegin | ( |  | ) |

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

## ◆ CreateTextBegin() [2/2]

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

  font | font to set the text in the text block to
  font_sz | size to set the text in the text block to

## ◆ CreateTextEnd()

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

Ends a text block.

## ◆ CreateTextNewLine() [1/2]

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

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

Returns
  the path Element

## ◆ CreateTextNewLine() [2/2]

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

  dx | The horizontal x offset from the start of the current line
  dy | The vertical y offset from the start of the current line

Returns
  the path Element

## ◆ CreateTextRun() [1/6]

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.

## ◆ CreateTextRun() [2/6]

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

## ◆ CreateTextRun() [3/6]

Element pdftron::PDF::ElementBuilder::CreateTextRun | ( | const char * | text_data,
|  | UInt32 | text_data_sz )

## ◆ CreateTextRun() [4/6]

Element pdftron::PDF::ElementBuilder::CreateTextRun | ( | const char * | text_data,
|  | UInt32 | text_data_sz,
|  | Font | font,
|  | double | font_sz )

## ◆ CreateTextRun() [5/6]

Element pdftron::PDF::ElementBuilder::CreateTextRun | ( | const UChar * | text_data,
|  | UInt32 | text_data_sz )

## ◆ CreateTextRun() [6/6]

Element pdftron::PDF::ElementBuilder::CreateTextRun | ( | const UChar * | text_data,
|  | UInt32 | text_data_sz,
|  | Font | font,
|  | double | font_sz )

## ◆ CreateUnicodeTextRun()

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

## ◆ CurveTo()

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

  cx1 | The x component of the first control point
  cy1 | The y component of the first control point
  cx2 | The x component of the second control point
  cy2 | The y component of the second control point
  x2 | The horizontal x component of the goal point
  y2 | The vertical y component of the goal point

## ◆ Destroy()

void pdftron::PDF::ElementBuilder::Destroy | ( |  | ) |

Frees the native memory of the object.

## ◆ Ellipse()

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

  x | The x coordinate of the ellipse center.
  y | The y coordinate of the ellipse center.
  width | The x radii of the ellipse.
  height | The y radii of the ellipse.

## ◆ LineTo()

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

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

Parameters

  x | The horizontal x component of the goal point
  y | The vertical y component of the goal point

## ◆ MoveTo()

void pdftron::PDF::ElementBuilder::MoveTo | ( | double | x,
|  | double | y )

Set the current point.

Parameters

  x | The horizontal x component of the point
  y | The vertical y component of the point

## ◆ PathBegin()

void pdftron::PDF::ElementBuilder::PathBegin | ( |  | ) |

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

## ◆ PathEnd()

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

Finishes building of the path Element.

Returns
  the path Element

## ◆ Rect()

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

## ◆ Reset()

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

  gs | GState (graphics state) object. If NULL or unspecified, resets graphics state to default.

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

- PDF/ElementBuilder.h