0

I have straange problem with jsPDF, when i test on local pc, i generate PDF good, but when i upload online and try to generate, it looks like slipped, like in the picture

Here is the link to sample image

i have tried just create PDF from HTML, but lots of problems, then i decided to create image from html, then add it to jsPDF page, its 2 page ID card, then generate PDF, it works ok on local, and it work ok sometime online, but most of time it is not working, like in the picture.

var qrcode = new QRCode("qrBox", { text: "https://sis.paragonisc.edu.kh/verify?code="+studentId, width: 180, height: 180, colorDark : "#000000", colorLight : "#ffffff", correctLevel : QRCode.CorrectLevel.H });
            var settings = { output: 'css', bgColor: '#FFFFFF', color: '#000000', barWidth: 5, barHeight: 100, moduleSize: 10, addQuietZone: true, showHRI: false, };
            $("#barCodeBox").barcode(studentId, 'code39', settings);
            var pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: [759, 1200] });
            var imgData = ""; var imgData2 = "";

            html2canvas($("#printPage"), {
                  onrendered: function(canvas) {
                      imgData = canvas.toDataURL('image/jpeg');
                      pdf.addImage(imgData, 'JPG', 0, 0, 759, 1200);
                      $('#printPage').hide();
                      $('#printPage2').show();
                      pdf.addPage();
                      html2canvas($("#printPage2"), {
                            onrendered: function(canvas) {
                                imgData2 = canvas.toDataURL('image/jpeg');
                                pdf.addImage(imgData2, 'JPG', 0, 0, 759, 1200);
                                pdf.save(arr[1]+'-'+arr[0]+'-'+studentId+'.pdf');
                                $('#qrBox').empty();
                                $('#loading').hide();
                            }
                        });
                  }
              });
maxileft
  • 225
  • 4
  • 15
  • when you say it's sometimes working, do you mean, the card is wide enough to fill the space or is it centered and it's width does not change? – Patrik Alexits Jan 17 '19 at 03:10
  • sometimes work: card full with the frame, no blank spaces on left , top or bottom, but most of the time it slips to right and bottom. – maxileft Jan 17 '19 at 06:41

0 Answers0