jspdf

create PDF with Unicode using jsPDF

拜拜、爱过 提交于 2019-12-23 01:51:54
问题 I want save a PDF with Sinhala unicode. but when try to convent data gives me junk data something like this "ʶ±Ê°ÀoÒ". If I cannot do this in jsPDF suggest me a another way but I do not want to use a screenshot like html2canvas. let doc = new jsPDF('landscape'); doc.text(15, 30, 'ස්තුතියි'); doc.save("new.pdf"); 来源: https://stackoverflow.com/questions/55617814/create-pdf-with-unicode-using-jspdf

Html2Canvas image is getting cut

故事扮演 提交于 2019-12-22 23:12:34
问题 I use Html2Canvas and then jsPdf to export the image. This is the function: function exportPdf() { content = $("#print"); var useWidth = content.prop('scrollWidth'); var useHeight = content.prop('scrollHeight'); debugger; html2canvas((content), { width: useWidth, height: useHeight}).then(function (canvas) { debugger; var img = canvas.toDataURL("image/png"); var doc = new jsPDF({ unit:'px', format:'a4' }); debugger; doc.addImage(img, 'JPEG', 0, 0); doc.save('test.pdf'); }); } I think is taking

Html2Canvas image is getting cut

前提是你 提交于 2019-12-22 23:12:14
问题 I use Html2Canvas and then jsPdf to export the image. This is the function: function exportPdf() { content = $("#print"); var useWidth = content.prop('scrollWidth'); var useHeight = content.prop('scrollHeight'); debugger; html2canvas((content), { width: useWidth, height: useHeight}).then(function (canvas) { debugger; var img = canvas.toDataURL("image/png"); var doc = new jsPDF({ unit:'px', format:'a4' }); debugger; doc.addImage(img, 'JPEG', 0, 0); doc.save('test.pdf'); }); } I think is taking

Does external css get applied to the pdfs generated by jsPDF

左心房为你撑大大i 提交于 2019-12-22 18:15:03
问题 I have started making some demos using jspdf. I have a html file and my css is in external file. I have written the below code to generate my pdf $('#pdfButton').on('click', function(){ var pdf = new jsPDF('p','in','letter') , source = $('#main')[0] , specialElementHandlers = { '#bypassme': function(element, renderer){ return true } } pdf.fromHTML( source // HTML string or DOM elem ref. , 0.5 // x coord , 0.5 // y coord , { 'width':700 // max width of content on PDF , 'elementHandlers':

image in generated pdf corrupts pdf sent to server

拟墨画扇 提交于 2019-12-22 10:48:31
问题 I'm creating a PDF document in a web app with jsPDF, sending that document to Perl, and having Perl email it, and it works fine. However, when I add an image to the PDF document, it no longer works, as the Adobe Reader says the file is corrupt. The app is huge, so here is a stub with similar pertinent code that acts in the same way: html: <!DOCTYPE html> <html> <head> <script src="https://<myserver>/js/jquery.js"></script> <script src="https://<myserver>/js/jspdf.js"></script> <script src=

How to display a javascript File object in Chrome's PDF viewer with its name?

夙愿已清 提交于 2019-12-22 04:11:42
问题 I've got a PDF file in the form of a Blob object (generated with jsPDF), that I want to display in an <iframe> element. I can do that easily this way: iframe.src = URL.createObjectURL( blob ) The PDF is rendered correctly but I get an esoteric string in place of its name (see image below of Chrome's PDF viewer). So I tried to convert the Blob to a File object in order to give it a human-readable name. var file = new File( [blob], 'a_name.pdf', { type: 'application/pdf' } ) iframe.src = URL

How to display a javascript File object in Chrome's PDF viewer with its name?

房东的猫 提交于 2019-12-22 04:11:06
问题 I've got a PDF file in the form of a Blob object (generated with jsPDF), that I want to display in an <iframe> element. I can do that easily this way: iframe.src = URL.createObjectURL( blob ) The PDF is rendered correctly but I get an esoteric string in place of its name (see image below of Chrome's PDF viewer). So I tried to convert the Blob to a File object in order to give it a human-readable name. var file = new File( [blob], 'a_name.pdf', { type: 'application/pdf' } ) iframe.src = URL

Create PDF with Table using Javascript

六眼飞鱼酱① 提交于 2019-12-22 00:23:04
问题 I'm currently creating a phonegap app that lets you input Data and then creates a PDF with that data. The Input is done, but I can't find anything to make a PDF with Javascript. So far I only found jsPDF, but that doesn't support tables. The App must work offline. Does someone have an Idea? 回答1: Bytescout PDF Generator SDK for Javascript might come in handy: http://bytescout.com/products/developer/pdfgeneratorsdkjs/index.html Ensure that browser inconsistencies for your targeted devices are

How to converted SVG Files into PDF in JSPDF using javascript

╄→гoц情女王★ 提交于 2019-12-21 17:31:30
问题 I struggled to converted SVG Files into PDF using JSPDF. Here i Worked in following code. var doc = new jsPDF(); var test = $.get('amChart.svg', function(svgText){ // console.log(svgText); var svgAsText = new XMLSerializer().serializeToString(svgText.documentElement); console.log(svgAsText); doc.addSVG(svgAsText, 20, 20, doc.internal.pageSize.width - 20*2) //console.log(doc); // Save the PDF doc.output('datauri'); }); I get this script from this SO Answer.Its results only blank PDF .When i

Adding Footer to pdf using jsPDF

偶尔善良 提交于 2019-12-21 12:11:22
问题 I am generating pdf from jsPDF api , I want to add footer to each page with page number . How to achieve this . It is having option of adding footer from fromHTML plugin , but I am writing without HTML. var doc = new jsPDF("portrait","px","a4"); 回答1: You have to implement it yourself. You can do something like this: var doc = new jsPDF(); doc.page=1; // use this as a counter. function footer(){ doc.text(150,285, 'page ' + doc.page); //print number bottom right doc.page ++; }; // and call