forked from parallax/jsPDF
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update examples, make from HTML demo the first one
- Loading branch information
Showing
4 changed files
with
54 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,15 @@ | ||
var pdf = new jsPDF('p','in','letter') | ||
var doc = new jsPDF(); | ||
|
||
// source can be HTML-formatted string, or a reference | ||
// to an actual DOM element from which the text will be scraped. | ||
, source = $('#fromHTMLtestdiv')[0] | ||
|
||
// we support special element handlers. Register them with jQuery-style | ||
// ID selector for either ID or node name. ("#iAmID", "div", "span" etc.) | ||
// There is no support for any other type of selectors | ||
// (class, of compound) at this time. | ||
, specialElementHandlers = { | ||
// element with id of "bypass" - jQuery style selector | ||
'#bypassme': function(element, renderer){ | ||
// true = "handled elsewhere, bypass text extraction" | ||
return true | ||
// We'll make our own renderer to skip this editor | ||
var specialElementHandlers = { | ||
'#editor': function(element, renderer){ | ||
return true; | ||
} | ||
}; | ||
|
||
// all coords and widths are in jsPDF instance's declared units | ||
// 'inches' in this case | ||
pdf.fromHTML( | ||
source // HTML string or DOM elem ref. | ||
, 0.5 // x coord | ||
, 0.5 // y coord | ||
, { | ||
'width':7.5 // max width of content on PDF | ||
, 'elementHandlers': specialElementHandlers | ||
} | ||
); | ||
// All units are in the set measurement for the document | ||
// This can be changed to "pt" (points), "mm" (Default), "cm", "in" | ||
doc.fromHTML($('body').get(0), 15, 15, { | ||
'width': 170, | ||
'elementHandlers': specialElementHandlers | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters