Recipe

Recipe

new Recipe(src, output, optionsopt)

Source:

Create a pdfDoc

Parameters:
Name Type Attributes Description
src string

The file path or Buffer of the src file.

output string

The path of the output file.

options Object <optional>

The options for pdfDoc

Properties
Name Type Attributes Description
version number <optional>

The pdf version

author string <optional>

The author

title string <optional>

The title

subject string <optional>

The subject

colorspace string <optional>

The default colorspace: rgb, cmyk, gray

keywords Array.<string> <optional>

The array of keywords

password string <optional>

permission password

userPassword string <optional>

this 'view' password also enables encryption

ownerPassword string <optional>

this allows owner to 'edit' file

userProtectionFlag string <optional>

encryption security level (see permissions)

fontSrcPath string | Array.<string> <optional>

directory location(s) of additional fonts

Methods

(static) annot(x, y, subtype, optionsopt)

Source:
To Do:
  • support for rich texst RC
  • support for opacity CA

Create an annotation

Parameters:
Name Type Attributes Description
x number

The coordinate x

y number

The coordinate y

subtype string

The markup annotation type 'Text'|'FreeText'|'Line'|'Square'|'Circle'|'Polygon'|'PolyLine'|'Highlight'|'Underline'|'Squiggly'|'StrikeOut'|'Stamp'|'Caret'|'Ink'|'FileAttachment'|'Sound'

options Object <optional>

The options

Properties
Name Type Attributes Default Description
title string <optional>

The title.

open boolean <optional>
false

Open the annotation by default?

flag 'invisible' | 'hidden' | 'print' | 'nozoom' | 'norotate' | 'noview' | 'readonly' | 'locked' | 'togglenoview' <optional>

The flag property

icon 'Comment' | 'Key' | 'Note' | 'Help' | 'NewParagraph' | 'Paragraph' | 'Insert' <optional>

The icon of annotation.

width number <optional>

Width

height number <optional>

Height

(static) appendPage(pdfSrc, pages)

Source:

Append pages from the other pdf to the current pdf

Parameters:
Name Type Description
pdfSrc string

The path for the other pdf.

pages number | Array.<number>

The page number or the array of page numbers to be appended.

(static) arc(x, y, radius, startAngleopt, endAngleopt, optionsopt)

Source:

Draw an arc of a circle.

Parameters:
Name Type Attributes Default Description
x number

the x coordinate of the arc center point

y number

the y coordinate of the arc center point

radius number

the distance from the given x,y coordinates from which to produce the arc

startAngle number <optional>
0

the start of the arc in degree units +/- 0 through 360. Positive values go clockwise, Negative values, counterclockwise.

endAngle number <optional>
360

the end of the arc in degree units +/- 0 through 360. Positive values go clockwise, Negative values, counterclockwise.

options Object <optional>
Properties
Name Type Attributes Default Description
color string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

stroke string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

fill string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

lineWidth number <optional>

The line width

opacity number <optional>

The opacity

dash Array.<number> <optional>

The dash style [number, number]

rotation number <optional>
0

Accept: +/- 0 through 360.

rotationOrigin Array.<number> <optional>

[originX, originY] Default: x, y

(static) arrow(x, y, optionsopt)

Source:

Draw an arrow

Parameters:
Name Type Attributes Description
x number

x-coordinate position

y number

y-coordinate position

options Object <optional>

arrow and polygon options

Properties
Name Type Attributes Default Description
type number <optional>
0

indicates the type of arrow head to produce. (0-'triangle', 1-'dart', 2-'kite') Number or name may be used. Note, that the value of base offset in head option overrides this value.

head number | Array.<number> <optional>
[10,20,0]

defines the length, width and base offset of arrow head. A single number can be used to assign both the length and width of arrow, giving the base offset value as zero.

shaft number | Array.<number> <optional>
[10,10]

defines the length and width of the arrow shaft.

double Boolean <optional>
false

indicate double headed arrow production.

at string <optional>

position and/or rotate at "head" or "tail" of arrow instead of at center.

