Class Index | File Index

Classes


Class jsPDF


Defined in: jspdf.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
jsPDF(orientation, unit, format)
Creates new jsPDF document object instance
Field Summary
Field Attributes Field Name and Description
 
jsPDF.API
jsPDF.API is a STATIC property of jsPDF class.
 
Is an Object providing a mapping from human-readable to integer flag values designating the varieties of line cap and join styles.
Method Summary
Method Attributes Method Name and Description
 
Adds (and transfers the focus to) new page to the PDF document.
 
circle(x, y, r, style)
Adds an circle to PDF
 
ellipse(x, y, rx, rx, style)
Adds an ellipse to PDF
 
Returns an object - a tree of fontName to fontStyle relationships available to active PDF document.
 
lines(lines, x, y, scale)
Adds series of curves (straight lines or cubic bezier curves) to canvas, starting at `x`, `y` coordinates.
 
output(type, options)
Generates the PDF document.
 
rect(x, y, w, h, style)
Adds a rectangle to PDF
 
setDrawColor(ch1, ch2, ch3, ch4)
Sets the stroke color for upcoming elements.
 
setFillColor(ch1, ch2, ch3, ch4)
Sets the fill color for upcoming elements.
 
setFont(fontName, fontStyle)
Sets text font face, variant for upcoming text elements.
 
Sets font size for upcoming text elements.
 
setFontStyle(style)
Switches font style or variant for upcoming text elements, while keeping the font face or family same.
 
setLineCap(style)
Sets the line cap styles See {jsPDF.CapJoinStyles} for variants
 
setLineJoin(style)
Sets the line join styles See {jsPDF.CapJoinStyles} for variants
 
setLineWidth(width)
Sets line width for upcoming lines.
 
Adds a properties to the PDF document
 
setTextColor(r, g, b)
Sets the text color for upcoming elements.
 
text(text, x, y, flags)
Adds text to page.
 
triangle(x1, y1, x2, y2, x3, y3, style)
Adds a triangle to PDF
Class Detail
jsPDF(orientation, unit, format)
Creates new jsPDF document object instance
Parameters:
orientation
One of "portrait" or "landscape" (or shortcuts "p" (Default), "l")
unit
Measurement unit to be used when coordinates are specified. One of "pt" (points), "mm" (Default), "cm", "in"
format
One of 'a3', 'a4' (Default),'a5' ,'letter' ,'legal'
Returns:
{jsPDF}
Field Detail
jsPDF.API
jsPDF.API is a STATIC property of jsPDF class. jsPDF.API is an object you can add methods and properties to. The methods / properties you add will show up in new jsPDF objects. One property is prepopulated. It is the 'events' Object. Plugin authors can add topics, callbacks to this object. These will be reassigned to all new instances of jsPDF. Examples: jsPDF.API.events['initialized'] = function(){ 'this' is API object } jsPDF.API.events['addFont'] = function(added_font_object){ 'this' is API object }
	jsPDF.API.mymethod = function(){
		// 'this' will be ref to internal API object. see jsPDF source
		// , so you can refer to built-in methods like so: 
		//	 this.line(....)
		//	 this.text(....)
	}
	var pdfdoc = new jsPDF()
	pdfdoc.mymethod() // <- !!!!!!

{Object} CapJoinStyles
Is an Object providing a mapping from human-readable to integer flag values designating the varieties of line cap and join styles.
Method Detail
{jsPDF} addPage()
Adds (and transfers the focus to) new page to the PDF document.
Returns:
{jsPDF}

{jsPDF} circle(x, y, r, style)
Adds an circle to PDF
Parameters:
{Number} x
Coordinate (in units declared at inception of PDF document) against left edge of the page
{Number} y
Coordinate (in units declared at inception of PDF document) against upper edge of the page
{Number} r
Radius (in units declared at inception of PDF document)
{String} style
(Defaults to active fill/stroke style) A string signalling if stroke, fill or both are to be applied.
Returns:
{jsPDF}

{jsPDF} ellipse(x, y, rx, rx, style)
Adds an ellipse to PDF
Parameters:
{Number} x
Coordinate (in units declared at inception of PDF document) against left edge of the page
{Number} y
Coordinate (in units declared at inception of PDF document) against upper edge of the page
{Number} rx
Radius along x axis (in units declared at inception of PDF document)
{Number} rx
Radius along y axis (in units declared at inception of PDF document)
{String} style
(Defaults to active fill/stroke style) A string signalling if stroke, fill or both are to be applied.
Returns:
{jsPDF}

