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.

Doc: simple example about how to generate PDF from HTML with SVG content

See original GitHub issue

I’ve searched in many past issues, and I have seen an unmerged pull request in this direction, but currently no easy-to-test example.

Could we provide a simple example showing how fromHTML() works when there is some SVG content?

Here is a beginning:

https://jsfiddle.net/6op5ofah/

What should I add to make it work? A jspdf.plugin.svg.js file? Another version of jspdf? Another syntax?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:7

github_iconTop GitHub Comments

1reaction
Uzlopakcommented, Sep 6, 2018

We are closing this issue, because we will not support any longer fromHTML and addHTML.

Explaination: We are working on a new html2pdf plugin, which will be based on html2canvas and our context2d plugin. This should lead to more reliable results for your projects. And it will give us the time to focus on the core functionality of pdf-generation because we will not use our energy for writing/supporting/extending 2 html plugins. If you still want to use addHTML or fromHTML you can still use jsPDF 1.4.1.

Best Regards

0reactions
Amthieucommented, Jun 2, 2017

@josephernest I have not found a good solution either. Every solution I tried involves converting the SVG to PNG which is bad for my needs since I want the image to stay vectorial. Right now I am only able to achieve that by calling window.print()

Here is the simple SVG I have tried working with :

<svg width="200" height="200">
    <g>
        <circle cx="100" cy="100" r="15"></circle>
    </g>
</svg>
Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Convert HTML To PDF With CSS And SVG(Chart ...
Step 1 - Create a HTML page · Step 2 - Copy all CDN links into your HTML page · Step 3 -...
Read more >
How to design runtime generated PDF via HTML
In this article, we will learn to design the runtime generated pdf file via HTML. This task can be achieved in 3 ways:....
Read more >
Convert HTML to PDF using JavaScript - CodexWorld
In this tutorial, we will show you how to generate PDF document and convert HTML to PDF using JavaScript and jsPDF library.
Read more >
How to create a PDF document with the following HTML string ...
I am trying to convert an HTML String into a PDF document. But only the text part is being printed into the PDF...
Read more >
Generating PDF from HTML in React Demo: Exporting Invoices
In this blog post, we'll build a sample invoice in our React app using HTML and CSS, then generate a PDF file based...
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