(static) chroma(name, value, colorspace)

Source:

Associate color values to names

The colorspace parameter is optional. When it is missing, the colorspace is automatically determined by the given color value. Note that the special PDF color space called 'separation' may also be used. The color value is then treated as the alternative color when the named 'separation' color is unavailable.

If the 'name' parameter is '!load', the second parameter is the name of a JSON formatted file containing a formatted list of defined colors associated with the color spaces rgb, cmyk, gray, or separation (think PANTONE color definitions). This file will be merged with existing set of known colors. The color values must be specified as hex values.

For example, { 'rgb': {'purple':'ff00ff', 'red':'#ff0000'}, 'cmyk': {'cyan':'ff000000', 'magenta':'%0,100,0,0'}, 'gray': {'grey':'#33'} }

Parameters:
Name Type Description
name string

the name to be associated to given color value, or '!load'

value string | Array.<number>

the color value (HexColor, DecimalColor, or PercentColor), or name of '!load' file

colorspace string

one of the followning: 'rgb', 'cmyk', 'gray', 'separation';

(static) circle(x, y, radius, optionsopt)

Source:

Draw a circle

Parameters:
Name Type Attributes Description
x number

The coordinate x

y number

The coordinate y

radius number

The radius

options Object <optional>

The options

Properties
Name Type Attributes Description
color string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

stroke string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

fill string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

lineWidth number <optional>

The line width

opacity number <optional>

The opacity

dash Array.<number> <optional>

The dash style [number, number]

(static) comment(text, x, y, optionsopt)

Source:

Create a comment annotation

Parameters:
Name Type Attributes Description
text string

The text content

x number

The coordinate x

y number

The coordinate y

options Object <optional>

The options

Properties
Name Type Attributes Default Description
title string <optional>

The title.

date string <optional>

The date.

open boolean <optional>
false

Open the annotation by default?

richText boolean <optional>

Display with rich text format, text will be transformed automatically, or you may pass in your own rich text starts with "<?xml..."

flag 'invisible' | 'hidden' | 'print' | 'nozoom' | 'norotate' | 'noview' | 'readonly' | 'locked' | 'togglenoview' <optional>

The flag property

(static) createPage(pageWidth_or_pageSizeNameopt, pageHeight_or_rotationopt, marginsopt)

Source:

Create a new page, specifying either actual width and height, or the name of a supported page size (eg. 'letter', )

Parameters:
Name Type Attributes Default Description
pageWidth_or_pageSizeName number | string <optional>
'letter'

The page width, or name of medium size. Known named medium sizes: executive, folio, legal, letter, ledger, tabloid, a0-a10, b0-b10, c0-c10, ra0-ra4, sra0-ara4

pageHeight_or_rotation number <optional>

The page height, or rotation (90) when when page size name given.

margins object <optional>

page margin definitions.

Properties
Name Type Attributes Description
left number <optional>

Left margin.

right number <optional>

Right margin.

top number <optional>

Top margin.

bottom number <optional>

Bottom margin.

(static) custom(keyopt, valueopt)

Source:

Add custom information to pdf

Parameters:
Name Type Attributes Description
key string <optional>

The key

value string <optional>

The value

(static) editPage(pageNumber)

Source:

Start editing a page

Parameters:
Name Type Description
pageNumber number

The page number to be edited.

(static) ellipse(cx, cy, rx, ry, options)

Source:

Draw an ellipse

Parameters:
Name Type Description
cx number

x-coordinate of center point of ellipse

cy number

y-coordinate of center point of ellipse

rx number

radius length from the center point along x-axis

ry number

radius length from the center point along y-axis

options Object
Properties
Name Type Attributes Description
color string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

stroke string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

fill string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

lineWidth number <optional>

The line width

opacity number <optional>

The opacity

dash Array.<number> <optional>

The dash style [number, number]

rotation number <optional>

Accept: +/- 0 through 360. Default: 0

rotationOrigin Array.<number> <optional>

[originX, originY] Default: x, y

(static) encrypt(options)

Source:

Encrypt the pdf

