Surfingkeys extension causes black blocks when generating pdf files with jsPDf .html() method
See original GitHub issueWhen 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:
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:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Yes @brookhong , this fixes the problem when generating PDFs on my site, thank you for your clever solution!