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.

fromHTML is not a function when I use jsPDF in vue

See original GitHub issue
<script>
import { jsPDF } from 'jspdf'
...
export default { 
    methods: {
          getPdf() {
               const printDoc = new jsPDF('p', 'in', 'letter')
               console.log('printDoc', printDoc)
               // There is no method fromHTML in what is printed,so when I use printDoc
               // the console reports error: fromHTML is not a function
          },
    },
}
</script>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

45reactions
HackbrettXXXcommented, Feb 22, 2021

@kamildudek6 simple to explain: In jsPDF@1.5.3 there were 4 different functions to convert HTML to PDF (fromHTML, addHTML, html2pdf, and html). Each had its own API and feature set. It was quite confusing for developers to decide which function to use. Since html had the most complete feature set and the most promising technological approach, it was chosen as the single HTML function for 2.0.0. The others were already marked as deprecated in 1.5.x. Between 1.5.3 and 2.0.0 developers had almost two years to port their code to html. Since a new major release with other breaking changes was already planned, it was only logical to remove all the old deprecated functions.

Another big point is maintenance and support. This project is currently maintained by a single person (me), and it is just not feasible to maintain 4 different variants of HTML functions, all with their own bugs and missing features. I hardly have the time maintain one of them properly. Please keep in mind this is an open source project, which everyone can use for free.

And, lastly, if you really want to use one of the old HTML functions, no one keeps you from installing 1.5.3 again or even forking the project and merge the old function with the 2.x code.

Also, please refrain from phrases like “junior dev move” if you don’t know the details behind design decisions. That’s not very kind and, IMHO, GitHub is not the right place for that. IMO, conversations on GitHub should remain purely technical and not emotional.

26reactions
HackbrettXXXcommented, Nov 4, 2020

The fromHTML function was replaced by html in 2.0.0. Unfortunately, the typings currently still contain the fromHTML method but a fix is under way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

fromHTML is not a function when I use jsPDF in vue #2992
The fromHTML function was replaced by html in 2.0.0. Unfortunately, the typings currently still contain the fromHTML method but a fix is under ......
Read more >
doc.fromHTML is not a function jsPDF - Stack Overflow
I uploaded to jsFiddle and works... but when I try it in my browser doesnt works and I get the error doc. fromHTML...
Read more >
Creating a PDF using jspdf.fromHTML : r/vuejs - Reddit
fromHTML. So i was working on a personal project and was trying to use jsPDF to create a pdf file using HTML. What...
Read more >
jsPDF from html - CodePen
Insecure Resource. The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https....
Read more >
doc.fromHTML is not a function Code Example
The fromHTML function was replaced by html in 2.0.0. Unfortunately, the typings currently still contain the fromHTML method but a fix is und....
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