Parameters:
Name Type Description
options Object

The options

Properties
Name Type Attributes Description
password string <optional>

The permission password.

ownerPassword string <optional>

The password for editing.

userPassword string <optional>

The password for viewing & encryption.

userProtectionFlag number <optional>

The flag for the security level.

(static) endPage()

Source:

Finish a page

(static) image(imgSrc, x, y, optionsopt)

Source:

Place images to pdf

Parameters:
Name Type Attributes Description
imgSrc string

The path for the image. [JPEG, PNG, TIFF]

x number

The coordinate x

y number

The coordinate y

options Object <optional>

The options

Properties
Name Type Attributes Default Description
width number <optional>

The new width

height number <optional>

The new height

scale number <optional>

Scale the image from the original width and height.

keepAspectRatio boolean <optional>
true

Keep the aspect ratio.

opacity number <optional>

The opacity.

align string <optional>

'center center'...

(static) info(optionsopt)

Source:

Add new PDF information, or retrieve existing PDF information.

Parameters:
Name Type Attributes Description
options Object <optional>

The options (when missing obtains existing PDF information)

Properties
Name Type Attributes Description
version number <optional>

The pdf version

author string <optional>

The author

title string <optional>

The title

subject string <optional>

The subject

keywords Array.<string> <optional>

The array of keywords

(static) insertPage(afterPageNumber, pdfSrc, srcPageNumber)

Source:

Insert a page from the other pdf

Parameters:
Name Type Description
afterPageNumber number

The page number for insertion.

pdfSrc string

The path for the other pdf

srcPageNumber number

The page number to be insterted from the other pdf.

(static) layout(id, x, y, width, height, optionsopt)

Source:

Define text column layout

Parameters:
Name Type Attributes Description
id number | string

The identifier to be associated with the layout. (See 'text' layout option)

x number

The coordinate x used to position text columns on page. When zero, left margin used.

y number

The coordinate y used to position text columns on page. When zero, top margin used.

width number

The width of a text column. When zero, space between left and right margin used.

height number

The height of a text column. When zero, space between top and bottom margin used.

options object <optional>

The options.

Properties
Name Type Attributes Default Description
columns number <optional>

Represents the number of columns in which to divide the given width.

gap number <optional>
18

Defines the separation between layout columns, units in points.

reset boolean <optional>

True indicates that the a new layout should be produced for the given layout id, so any previous layout associated with the given id will be lost.

(static) line(coordinates, optionsopt)

Source:

Draw a line

Parameters:
Name Type Attributes Description
coordinates Array.<number>

The array of coordinate [[x,y], [m,n]]

options Object <optional>

The options

Properties
Name Type Attributes Description
color string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

stroke string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

lineWidth number <optional>

The line width

opacity number <optional>

how transparent should line be, from 0: invisible to 1: opaque

dash Array.<number> <optional>

The dash pattern [dashSize, gapSize] or [dashAndGapSize]

dashPhase number <optional>

distance into dash pattern at which to start dash (default: 0, immediately)

lineCap string <optional>

open line end style, 'butt', 'round', or 'square' (default: 'round')

lineJoin string <optional>

joined line end style, 'miter', 'round', or 'bevel' (default: 'round')

miterLimit number <optional>

limit at which 'miter' joins are forced to 'bevel' (default: 1.414)

(static) lineTo(x, y, optionsopt)

Source:

Draw a line from current position

Parameters:
Name Type Attributes Description
x number

The coordinate x

y number

The coordinate y

options Object <optional>

The options

Properties
Name Type Attributes Description
color string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

stroke string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

lineWidth number <optional>

The line width

opacity number <optional>

how transparent should line be, from 0: invisible to 1: opaque

dash Array.<number> <optional>

The dash pattern [dashSize, gapSize] or [dashAndGapSize]

dashPhase number <optional>

distance into dash pattern at which to start dash (default: 0, immediately)

lineCap string <optional>

open line end style, 'butt', 'round', or 'square' (default: 'round')

lineJoin string <optional>

