html

jsPDF html PlugIn

Source:

Methods

(inner) html(source, optionsopt)

Source:

Generate a PDF from an HTML element or string using.

Example
var doc = new jsPDF();

doc.html(document.body, {
   callback: function (doc) {
     doc.save();
   },
   x: 10,
   y: 10
});
Parameters:
Name Type Attributes Description
source HTMLElement | string

The source HTMLElement or a string containing HTML.

options Object <optional>

Collection of settings

Properties
Name Type Attributes Description
callback function <optional>

The mandatory callback-function gets as first parameter the current jsPDF instance

margin number | Array.<number> <optional>

Page margins [top, right, bottom, left]. Default is 0.

autoPaging boolean | 'slice' | 'text' <optional>

The auto paging mode.

  • false: Auto paging is disabled.
  • true or 'slice': Will cut shapes or text chunks across page breaks. Will possibly slice text in half, making it difficult to read.
  • 'text': Trys not to cut text in half across page breaks. Works best for documents consisting mostly of a single column of text.
Default is true.
filename string <optional>

name of the file

image HTMLOptionImage <optional>

image settings when converting HTML to image

html2canvas Html2CanvasOptions <optional>

html2canvas options

fontFaces Array.<FontFace> <optional>

A list of font-faces to match when resolving fonts. Fonts will be added to the PDF based on the specified URL. If omitted, the font match algorithm falls back to old algorithm.

jsPDF jsPDF <optional>

jsPDF instance

x number <optional>

x position on the PDF document in jsPDF units.

y number <optional>

y position on the PDF document in jsPDF units.

width number <optional>

The target width in the PDF document in jsPDF units. The rendered element will be scaled such that it fits into the specified width. Has no effect if either the html2canvas.scale is specified or the windowWidth option is NOT specified.

windowWidth number <optional>

The window width in CSS pixels. In contrast to the html2canvas.windowWidth option, this option affects the actual container size while rendering and does NOT affect CSS media queries. This option only has an effect, if the width option is also specified.

Type Definitions

FontFace

Source:
Properties:
Name Type Attributes Description
family string

The name of the font-family.

style string | undefined

The style that this font-face defines, e.g. 'italic'.

weight string | number | undefined

The weight of the font, either as a string or a number (400, 500, 600, e.g.)

stretch string | undefined

The stretch of the font, e.g. condensed, normal, expanded.

src Array.<Object>

A list of URLs from where fonts of various formats can be fetched.

src string <optional>

url A URL to a font of a specific format.

src string <optional>

format Format of the font referenced by the URL.