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 bug

See original GitHub issue

I am using jsPDF module in angular 7 for rendering my page to a new pdf file. Here is some code snippets you can check.

@ViewChild('pdf') pdf: ElementRef;

var doc = new jsPDF('p', 'pt', 'a4');
const pdfTable = this.pdf.nativeElement;
doc.html(pdfTable, {
  callback: function(doc) {
  doc.save('tableToPdf.pdf');
 }
});

and here is the div element i was trying to render for testing.

<div class = "pdf" id="pdf" #pdf>
  <label>test</label><br>
  <label>test</label><br>
  <label>test</label><br>
  <label>test</label><br>
  <label>test</label><br>
  <label>test</label><br>
  <label>test</label><br>
  <label>test</label><br>
</div>

the problem is that when the div content is over one page, pdf shows a strange margin on the top of the first page. I have attached a screenshot for some insights. screenshot

For some reasons, I must use html function and i can’t use other functions such as addHTML() or fromHTML().

Why do i have this strange margin? Is there any solution to avoid this issue?

Please help me if you have some solutions. Thanks in advance.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
HackbrettXXXcommented, Jul 17, 2020

We are currently working on making the html function work again - stay tuned. Meanwhile you can try using html2canvas 1.0.0-rc1 instead of rc5.

1reaction
shortdarkcommented, Jul 3, 2020

If it’s any help, I had more success with getting HTML into a PDF with html2pdf (which uses jsPDF) than I did by putting it straight into jsPDF.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jquery html() bug? - javascript - Stack Overflow
Jquery html() bug? ... In IE8, how come when I press the "press" button, the h2 with black background turns to white background...
Read more >
Bugs and Errors :: Eloquent JavaScript
The process of finding mistakes—bugs—in programs is called debugging. ... function canYouSpotTheProblem() { "use strict"; for (counter = 0; counter < 10; ...
Read more >
What went wrong? Troubleshooting JavaScript - MDN Web Docs
In this case, the code was not run and the error was not thrown until the checkGuess() function was run by line 86....
Read more >
html helper function bug · Issue #126 · rstudio/gt · GitHub
html helper function recycles input value tab_1 <- exibble ... @olegursu What you have is pretty close but you actually need the text_transform()...
Read more >
6559 (.html() function returns inconsistent results) – jQuery
#6559 closed bug (worksforme) .html() function returns inconsistent results ... The html contents of the div element were returned. b is invalid markup....
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