joined line end style, 'miter', 'round', or 'bevel' (default: 'round')

miterLimit number <optional>

limit at which 'miter' joins are forced to 'bevel' (default: 1.414)

(static) margins(leftopt, rightopt, topopt, bottomopt) → {object}

Source:

Set/Get current page margins.

Parameters:
Name Type Attributes Description
left number | object <optional>

Left margin width or an object holding margin properties to be set. Valid margin property names are: left, right, top, bottom.

right number <optional>

Right margin width.

top number <optional>

Top margin height.

bottom number <optional>

Bottom margin height.

Returns:

When parameters are given, the value returned is the recipe handle. When no parameters given, the return value is the current page margin object.

Type
object

(static) movedown(linesopt, returnCoordsopt) → {Object|Array.<number>}

Source:

Move text positioning down N lines in text box

Parameters:
Name Type Attributes Default Description
lines number <optional>
1

the number of lines to reposition x and y coordinates

returnCoords Boolean <optional>
false

indicate whether or not to return [x,y] coordinates

Returns:
  • when returnCoord false, the recipe object, when true, the new [x,y] coordinates.
Type
Object | Array.<number>

(static) moveTo(x, y)

Source:

move the current position to target position

Parameters:
Name Type Description
x number

The coordinate x

y number

The coordinate y

(static) n_gon(cx, cy, radius, sidesopt, optionsopt)

Source:

Draw an N-sided regular polygon

Parameters:
Name Type Attributes Default Description
cx number

x-coordinate of center point of regular polygon

cy number

y-coordinate of center point of regular polygon

radius number

The radius, distance from the center of the polygon to a vertice.

sides number <optional>
3

the number of sides of the regular polygon

options Object <optional>

The options

Properties
Name Type Attributes Default Description
color string | Array.<number> <optional>

HexColor or DecimalColor

stroke string | Array.<number> <optional>

HexColor or DecimalColor

fill string | Array.<number> <optional>

HexColor or DecimalColor

lineWidth number <optional>

The line width

opacity number <optional>

The opacity

dash Array.<number> <optional>

The dash style [number, number]

rotation number <optional>
0

Accept: +/- 0 through 360.

rotationOrigin Array.<number> <optional>
[cx,cy]

[originX, originY]

rotationVertice number <optional>

the number of the vertice to be used as rotation origin

skewX number <optional>

the angle skew off the x-axis

skewY number <optional>

the angle skew off the y-axis.

(static) overlay(pdfSrc, x, y)

Source:

Overlay a pdf to the current pdf

Parameters:
Name Type Attributes Description
pdfSrc string

The path for the overlay pdf

x number

The coordinate x

y number

The coordinate y

options.scale number <optional>

Scale the overlay pdf, default is 1

options.keepAspectRatio boolean <optional>

To keep the aspect ratio when scaling, default is true

options.fitWidth boolean <optional>

To set the width to 100% (use with keepAspectRatio=true)

options.fitHeight boolean <optional>

To set the height to 100% (use with keepAspectRatio=true)

(static) pageInfo(pageNumber)

Source:

Get page information

Parameters:
Name Type Description
pageNumber number

The page number.

(static) permission(flags)

Source:

Encryption user access permissions

This function supplies the numeric value for the encrypt function's 'userProtectionFlag' option. When no argument is given, the default 'print' value is used.

Parameters:
Name Type Description
flags string

from the list print, modify, copy, edit, fillform, extract, assemble, and printbest More than one may be specified by using a comma to separate the names in the input string.

(static) polygon(coordinates, optionsopt)

Source:

Draw a polygon

Parameters:
Name Type Attributes Description
coordinates Array.<number>

The array of coordinate [[x,y], ... [m,n]]

options Object <optional>

The options

Properties
Name Type Attributes Description
color string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

stroke string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

fill string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

lineWidth number <optional>

The line width

opacity number <optional>

The opacity

dash Array.<number> <optional>

The dash pattern [dashSize, gapSize] or [dashAndGapSize]

dashPhase number <optional>

distance into dash pattern at which to start dash (default: 0, immediately)

