jsPDF multi page PDF with HTML renderer

前端 未结 11 1659
感情败类
感情败类 2020-11-27 13:54

I am using jsPDF in my site to generate PDFs. But now I have multiple DIVs to print in a single PDF. which may take 2 to 3 pages.

For example:



        
11条回答
  •  [愿得一人]
    2020-11-27 14:29

    I have the same working issue. Searching in MrRio github I found this: https://github.com/MrRio/jsPDF/issues/101

    Basically, you have to check the actual page size always before adding new content

    doc = new jsPdf();
    ...
    pageHeight= doc.internal.pageSize.height;
    
    // Before adding new content
    y = 500 // Height position of new content
    if (y >= pageHeight)
    {
      doc.addPage();
      y = 0 // Restart height position
    }
    doc.text(x, y, "value");
    

提交回复
热议问题