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.

Surfingkeys extension causes black blocks when generating pdf files with jsPDf .html() method

See original GitHub issue

When this extension is installed alongside https://npmjs.com/package/pdfjs, and the jsPDF doc.html(...) method is used to generate a PDF from html content, the pdf output has black blocks in the content:

image

import { jsPDF } from "jspdf"; // for generating pdf from html

(window as any).btnclick = () => {
  const doc = new jsPDF("p", "pt", "a4", true);
  const html = `Hello <b>There!</b> everyone2!`;
  doc.html(html, {
    margin: 20,
    callback: (doc) => {
      doc.save("hello.pdf");
    }
  });
};

I have a repro here: https://codesandbox.io/s/surfingkeys-breaks-jspdf-dzkhfd?file=/index.html

Through some painful troubleshooting I’ve narrowed this down to having the SurfingKeys extension installed and enabled. I’ve tried this in a fresh chrome profile.

Somehow I think this extension is adding some css to the html and body elements on the page.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
brookhongcommented, Mar 6, 2022

Thanks @b0o for looking into this, I have committed a fix for this, which basically inserts the hints host element on demand rather than initially. @wildhart please verify whether it works for your case.

1reaction
wildhartcommented, Mar 6, 2022

Yes @brookhong , this fixes the problem when generating PDFs on my site, thank you for your clever solution!

Read more comments on GitHub >

github_iconTop Results From Across the Web

jsPDF downloading blank pdf - Stack Overflow
I'm using jsPDF to generate a pdf ...
Read more >
Generating PDFs from Web Pages on the Fly with jsPDF
Massimo Cassandro demonstrates how to make use of jsPDF, a JavaScript library for generating PDF documents from web pages.
Read more >
jsPDF in Web Portal - Perficient Blogs
jsPDF is an open-source library for generating PDF documents using JavaScript. It provides multiple options to generate PDF files, ...
Read more >
Welcome to Everything.js | Everything.js
Welcome to Everything.js. A curated list of awesome JavaScript frameworks, libraries and software. freeCodeCamp/freeCodeCamp - The https://www.
Read more >
Creating PDF documents with jsPDF - Tizen Developers
close() method. Now there is only one missing element. How to get the PDF file data? var getExampleOutput = ...
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