rotation number <optional>

Accept: +/- 0 through 360. Default: 0

rotationOrigin Array.<number> <optional>

[originX, originY] Default: x, y

lineCap string <optional>

open line end style, 'butt', 'round', or 'square' (default: 'round')

lineJoin string <optional>

joined line end style, 'miter', 'round', or 'bevel' (default: 'round')

miterLimit number <optional>

limit at which 'miter' joins are forced to 'bevel' (default: 1.414)

(static) rectangle(x, y, width, height, optionsopt)

Source:

Draw a rectangle

Parameters:
Name Type Attributes Description
x number

The coordinate x

y number

The coordinate y

width number

The width

height number

The height

options Object <optional>

The options

Properties
Name Type Attributes Description
color string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

stroke string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

fill string | Array.<number> <optional>

HexColor, PercentColor or DecimalColor

lineWidth number <optional>

The line width

opacity number <optional>

The opacity

dash Array.<number> <optional>

The dash style [number, number]

rotation number <optional>

Accept: +/- 0 through 360. Default: 0

rotationOrigin Array.<number> <optional>

[originX, originY] Default: x, y

borderRadius number | Array.<number> <optional>

radius size for rounded corners.Error When a one to four number array can be used to give specific sizees to each corner. The numbering starts from the top, left corner, and goes clockwise around the text box. Missing values in the array are filled in by opposite corner values.

(static) registerFont(fontName, fontSrcPath, typeopt)

Source:

Register a custom font

Parameters:
Name Type Attributes Default Description
fontName string

The font name will be used in text

fontSrcPath string

The path to the font file.

type string <optional>
'regular'

The font type, one of 'bold', 'bold-italic', 'italic'

(static) split(outputDir, prefix)

Source:

Split the pdf

Parameters:
Name Type Description
outputDir string

The path for the output pdfs.

prefix string

${prefix}-${i+1}.pdf.

(static) star(cx, cy, pointsopt, optionsopt)

Source:

Draw an N pointed star

Parameters:
Name Type Attributes Default Description
cx number

x-coordinate of center point of regular polygon

cy number

y-coordinate of center point of regular polygon

points number <optional>
5

number of points on star

options Object <optional>

The options

Properties
Name Type Attributes Description
color string | Array.<number> <optional>

HexColor or DecimalColor

stroke string | Array.<number> <optional>

HexColor or DecimalColor

fill string | Array.<number> <optional>

HexColor or DecimalColor

lineWidth number <optional>

The line width

opacity number <optional>

The opacity

dash Array.<number> <optional>

The dash style [number, number]

rotation number <optional>

Accept: +/- 0 through 360. Default: 0

rotationOrigin Array.<number> <optional>

[originX, originY] Default: x, y

skewX number <optional>

the angle skew off the x-axis

skewY number <optional>

the angle skew off the y-axis.

(static) table(x, y, contents, optionsopt)

Source:

Display text data in tabular form

Parameters:
Name Type Attributes Description
x number

The coordinate x used to position table on page

y number

The coordinate y used to position table on page

contents Array.<object>

the data to be placed into the table

options object <optional>

The options

Properties
Name Type Attributes Default Description
height number <optional>

The height designation of the table

order string | Array.<string> <optional>

Defines the order of the named columns in the table. It can also be used to choose a subset of the actual data found in the given contents.

columns Array.<object> <optional>

Holds the defining options for columns in the table.

Properties
Name Type Attributes Default Description
name string <optional>

The name of the content data field to be associated with the column. This field is mandatory when supplying column options.

text string <optional>

The title to be applied to the column header. When missing, the data field name is used.

width number <optional>
100

The width of table column.

cell object <optional>

Holds the options to be applied to a column table cell. All textBox options from the 'text' interface can be used here.

color string | Array.<number> <optional>

Text color (HexColor, PercentColor or DecimalColor)

opacity number <optional>
1

opacity

font string <optional>
Helvetica

The font. 'Arial', 'Helvetica'...

size number <optional>
14

The font size

