jsPDF add top margins on second page using addImage() method

Created on 27 Sep 2018  Â·  13Comments  Â·  Source: MrRio/jsPDF

All 13 comments

The image should not get clipped as seen above. Any help would be appreciated or even if one could suggest in the right direction it would be of great help. Thanks

Your code?

public captureScreen() {
var data = document.getElementById('content');
html2canvas(data).then(canvas => {
// Few necessary setting options

  const contentDataURL = canvas.toDataURL('image/png')  
  var imgWidth = 210; 
  var pageHeight = 295;  
  var imgHeight = canvas.height * imgWidth / canvas.width;
  var heightLeft = imgHeight;

  var doc = new jsPDF('p', 'mm');
  var position = 0;

  doc.addImage(contentDataURL, 'PNG', 0, position, imgWidth, imgHeight);

  heightLeft -= pageHeight;

  while (heightLeft >= 0) {
    position = heightLeft - imgHeight;
    doc.addPage();
    doc.addImage(contentDataURL, 'PNG', 0, position, imgWidth, imgHeight);
    heightLeft -= pageHeight;
  }
  doc.save( 'file.pdf');

});

}

The code above gives the image mentioned above. It has been difficult to get proper examples of addImage() method

Ok, and what is your problem? How should i look like?

Hello i have just solved the problem using your html2pdf repo. Thanks a lot for your support. However i could do that only using html2pdf....with jspdf i am still not sure but still if you have solved it using jspdf could you let me know what is the process??

Can you post your solution, help others out ? thnx

Im also facing the same issue. Can you please post the solution here?

I am interested in finding the solution to this as well.

Please use html2pdf as thats a better option

On Fri, 12 Jul 2019 at 21:21, Mirza Joldic notifications@github.com wrote:

I am interested in finding the solution to this as well.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/MrRio/jsPDF/issues/1970?email_source=notifications&email_token=AFZQK7OVBYVL4GC3FQD6NQDP7CSANA5CNFSM4FXTUF6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ2EUCI#issuecomment-510937609,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFZQK7KFJV2UPXA4XYKKQCLP7CSANANCNFSM4FXTUF6A
.

I am interested in finding the solution to this as well. It seems that we should prepare margin before html2canvas.

Has anyone found a solution?

Hello i have just solved the problem using your html2pdf repo. Thanks a lot for your support. However i could do that only using html2pdf....with jspdf i am still not sure but still if you have solved it using jspdf could you let me know what is the process??

HI , can you give the solution you applied to resolve this issue?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MaxCodeDE picture MaxCodeDE  Â·  4Comments

tarekis picture tarekis  Â·  4Comments

mellisa0109 picture mellisa0109  Â·  3Comments

MelanieCroce picture MelanieCroce  Â·  4Comments

sajesh1985 picture sajesh1985  Â·  5Comments