How show jsPDF data on image - javascript

I am exporting some charts created in d3 to PDF. I am using jsPDF lib to achieve this. For instance I created a pdf as follows-
var pdf=new jsPDF('p','mm',[200,300]);
pdf.addImage(...);
pdf.addImage(...);
pdf.rect(...);
...
Now I want to display this pdf in an image element on html page.
Is there any way to do this? May be if I can get data from this pdf,Something like-
pdf.getData();

You have to use third party library to render pdf in javascript. For example
https://mozilla.github.io/pdf.js/

Related

Export current rendered view/template as a PDF with Nativescript-VueJS

Using NativeScript + VueJS, I'm trying to find a way to take a dynamic template that's rendered based on props and route data, and tap a button to save the "view" as a PDF to the filesystem.
I found this tutorial here which gives me a start: https://medium.com/#kumarandena/pdf-generation-in-nativescript-using-javascript-libraries-864ecf4e9a3a
This generates a Base64 which you then copy to clipboard and open in a browser. In iOS for example if I choose to save the page as a file it's just unknown.pdf. So my goal is to reference an html element, like a div, and save all the contents exactly as they appear into a folder of my choice in the native file system.
There's little to find on this so wondering if someone has accomplished this.
I use domtoimage to convert any dom element to an image, and it works well. Then you can probably insert that image to a pdf using jsPDF or pdfMake.
I see in the pdfMake playground that you can insert an image with a dataurl format.

How to convert current xhtml page with javascript charts to pdf

I have a web application with some pages where there are some texts, and some charts generated with javascript library. I want to show a "Download as pdf" link on each page, which will export the current page in pdf version.
Is there any way to do this.?
http://www.cloudformatter.com/CSS2Pdf has 12 different chart/map javascript libraries in the demos panel showing the pure SVG to PDF as vector information along with text, tables.
http://phantomjs.org/
Just run from command line
phantomjs rasterize.js 'http://en.wikipedia.org/w/index.php?title=Jakarta&printable=yes' jakarta.pdf
You can export image, then insert it into pdf file using itext or another library.
I think the below link help you:
http://www.highcharts.com/component/content/article/2-articles/news/56-improved-image-export-with-phantomjs

ng-grid to PDF using jsPDF or other library?

Hi I have an AngularJS ng-grid.
I am trying to find a way to use jsPDF to render it as a PDF. I have successfully managed to render PDFs of simple text and complicated SVGs via their URI...however when I try to create an image from the ng-grid the image fails, and when I try to use the jsPDF plugin for fromHtml it takes away all the CSS even though I explicitly add it back in.
Any suggestions?
Here are some related posts but they are not angularJS specific:
Export HTML table to pdf using jspdf
Export HTML table to pdf using jspdf
I tried doing the exact same thing as the second post and I get all of my data in a long list since angularJS doesn't uses standard tr and tds to make tables...it just a lot of divs with CSS.
jsPDF worked well after I made my own version of ng-grid-pdf-export.js to use POINTS rather than MM in the calls for the definition of table info. Otherwise, the row spacing was much too large!

Using Javascript with MPDF

I want to use the charts created in charts.js with MPDF but it doesn't seem to be recognising the Javascript elements, do you know if there is anything additional you need to add.
If MPDF cannot render Javascript do you know any other HTML to PDF converter in PHP that will work?
Better make charts in PHP using https://phpchart.com/. if you want to show it in a pdf. javascript looks and style does not work in PDF anyway.

Generate pdf from HTML and SVG

I have some SVG element in my HTML page with some HTML controls. I want to export all in a pdf. The export need to be "correct", I can't, for example, create a picture and create a pdf from it. And the html text need to keep this format, it have to stay selectionnable.
I saw jspdf but it seems hard with SVGs.
So, have you got an idea to do this?
Just for information I work with Phonegap / Angular js on mobile platforms.

Categories