{Object} getFontList()
Returns an object - a tree of fontName to fontStyle relationships available to active PDF document.
Returns:
{Object} Like {'times':['normal', 'italic', ... ], 'arial':['normal', 'bold', ... ], ... }

{jsPDF} lines(lines, x, y, scale)
Adds series of curves (straight lines or cubic bezier curves) to canvas, starting at `x`, `y` coordinates. All data points in `lines` are relative to last line origin. `x`, `y` become x1,y1 for first line / curve in the set. For lines you only need to specify [x2, y2] - (ending point) vector against x1, y1 starting point. For bezier curves you need to specify [x2,y2,x3,y3,x4,y4] - vectors to control points 1, 2, ending point. All vectors are against the start of the curve - x1,y1.
.lines([[2,2],[-2,2],[1,1,2,2,3,3],[2,1]], 212,110, 10) // line, line, bezier curve, line
Parameters:
{Array} lines
Array of *vector* shifts as pairs (lines) or sextets (cubic bezier curves).
{Number} x
Coordinate (in units declared at inception of PDF document) against left edge of the page
{Number} y
Coordinate (in units declared at inception of PDF document) against upper edge of the page
{Number} scale
(Defaults to [1.0,1.0]) x,y Scaling factor for all vectors. Elements can be any floating number Sub-one makes drawing smaller. Over-one grows the drawing. Negative flips the direction.
Returns:
{jsPDF}

{jsPDF} output(type, options)
Generates the PDF document. Possible values: datauristring (alias dataurlstring) - Data-Url-formatted data returned as string. datauri (alias datauri) - Data-Url-formatted data pushed into current window's location (effectively reloading the window with contents of the PDF). If `type` argument is undefined, output is raw body of resulting PDF returned as a string.
Parameters:
{String} type
A string identifying one of the possible output types.
{Object} options
An object providing some additional signalling to PDF generator.
Returns:
{jsPDF}

{jsPDF} rect(x, y, w, h, style)
Adds a rectangle to PDF
Parameters:
{Number} x
Coordinate (in units declared at inception of PDF document) against left edge of the page
{Number} y
Coordinate (in units declared at inception of PDF document) against upper edge of the page
{Number} w
Width (in units declared at inception of PDF document)
{Number} h
Height (in units declared at inception of PDF document)
{String} style
(Defaults to active fill/stroke style) A string signalling if stroke, fill or both are to be applied.
Returns:
{jsPDF}

{jsPDF} setDrawColor(ch1, ch2, ch3, ch4)
Sets the stroke color for upcoming elements. Depending on the number of arguments given, Gray, RGB, or CMYK color space is implied. When only ch1 is given, "Gray" color space is implied and it must be a value in the range from 0.00 (solid black) to to 1.00 (white) if values are communicated as String types, or in range from 0 (black) to 255 (white) if communicated as Number type. The RGB-like 0-255 range is provided for backward compatibility. When only ch1,ch2,ch3 are given, "RGB" color space is implied and each value must be in the range from 0.00 (minimum intensity) to to 1.00 (max intensity) if values are communicated as String types, or from 0 (min intensity) to to 255 (max intensity) if values are communicated as Number types. The RGB-like 0-255 range is provided for backward compatibility. When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each value must be a in the range from 0.00 (0% concentration) to to 1.00 (100% concentration) Because JavaScript treats fixed point numbers badly (rounds to floating point nearest to binary representation) it is highly advised to communicate the fractional numbers as String types, not JavaScript Number type.
Parameters:
{Number|String} ch1
Color channel value
{Number|String} ch2
Color channel value
{Number|String} ch3
Color channel value
{Number|String} ch4
Color channel value
Returns:
{jsPDF}

