Does there is any javascript code to convert generated google map into PDF using Javascript or any JS library?
Any help will be appreciated, and it will be more helpful if there is demo of such scenario.
Does there is any javascript code to convert generated google map into PDF using Javascript or any JS library?
Any help will be appreciated, and it will be more helpful if there is demo of such scenario.
If your okay with multiple libraries, you could try phantom.js to snapshot the html page then use node.js to convert to pdf.
I have a solution using 2 libraries: jspdf.min.js and html2canvas.js. add these to your index.html:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
function export_to_pdf() {
html2canvas(document.body, {
useCORS: true,
onrendered: function(canvas) {
var img =canvas.toDataURL("image/jpeg,1.0");
var pdf = new jsPDF();
pdf.addImage(img, 'JPEG', 15, 40, 180, 180);
pdf.save('a4.pdf')
}
});
}
explanation: