new Recipe(src, output, optionsopt)
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
|
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
|
(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)
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
|
(static) arrow(x, y, optionsopt)
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
|
(static) chroma(name, value, colorspace)
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)
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
|
(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
|
(static) createPage(pageWidth_or_pageSizeNameopt, pageHeight_or_rotationopt, marginsopt)
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
|
(static) custom(keyopt, valueopt)
Add custom information to pdf
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
string |
<optional> |
The key |
value |
string |
<optional> |
The value |
(static) editPage(pageNumber)
Start editing a page
Parameters:
Name | Type | Description |
---|---|---|
pageNumber |
number | The page number to be edited. |
(static) ellipse(cx, cy, rx, ry, options)
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
|
(static) encrypt(options)
- Source:
Encrypt the pdf
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | The options Properties
|
(static) endPage()
Finish a page
(static) image(imgSrc, x, y, optionsopt)
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
|
(static) info(optionsopt)
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
|
(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)
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
|
(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
|
(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
|
(static) margins(leftopt, rightopt, topopt, bottomopt) → {object}
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>}
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)
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
|
(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)
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
|
(static) rectangle(x, y, width, height, optionsopt)
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
|
(static) registerFont(fontName, fontSrcPath, typeopt)
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)
Split the pdf
Parameters:
Name | Type | Description |
---|---|---|
outputDir |
string | The path for the output pdfs. |
prefix |
string |
|
(static) star(cx, cy, pointsopt, optionsopt)
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
|
(static) table(x, y, contents, optionsopt)
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
|
(static) text(text, x, y, optionsopt)
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
|
(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
|
Returns:
measurement components of given text: width, height, xMin, xMax, yMin, yMax
- Type
- Object
(static) triangle(x, y, traits, optionsopt)
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
|
endPDF(callback)
End the pdfDoc
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | The callback function. |
register(key, callback)
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 |