<div id="content">
<h3>Hello, this is a H3 tag</h3>
<p>a pararaph</p>
</div>
<div id="editor"></div>
<button id="cmd">generate PDF</button>
var doc = new jsPDF();
var specialElementHandlers = {
'#editor': function (element, renderer) {
return true;
}
};
$('#cmd').click(function () {
doc.fromHTML($('#content').html(), 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});
doc.save('sample-file.pdf');
});
You should make an extern for jsPDF I think. It just has to include the functions you are calling.
Per my tweet, you can use the JQuery extern too.
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.
(function () { "use strict";
var Test = function() { };
Test.main = function() {
var doc = new jsPDF();
var specialElementHandlers = { '#editor' : function(element,renderer) {
return true;
}};
new js.JQuery("#cmd").click(function(_) {
doc.fromHTML(new js.JQuery("#content").html(),15,15,{ width : 170, elementHandlers : specialElementHandlers});
doc.save("sample-file.pdf");
});
};
var js = {};
var q = window.jQuery;
js.JQuery = q;
})();
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="http://localhost:8000/jsPDF/dist/jspdf.min.js"></script>
<script src="http://localhost:8000/pdf.js"></script>
</head>
<body>
<div id="content">
<h3>Hello, this is a H3 tag</h3>
<p>a pararaph</p>
</div>
<div id="editor"></div>
<button id="cmd">generate PDF</button>
</body>
</html>
Move the script tags at the of the body - the code isn't waiting for document ready event.