question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

html() function always starts on first page

See original GitHub issue

Hello. Does jsPDF.html method can draw <table> in pdf? And how can i with html() draw in not first page of pdf?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

4reactions
glebov21commented, Jul 29, 2021

Hi, any update regarding this issue? I’ve been facing the same issue… Trying to add some html content after a table in the first few pages… But the html content always starts from the first page on top of the table contents.

While issue not fixed, i use offset by y coord:

doc.html(mdDiv,
    { 
    callback: function (doc) {doc.save(); },
    y: ((pageNum-1) * pageHeight) + offsetY,
    });
1reaction
HackbrettXXXcommented, Jul 13, 2021

Ah, you’re right. There seems to be a bug in jsPDF. The context2d.autoPaging property is set to true (which is probably good for most use cases): https://github.com/MrRio/jsPDF/blob/cef97fb34eda41a8704c9f3983e680919a328ce4/src/modules/html.js#L451-L454

However, the autoPaging mechanism doesn’t respect the starting page. See e.g. here:

https://github.com/MrRio/jsPDF/blob/cef97fb34eda41a8704c9f3983e680919a328ce4/src/modules/context2d.js#L1675-L1681

A workaround would be to first call html with only one page and the afterwards add another page with insertPage before the first page.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to run a function when the page is loaded? - Stack Overflow
Place your JavaScript functions or or library calls inside the "Start()" method below, so they are triggered as soon as the script says...
Read more >
first - CSS: Cascading Style Sheets - MDN Web Docs
The :first CSS pseudo-class, used with the @page at-rule, represents the first page of a printed document. (See :first-child for general ...
Read more >
WebD2: Common HTML Tags - University of Washington
Every web page must start with a DOCTYPE declaration. It has to be the very first item on the very first line of...
Read more >
HTML Block and Inline Elements - W3Schools
A block-level element always starts on a new line, and the browsers automatically add some space (a margin) before and after the element....
Read more >
page-break - Properties - CSS-Tricks
The page-break-inside property adds a page-break inside the element to which it is applied. Syntax. page-break-after : auto | always | avoid | ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found