new ElementBuilder()
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.
Note: For C++ developers. Analogous to ElementReader, ElementBuilder is the owner of
all Element objects it creates.
Extends
Methods
-
<static> create()
-
Constructor for an ElementBuilder object that can be used to build new PDF::Elements (eg. image, text, path, etc.) from scratch. In conjunction with ElementWriter, ElementBuilder can be used to create new page content.
Returns:
A promise that resolves to Returns an ElementBuilder object- Type
- Promise.<Core.PDFNet.ElementBuilder>
-
arcTo(x, y, width, height, start, extent)
-
Draw an arc with the specified parameters (lower left corner, width, height and angles).
Parameters:
Name Type Description x
number The horizontal x coordinate of the lower left corner of the ellipse encompassing rectangle y
number The horizontal y coordinate of the lower left corner of the ellipse encompassing rectangle width
number overall width of the full ellipse (not considering the angular extents). height
number overall height of the full ellipse (not considering the angular extents). start
number starting angle of the arc in degrees extent
number angular extent of the arc in degrees Returns:
- Type
- Promise.<void>
-
arcTo2(xr, yr, rx, isLargeArc, sweep, endX, endY)
-
Draw an arc from the current point to the end point.
Parameters:
Name Type Description xr
number x radius for the arc yr
number y radius for the arc rx
number x-axis rotation in radians isLargeArc
boolean 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
boolean direction in which arc is drawn (1 clockwise, 0 counterclockwise) endX
number x coordinate of end point endY
number 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. Returns:
- Type
- Promise.<void>
-
closePath()
-
Closes the current subpath.
Returns:
- Type
- Promise.<void>
-
createEllipse(x, y, width, height)
-
Create an ellipse (or circle, if width == height) path Element.
Parameters:
Name Type Description x
number The horizontal x coordinate of the ellipse center. y
number The vertical y coordinate of the ellipse center. width
number The width of the ellipse rectangle. height
number The height of the ellipse rectangle. Returns:
A promise that resolves to the path Element- Type
- Promise.<Core.PDFNet.Element>
-
createFormFromDoc(page, 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:
Name Type Description page
Core.PDFNet.Page A page used to create the Form XObject. doc
Core.PDFNet.PDFDoc | Core.PDFNet.SDFDoc | Core.PDFNet.FDFDoc Destination document for the Form XObject. Returns:
A promise that resolves to an object of type: "PDFNet.Element"- Type
- Promise.<Core.PDFNet.Element>
-
createFormFromPage(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:
Name Type Description page
Core.PDFNet.Page A page used to create the Form XObject. Returns:
A promise that resolves to an object of type: "PDFNet.Element"- Type
- Promise.<Core.PDFNet.Element>
-
createFormFromStream(form)
-
Create a Form XObject Element.
Parameters:
Name Type Description form
Core.PDFNet.Obj a Form XObject content stream Returns:
A promise that resolves to an object of type: "PDFNet.Element"- Type
- Promise.<Core.PDFNet.Element>
-
createGroupBegin()
-
Create e_group_begin Element (i.e. 'q' operator in PDF content stream). The function saves the current graphics state.
Returns:
A promise that resolves to an object of type: "PDFNet.Element"- Type
- Promise.<Core.PDFNet.Element>
-
createGroupEnd()
-
Create e_group_end Element (i.e. 'Q' operator in PDF content stream). The function restores the previous graphics state.
Returns:
A promise that resolves to an object of type: "PDFNet.Element"- Type
- Promise.<Core.PDFNet.Element>
-
createImage(img)
-
Create a content image Element out of a given document Image.
Parameters:
Name Type Description img
Core.PDFNet.Image the given image. Returns:
A promise that resolves to an object of type: "PDFNet.Element"- Type
- Promise.<Core.PDFNet.Element>
-
createImageFromMatrix(img, mtx)
-
Create a content image Element out of a given document Image.
Parameters:
Name Type Description img
Core.PDFNet.Image the given image. mtx
Core.PDFNet.Matrix2D the image transformation matrix. Returns:
A promise that resolves to an object of type: "PDFNet.Element"- Type
- Promise.<Core.PDFNet.Element>
-
createImageScaled(img, x, y, hscale, 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:
Name Type Description img
Core.PDFNet.Image the given image. x
number The horizontal x position to place the lower left corner of the image y
number The vertical x position to place the lower left corner of the image hscale
number The horizontal scale of the image vscale
number The vertical scale of the image Returns:
A promise that resolves to an object of type: "PDFNet.Element"- Type
- Promise.<Core.PDFNet.Element>
-
createMarkedContentBegin(tag, property_dict)
-
Create e_marked_content_begin element with an associated property dictionary (i.e. BMC or BDC operator in PDF content stream).
Parameters:
Name Type Description tag
string the tag entry for this element. property_dict
Core.PDFNet.Obj the property dictionary. Returns:
A promise that resolves to the marked content begin element.- Type
- Promise.<Core.PDFNet.Element>
-
createMarkedContentBeginInlineProperties(tag)
-
Create e_marked_content_begin element with an inline property dictionary (i.e. BDC operator in PDF content stream).
Parameters:
Name Type Description tag
string the tag entry for this element. Returns:
A promise that resolves to the marked content begin element. Note: The inline property dictionary can be accessed and edited using element.GetMCPropertyDict()- Type
- Promise.<Core.PDFNet.Element>
-
createMarkedContentEnd()
-
Create e_marked_content_end element (i.e. EMC operator in PDF content stream).
Returns:
A promise that resolves to the marked content end element.- Type
- Promise.<Core.PDFNet.Element>
-
createMarkedContentPoint(tag, property_dict)
-
Create e_marked_content_point element with an associated property dictionary (i.e. MP or DP operator in PDF content stream).
Parameters:
Name Type Description tag
string the tag entry for this element. property_dict
Core.PDFNet.Obj the property dictionary. Returns:
A promise that resolves to the marked content point element.- Type
- Promise.<Core.PDFNet.Element>
-
createMarkedContentPointInlineProperties(tag)
-
Create e_marked_content_point element with an inline property dictionary (i.e. DP operator in PDF content stream).
Parameters:
Name Type Description tag
string the tag entry for this element. Returns:
A promise that resolves to the marked content point element. Note: The inline property dictionary can be accessed and edited using element.GetMCPropertyDict()- Type
- Promise.<Core.PDFNet.Element>
-
createNewTextRun(text_data)
-
Create a new text run.
Parameters:
Name Type Description text_data
string text to initialize the text run with. Note: a text run can be created only within a text block Note: you must set the current Font and font size before calling this function. Returns:
A promise that resolves to an object of type: "PDFNet.Element"- Type
- Promise.<Core.PDFNet.Element>
-
createNewTextRunUnsigned(text_data)
-
Create a new text run.
Parameters:
Name Type Description text_data
string text to initialize the text run with. Uses unsigned characters. Note: a text run can be created only within a text block Note: you must set the current Font and font size before calling this function. Returns:
A promise that resolves to an object of type: "PDFNet.Element"- Type
- Promise.<Core.PDFNet.Element>
-
createPath(points, buf_seg_types)
-
Create a path Element using the given path segment data
Parameters:
Name Type Description points
Array.<number> An array containing data on the points in the path. What each point represents is determined by the corresponding segment type. buf_seg_types
ArrayBuffer | Int8Array | Uint8Array | Uint8ClampedArray A buffer/array containing data on the segment types. Possible segment types are as follows: PDFNet.Element.PathSegmentType = { e_moveto : 1, e_lineto : 2, e_cubicto : 3, e_conicto : 4, e_rect : 5, e_closepath : 6 }
Returns:
A promise that resolves to the path Element- Type
- Promise.<Core.PDFNet.Element>
-
createRect(x, y, width, height)
-
Create a rectangle path Element.
Parameters:
Name Type Description x
number The horizontal coordinate of the lower left corner of the rectangle. y
number The vertical coordinate of the lower left corner of the rectangle. width
number The width of the rectangle. height
number The height of the rectangle. Returns:
A promise that resolves to the path Element- Type
- Promise.<Core.PDFNet.Element>
-
createShading(sh)
-
Parameters:
Name Type Description sh
Core.PDFNet.Shading 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. Returns:
A promise that resolves to an object of type: "PDFNet.Element"- Type
- Promise.<Core.PDFNet.Element>
-
createShapedTextRun(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:
Name Type Description text_data
Core.PDFNet.ShapedText 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. Note: For best results, the font should be encoded using the e_Indices encoding scheme. Note: a text run can be created only within a text block Returns:
A promise that resolves to an object of type: "PDFNet.Element"- Type
- Promise.<Core.PDFNet.Element>
-
createTextBegin()
-
Start a text block ('BT' operator in PDF content stream).
Returns:
A promise that resolves to an object of type: "PDFNet.Element"- Type
- Promise.<Core.PDFNet.Element>
-
createTextBeginWithFont(font, font_sz)
-
Start a text block ('BT' operator in PDF content stream). The function installs the given font in the current graphics state.
Parameters:
Name Type Description font
Core.PDFNet.Font font to set the text in the text block to font_sz
number size to set the text in the text block to Returns:
A promise that resolves to an object of type: "PDFNet.Element"- Type
- Promise.<Core.PDFNet.Element>
-
createTextEnd()
-
Ends a text block.
Returns:
A promise that resolves to an object of type: "PDFNet.Element"- Type
- Promise.<Core.PDFNet.Element>
-
createTextNewLine()
-
Create e_text_new_line Element (i.e. a T* operator in PDF content stream).
Returns:
A promise that resolves to the path Element- Type
- Promise.<Core.PDFNet.Element>
-
createTextNewLineWithOffset(dx, 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:
Name Type Description dx
number The horizontal x offset from the start of the current line dy
number The vertical y offset from the start of the current line Returns:
A promise that resolves to the path Element- Type
- Promise.<Core.PDFNet.Element>
-
createTextRun(text_data, font, font_sz)
-
Create a text run using the given font.
Parameters:
Name Type Description text_data
string text to initialize the text run with font
Core.PDFNet.Font font of the text in the text run font_sz
number size of the text in the text run Note: a text run can be created only within a text block Returns:
A promise that resolves to an object of type: "PDFNet.Element"- Type
- Promise.<Core.PDFNet.Element>
-
createTextRunUnsigned(text_data, font, font_sz)
-
Create a text run using the given font.
Parameters:
Name Type Description text_data
string text to initialize the text run with. Uses unsigned characters. font
Core.PDFNet.Font font of the text in the text run font_sz
number size of the text in the text run Note: a text run can be created only within a text block Returns:
A promise that resolves to an object of type: "PDFNet.Element"- Type
- Promise.<Core.PDFNet.Element>
-
createUnicodeTextRun(text_data)
-
Create a new Unicode text run.
Parameters:
Name Type Description text_data
string the Unicode text Note: you must set the current Font and font size before calling this function and the font must be a CID/Unicode font. Note: a text run can be created only within a text block Returns:
A promise that resolves to an object of type: "PDFNet.Element"- Type
- Promise.<Core.PDFNet.Element>
-
curveTo(cx1, cy1, cx2, cy2, x2, 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:
Name Type Description cx1
number The x component of the first control point cy1
number The y component of the first control point cx2
number The x component of the second control point cy2
number The y component of the second control point x2
number The horizontal x component of the goal point y2
number The vertical y component of the goal point Returns:
- Type
- Promise.<void>
-
destroy()
-
Destructor
- Inherited From:
Returns:
- Type
- Promise.<void>
-
ellipse(x, y, width, 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:
Name Type Description x
number The x coordinate of the ellipse center. y
number The y coordinate of the ellipse center. width
number The x radii of the ellipse. height
number The y radii of the ellipse. Returns:
- Type
- Promise.<void>
-
lineTo(x, y)
-
Draw a line from the current point to the given point.
Parameters:
Name Type Description x
number The horizontal x component of the goal point y
number The vertical y component of the goal point Returns:
- Type
- Promise.<void>
-
moveTo(x, y)
-
Set the current point.
Parameters:
Name Type Description x
number The horizontal x component of the point y
number The vertical y component of the point Returns:
- Type
- Promise.<void>
-
pathBegin()
-
Starts building a new path Element that can contain an arbitrary sequence of lines, curves, and rectangles.
Returns:
- Type
- Promise.<void>
-
pathEnd()
-
Finishes building of the path Element.
Returns:
A promise that resolves to the path Element- Type
- Promise.<Core.PDFNet.Element>
-
rect(x, y, width, height)
-
Add a rectangle to the current path as a complete subpath. Setting the current point is not required before using this function.
Parameters:
Name Type Description x
number The x coordinate of the lower left corner of the rectangle. y
number The y coordinate of the lower left corner of the rectangle. width
number The width of the rectangle. height
number The height of the rectangle. Returns:
- Type
- Promise.<void>
-
reset( [gs])
-
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:
Name Type Argument Description gs
Core.PDFNet.GState <optional>
GState (graphics state) object. If NULL or unspecified, resets graphics state to default. Returns:
- Type
- Promise.<void>
-
takeOwnership()
-
Take the ownership of this object, so that PDFNet.runWithCleanup won't destroy this object.
- Inherited From:
Returns:
- Type
- void