Class PDFNet.ElementBuilder
PDFNet.ElementBuilder
Constructor Attributes | Constructor Name and Description |
---|---|
ElementBuilder is used to build new PDF::Elements (e.g.
|
Method Attributes | Method Name and Description |
---|---|
arcTo(x, y, width, height, start, extent)
Draw an arc with the specified parameters (lower left corner, width, height and angles).
|
|
arcTo2(xr, yr, rx, isLargeArc, sweep, endX, endY)
Draw an arc from the current point to the end point.
|
|
Closes the current subpath.
|
|
<static> |
PDFNet.ElementBuilder.create()
Constructor for an ElementBuilder object that can be used to build new PDF::Elements
(eg.
|
createEllipse(x, y, width, height)
Create an ellipse (or circle, if width == height) path Element.
|
|
createFormFromDoc(page, doc)
Create a Form XObject Element using the content of the existing page.
|
|
createFormFromPage(page)
Create a Form XObject Element using the content of the existing page.
|
|
createFormFromStream(form)
Create a Form XObject Element.
|
|
Create e_group_begin Element (i.e.
|
|
Create e_group_end Element (i.e.
|
|
createImage(img)
Create a content image Element out of a given document Image.
|
|
createImageFromMatrix(img, mtx)
Create a content image Element out of a given document Image.
|
|
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).
|
|
createNewTextRun(text_data)
Create a new text run.
|
|
createNewTextRunUnsigned(text_data)
Create a new text run.
|
|
createNewTextRunWithSize(text_data, text_data_sz)
Create a new text run.
|
|
createPath(buf_points, buf_seg_types)
Create a path Element using the given path segment data
|
|
createRect(x, y, width, height)
Create a rectangle path Element.
|
|
createShading(sh)
|
|
Start a text block ('BT' operator in PDF content stream).
|
|
createTextBeginWithFont(font, font_sz)
Start a text block ('BT' operator in PDF content stream).
|
|
Ends a text block.
|
|
Create e_text_new_line Element (i.e.
|
|
createTextNewLineWithOffset(dx, dy)
Create e_text_new_line Element (i.e.
|
|
createTextRun(text_data, font, font_sz)
Create a text run using the given font.
|
|
createTextRunUnsigned(text_data, font, font_sz)
Create a text run using the given font.
|
|
createTextRunWithSize(text_data, text_data_sz, font, font_sz)
Create a text run using the given font.
|
|
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.
|
|
destroy()
Frees the native memory of the object.
|
|
ellipse(x, y, width, height)
Add an ellipse (or circle, if rx == ry) to the current path as a complete subpath.
|
|
lineTo(x, y)
Draw a line from the current point to the given point.
|
|
moveTo(x, y)
Set the current point.
|
|
Starts building a new path Element that can contain an arbitrary sequence
of lines, curves, and rectangles.
|
|
pathEnd()
Finishes building of the path Element.
|
|
rect(x, y, width, height)
Add a rectangle to the current path as a complete subpath.
|
|
reset(gs)
The function sets the graphics state of this Element to the given value.
|
Class Detail
PDFNet.ElementBuilder(id)
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.
- Parameters:
- id
Method Detail
arcTo(x, y, width, height, start, extent)
Draw an arc with the specified parameters (lower left corner, width, height and angles).
- Parameters:
- {number} x
- The horizontal x coordinate of the lower left corner of the ellipse encompassing rectangle
- {number} y
- The horizontal y coordinate of the lower left corner of the ellipse encompassing rectangle
- {number} width
- overall width of the full ellipse (not considering the angular extents).
- {number} height
- overall height of the full ellipse (not considering the angular extents).
- {number} start
- starting angle of the arc in degrees
- {number} extent
- angular extent of the arc in degrees
arcTo2(xr, yr, rx, isLargeArc, sweep, endX, endY)
Draw an arc from the current point to the end point.
- Parameters:
- {number} xr
- x radius for the arc
- {number} yr
- y radius for the arc
- {number} rx
- x-axis rotation in degrees
- {boolean} 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
- {boolean} sweep
- direction in which arc is drawn (1 clockwise, 0 counterclockwise)
- {number} endX
- x coordinate of end point
- {number} endY
- y coordinate of end point
closePath()
Closes the current subpath.
<static>
{ElementBuilder}
PDFNet.ElementBuilder.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:
- {ElementBuilder} Returns an ElementBuilder object
{Element}
createEllipse(x, y, width, height)
Create an ellipse (or circle, if width == height) path Element.
- Parameters:
- {number} x
- The horizontal x coordinate of the ellipse center.
- {number} y
- The vertical y coordinate of the ellipse center.
- {number} width
- The width of the ellipse rectangle.
- {number} height
- The height of the ellipse rectangle.
- Returns:
- {Element} A promise that resolves to the path Element
{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:
- {Page} page
- A page used to create the Form XObject.
- {PDFDoc} doc
- Destination document for the Form XObject.
- Returns:
- {Element} A promise that resolves to an object of type: "Element" (generated documentation)
{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:
- {Page} page
- A page used to create the Form XObject.
- Returns:
- {Element} A promise that resolves to an object of type: "Element" (generated documentation)
{Element}
createFormFromStream(form)
Create a Form XObject Element.
- Parameters:
- {Obj} form
- a Form XObject content stream
- Returns:
- {Element} A promise that resolves to an object of type: "Element" (generated documentation)
{Element}
createGroupBegin()
Create e_group_begin Element (i.e. 'q' operator in PDF content stream).
The function saves the current graphics state.
- Returns:
- {Element} A promise that resolves to an object of type: "Element" (generated documentation)
{Element}
createGroupEnd()
Create e_group_end Element (i.e. 'Q' operator in PDF content stream).
The function restores the previous graphics state.
- Returns:
- {Element} A promise that resolves to an object of type: "Element" (generated documentation)
{Element}
createImage(img)
Create a content image Element out of a given document Image.
- Parameters:
- {Image} img
- the given image.
- Returns:
- {Element} A promise that resolves to an object of type: "Element" (generated documentation)
{Element}
createImageFromMatrix(img, mtx)
Create a content image Element out of a given document Image.
- Parameters:
- {Image} img
- the given image.
- {matrix2d} mtx
- the image transformation matrix.
- Returns:
- {Element} A promise that resolves to an object of type: "Element" (generated documentation)
{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:
- {Image} img
- the given image.
- {number} x
- The horizontal x position to place the lower left corner of the image
- {number} y
- The vertical x position to place the lower left corner of the image
- {number} hscale
- The horizontal scale of the image
- {number} vscale
- The vertical scale of the image
- Returns:
- {Element} A promise that resolves to an object of type: "Element" (generated documentation)
{Element}
createNewTextRun(text_data)
Create a new text run.
- Parameters:
- {string} text_data
- text to initialize the text run with.
- Returns:
- {Element} A promise that resolves to an object of type: "Element" (generated documentation)
{Element}
createNewTextRunUnsigned(text_data)
Create a new text run.
- Parameters:
- {string} text_data
- text to initialize the text run with. Uses unsigned characters.
- Returns:
- {Element} A promise that resolves to an object of type: "Element" (generated documentation)
{Element}
createNewTextRunWithSize(text_data, text_data_sz)
Create a new text run.
- Parameters:
- {string} text_data
- text to initialize the text run with.
- {number} text_data_sz
- size pf the text run.
- Returns:
- {Element} A promise that resolves to an object of type: "Element" (generated documentation)
{Element}
createPath(buf_points, buf_seg_types)
Create a path Element using the given path segment data
- Parameters:
- {Array} buf_points
- A buffer/array containing data on the points in the path. What each point represents is determined by the corresponding segment type.
- {Array} buf_seg_types
- 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:
- {Element} the path Element
{Element}
createRect(x, y, width, height)
Create a rectangle path Element.
- Parameters:
- {number} x
- The horizontal coordinate of the lower left corner of the rectangle.
- {number} y
- The vertical coordinate of the lower left corner of the rectangle.
- {number} width
- The width of the rectangle.
- {number} height
- The height of the rectangle.
- Returns:
- {Element} A promise that resolves to the path Element
{Element}
createShading(sh)
- Parameters:
- {Shading} 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.
- Returns:
- {Element} A promise that resolves to an object of type: "Element" (generated documentation)
{Element}
createTextBegin()
Start a text block ('BT' operator in PDF content stream).
- Returns:
- {Element} A promise that resolves to an object of type: "Element" (generated documentation)
{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:
- {Font} font
- font to set the text in the text block to
- {number} font_sz
- size to set the text in the text block to
- Returns:
- {Element} A promise that resolves to an object of type: "Element" (generated documentation)
{Element}
createTextEnd()
Ends a text block.
- Returns:
- {Element} A promise that resolves to an object of type: "Element" (generated documentation)
{Element}
createTextNewLine()
Create e_text_new_line Element (i.e. a T* operator in PDF content stream).
- Returns:
- {Element} A promise that resolves to the path Element
{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:
- {number} dx
- The horizontal x offset from the start of the current line
- {number} dy
- The vertical y offset from the start of the current line
- Returns:
- {Element} A promise that resolves to the path Element
{Element}
createTextRun(text_data, font, font_sz)
Create a text run using the given font.
- Parameters:
- {string} text_data
- text to initialize the text run with
- {Font} font
- font of the text in the text run
- {number} font_sz
- size of the text in the text run
- Returns:
- {Element} A promise that resolves to an object of type: "Element" (generated documentation)
{Element}
createTextRunUnsigned(text_data, font, font_sz)
Create a text run using the given font.
- Parameters:
- {string} text_data
- text to initialize the text run with. Uses unsigned characters.
- {Font} font
- font of the text in the text run
- {number} font_sz
- size of the text in the text run
- Returns:
- {Element} A promise that resolves to an object of type: "Element" (generated documentation)
{Element}
createTextRunWithSize(text_data, text_data_sz, font, font_sz)
Create a text run using the given font.
- Parameters:
- {string} text_data
- text to initialize the text run with
- {number} text_data_sz
- size of the text run
- {Font} font
- font of the text in the text run
- {number} font_sz
- size of the text in the text run
- Returns:
- {Element} A promise that resolves to an object of type: "Element" (generated documentation)
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:
- {number} cx1
- The x component of the first control point
- {number} cy1
- The y component of the first control point
- {number} cx2
- The x component of the second control point
- {number} cy2
- The y component of the second control point
- {number} x2
- The horizontal x component of the goal point
- {number} y2
- The vertical y component of the goal point
destroy()
Frees the native memory of the object.
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:
- {number} x
- The x coordinate of the ellipse center.
- {number} y
- The y coordinate of the ellipse center.
- {number} width
- The x radii of the ellipse.
- {number} height
- The y radii of the ellipse.
lineTo(x, y)
Draw a line from the current point to the given point.
- Parameters:
- {number} x
- The horizontal x component of the goal point
- {number} y
- The vertical y component of the goal point
moveTo(x, y)
Set the current point.
- Parameters:
- {number} x
- The horizontal x component of the point
- {number} y
- The vertical y component of the point
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.
- Returns:
- {Element} A promise that resolves to the path 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:
- {number} x
- The x coordinate of the lower left corner of the rectangle.
- {number} y
- The y coordinate of the lower left corner of the rectangle.
- {number} width
- The width of the rectangle.
- {number} height
- The height of the rectangle.
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:
- {GState} gs
- GState (graphics state) object. If NULL or unspecified, resets graphics state to default.