renderer function <optional>

function to be called which can be used to modify the text options for a particular table cell. The function is called with the parameters (text, data), where 'text' is the text to be written in the cell and 'data' is an object holding all the text elements in the table row. The function returns an object with the text attributes that are to be modified for the table cell.

header object | boolean <optional>
false

When true, the column name associated with a column will appear at the top of the column. When presented as an object it is the set of unique options to be applied to column headers. All 'text' interface options can be used.

Properties
Name Type Attributes Description
cell object <optional>

All textBox options from the 'text' interface can be used here.

border object <optional>

Used to define table and cell border characteristics

Properties
Name Type Attributes Default Description
width number <optional>
.5

thickness of lines used in border.Array

stroke string | Array.<number> <optional>

line color (HexColor, PercentColor or DecimalColor)

overflow function <optional>

Called when the next table entry is going to expand the table beyond the given height or page boundary. Its parameters are (self, row) where 'self' is the recipe handle so that other recipe interfaces can be called, and the row number of the data which caused the data overflow. The return value can be 'true' which indicates that data processing should stop, or 'false' which indicates that the data should continue being processed with the original [x,y] coordinates, or it can be an object containing a 'position' property indicating the [x,y] coordinates where the next table for the remaining data should start.

row object <optional>

text properties to be applied to all cells in a table row.

Properties
Name Type Attributes Description
cell object <optional>

All textBox options from the 'text' interface can be used here.

nth string <optional>

'even|odd', indicating that the properties should be applied only to 'even' or 'odd' rows.

(static) text(text, x, y, optionsopt)

Source:
To Do:
  • support break words

Write text elements

Parameters:
Name Type Attributes Description
text string

The text content

x number

The coordinate x

y number

The coordinate y

options Object <optional>

The options

Properties
Name Type Attributes Default Description
color string | Array.<number> <optional>

Text color (HexColor, PercentColor or DecimalColor)

opacity number <optional>
1

opacity

rotation number <optional>
0

Accept: +/- 0 through 360.

rotationOrigin Array.<number> <optional>
[x,y]

[originX, originY]

font string <optional>
Helvetica

The font. 'Arial', 'Helvetica'...

size number <optional>
14

The font size

charSpace number <optional>
0

space to be added between characters, units in points.

align string <optional>
'left top'

This is the alignment of the text in relationship to its position coordinates, specified as 'horizontal vertical', where horizontal is either 'left', 'center' or 'right and vertical is either 'top', 'center' or bottom.

highlight Object | Boolean <optional>

Text markup annotation.

underline Object | Boolean <optional>

Text markup annotation.

strikeOut Object | Boolean <optional>

Text markup annotation.

flow Boolean <optional>
false

Used to activate/deactivate text flow which is the ability to use multiple calls to 'text' to create an overall text box.

layout number | string <optional>

An identifier of the layout to be associated with given text.

overflow function <optional>

Called when the text is going to exceed the area of the given text object. Intended for column layouts. Its parameter is (self) where 'self' is the recipe handle so that other recipe interfaces can be called. The return value can be 'true' which indicates that text processing should stop, or 'false' which indicates that the text should continue being processed with the original [x,y] coordinates, or it can be an object containing a 'column' property indicating either a layout column index or a set of [x,y] coordinates where the next set of layout columns should be positioned for the remaining text.

hilite Boolean | Object <optional>
false

Used to hilite given text.

Properties
Name Type Attributes Default Description
color string | Array.<number> <optional>
yellow

text hilite color (HexColor, PercentColor or DecimalColor)

opacity number <optional>
.5

text hilite color opacity

textBox Object <optional>

Text Box to fit in.

Properties
Name Type Attributes Default Description
width number <optional>
100

Text Box width

height number <optional>

Text Box fixed height

minHeight number <optional>
0

Text Box minimum height

padding number | Array.<number> <optional>
0

Text Box padding, [top, right, bottom, left]

lineHeight number <optional>
0

Text Box line height

wrap string | Boolean <optional>
'auto'

