jspdf的方法addHTML()和fromHTML()有什么区别?

What are the differences between jspdf's methods addHTML() and fromHTML()?

jspdf的方法addHTML()fromHTML()有什么区别? Documentation 只有第一个的信息。

This issue on GitHub 没有提到两者之间的具体区别,但确实说它们是具有相似目标的独立插件。

From the issue:

Existing jsPDF plugins

Hi, I've been working on a new html2pdf package that uses html2canvas + jsPDF to convert HTML content to PDF. I know there are already three existing jsPDF plugins for HTML: addHTML, fromHTML, and html2pdf (same name). I don't want to step on any toes - from what I can tell:

  • fromHTML is the oldest plugin and renders the HTML directly to PDF (which is great), but its support for complex HTML/CSS is lacking.
  • addHTML is newer (but now deprecated) and uses html2canvas/rasterizeHTML to create a canvas, then puts the image onto the PDF page. Current state is described at #944.
  • html2pdf: I haven't found much info (apart from the demo), but it looks like it renders directly to PDF like fromHTML, which again is great but runs the risk of poor HTML/CSS support.