I try to use javascript library JSPDF for export my OpenLayers map but it doesn't work. I create my HTML :
And my Javascript :
$(document).ready(function () {
var doc = new jsPDF();
var specialElementHandlers = {
'#editor': function (element, renderer) {
console.log(1);
return true;
}
};
$('#cmd').click(function () {
var html=$("'#index_map").html();
console.log (html);
doc.fromHTML(html, 200, 200, {
'width': 500,
'elementHandlers': specialElementHandlers
});
doc.save('test.pdf');
});
});
And when I click on my button I've the message "doc.fromHTML is not a function"
Answer
Use:
doc.fromHTML($('#index_map').get(0), 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});
note the get: doc.fromHTML($('#index_map').get(0)
No comments:
Post a Comment