Text wrapping mechanism, may be true, false, 'auto', 'clip', 'trim', 'ellipsis'. All the option values that are not equivalent to 'auto' dictate how the text which does not fit on a line is to be truncated. True is equivalent to 'auto'. False is equivalent to 'ellipsis'.

textAlign string <optional>
'left top'

Alignment inside text box, specified as 'horizontal vertical', where horizontal is one of: 'left', 'center', 'right', 'justify' and veritical is one of: 'top', 'center', 'bottom'.

style Object <optional>

Text Box styles

Properties
Name Type Attributes Default Description
lineWidth number <optional>
2

Text Box border width

stroke string | Array.<number> <optional>

Text Box border color (HexColor, PercentColor or DecimalColor)

dash Array.<number> <optional>
[]

Text Box border border dash style [number, number]

fill string | Array.<number> <optional>

Text Box border background color (HexColor, PercentColor or DecimalColor)

opacity number <optional>
1

Text Box border background opacity

borderRadius boolean | number | Array.<number> <optional>
0

Border radius to apply to get rounded corners. When true is given, the default radius size for all corners is 5. A four number array may be used to give specific sizees to each corner. The numbering starts from the top, left corner, and goes clockwise around the text box.

(static) textDimensions(text, optionsopt) → {Object}

Source:

Get text dimensions

Parameters:
Name Type Attributes Description
text string

text to be measured

options Object <optional>

The options

Properties
Name Type Attributes Default Description
font string <optional>
'helvetica'

name of font from which measurements are to be taken

size number <optional>
14

size of font to be used in taking measurements

charSpace number <optional>
0

character spacing being applied to the given text.

Returns:

measurement components of given text: width, height, xMin, xMax, yMin, yMax

Type
Object

(static) triangle(x, y, traits, optionsopt)

Source:

Draw a triangle, by specifying three side lengths, two side lengths and one inclusive angle, one side length and two adjacent angles, or with a set of vertices.

Parameters:
Name Type Attributes Description
x number

x-coordinate used to position triangle, by default associated with left vertex of triangle base.

y number

y-coordinate used to position triangle, by default associated with left vertex of triangle base.

traits Array.<number>

the data defining the triangle. Angles are specified as degrees, sides in units of points (1/72 in.).

options Object <optional>

The options

Properties
Name Type Attributes Default Description
traitID string <optional>
'sss'

indicates what type of data is being passed in the traits parameter. ('sss'- three side lengths, 'sas' - side-angle-side (sideA, <C, sideB), 'asa' - angle-side-angle (<B, sideC, <A), or 'vtx' - three vertex points [x,y])

position string <optional>
'b'

the position of the triangle to be set at the given x,y coordinates. The values can be one of: 'A' - the A vertex (right vertex of triangle base), 'B' - the B vertex (left vertex of triangle base), 'C' - the C vertex (apex of triangle), 'centroid', 'circumcenter', or 'incenter' of the triangle.

flipX Boolean <optional>
false

flip triangle up to down through rotation point.

flipY Boolean <optional>
false

flip triangle right to left through rotation point.

color string | Array.<number> <optional>

HexColor or DecimalColor

stroke string | Array.<number> <optional>

HexColor or DecimalColor

fill string | Array.<number> <optional>

HexColor or DecimalColor

lineWidth number <optional>

The line width

opacity number <optional>

The opacity

dash Array.<number> <optional>

The dash style [number, number]

rotation number <optional>

Accept: +/- 0 through 360. Default: 0

rotationOrigin Array.<number> <optional>

[originX, originY] Default: x, y

skewX number <optional>

the angle skew off the x-axis

skewY number <optional>

the angle skew off the y-axis.

endPDF(callback)

Source:

End the pdfDoc

Parameters:
Name Type Description
callback function

The callback function.

register(key, callback)

Source:

Register callback procedure with hummus-recipe.

Parameters:
Name Type Description
key string

name assigned to given callback. Note that if an actual function is being registered, and its given name is what is to be used to access it, the key is unnecessary.

callback function

procedure that can be accessed through hummus-recipe