{jsPDF} setFillColor(ch1, ch2, ch3, ch4)
Sets the fill color for upcoming elements. Depending on the number of arguments given, Gray, RGB, or CMYK color space is implied. When only ch1 is given, "Gray" color space is implied and it must be a value in the range from 0.00 (solid black) to to 1.00 (white) if values are communicated as String types, or in range from 0 (black) to 255 (white) if communicated as Number type. The RGB-like 0-255 range is provided for backward compatibility. When only ch1,ch2,ch3 are given, "RGB" color space is implied and each value must be in the range from 0.00 (minimum intensity) to to 1.00 (max intensity) if values are communicated as String types, or from 0 (min intensity) to to 255 (max intensity) if values are communicated as Number types. The RGB-like 0-255 range is provided for backward compatibility. When ch1,ch2,ch3,ch4 are given, "CMYK" color space is implied and each value must be a in the range from 0.00 (0% concentration) to to 1.00 (100% concentration) Because JavaScript treats fixed point numbers badly (rounds to floating point nearest to binary representation) it is highly advised to communicate the fractional numbers as String types, not JavaScript Number type.
Parameters:
{Number|String} ch1
Color channel value
{Number|String} ch2
Color channel value
{Number|String} ch3
Color channel value
{Number|String} ch4
Color channel value
Returns:
{jsPDF}

{jsPDF} setFont(fontName, fontStyle)
Sets text font face, variant for upcoming text elements. See output of jsPDF.getFontList() for possible font names, styles.
Parameters:
{String} fontName
Font name or family. Example: "times"
{String} fontStyle
Font style or variant. Example: "italic"
Returns:
{jsPDF}

{jsPDF} setFontSize(size)
Sets font size for upcoming text elements.
Parameters:
{Number} size
Font size in points.
Returns:
{jsPDF}

{jsPDF} setFontStyle(style)
Switches font style or variant for upcoming text elements, while keeping the font face or family same. See output of jsPDF.getFontList() for possible font names, styles.
Parameters:
{String} style
Font style or variant. Example: "italic"
Returns:
{jsPDF}

{jsPDF} setLineCap(style)
Sets the line cap styles See {jsPDF.CapJoinStyles} for variants
Parameters:
{String|Number} style
A string or number identifying the type of line cap
Returns:
{jsPDF}

{jsPDF} setLineJoin(style)
Sets the line join styles See {jsPDF.CapJoinStyles} for variants
Parameters:
{String|Number} style
A string or number identifying the type of line join
Returns:
{jsPDF}

{jsPDF} setLineWidth(width)
Sets line width for upcoming lines.
Parameters:
{Number} width
Line width (in units declared at inception of PDF document)
Returns:
{jsPDF}

{jsPDF} setProperties(A)
Adds a properties to the PDF document
Parameters:
{Object} A
property_name-to-property_value object structure.
Returns:
{jsPDF}

{jsPDF} setTextColor(r, g, b)
Sets the text color for upcoming elements. If only one, first argument is given, treats the value as gray-scale color value.
Parameters:
{Number} r
Red channel color value in range 0-255
{Number} g
Green channel color value in range 0-255
{Number} b
Blue channel color value in range 0-255
Returns:
{jsPDF}

{jsPDF} text(text, x, y, flags)
Adds text to page. Supports adding multiline text when 'text' argument is an Array of Strings.
Parameters:
{String|Array} text
String or array of strings to be added to the page. Each line is shifted one line down per font, spacing settings declared before this call.
{Number} x
Coordinate (in units declared at inception of PDF document) against left edge of the page
{Number} y
Coordinate (in units declared at inception of PDF document) against upper edge of the page
{Object} flags
Collection of settings signalling how the text must be encoded. Defaults are sane. If you think you want to pass some flags, you likely can read the source.
Returns:
{jsPDF}

{jsPDF} triangle(x1, y1, x2, y2, x3, y3, style)
Adds a triangle to PDF
Parameters:
{Number} x1
Coordinate (in units declared at inception of PDF document) against left edge of the page
{Number} y1
Coordinate (in units declared at inception of PDF document) against upper edge of the page
{Number} x2
Coordinate (in units declared at inception of PDF document) against left edge of the page
{Number} y2
Coordinate (in units declared at inception of PDF document) against upper edge of the page
{Number} x3
Coordinate (in units declared at inception of PDF document) against left edge of the page
{Number} y3
Coordinate (in units declared at inception of PDF document) against upper edge of the page
{String} style
(Defaults to active fill/stroke style) A string signalling if stroke, fill or both are to be applied.
Returns:
{jsPDF}

Documentation generated by JsDoc Toolkit 2.4.0 on Mon Oct 15 2012 22:41:49 GMT-0700 (PDT)