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!
Related
I want to export my html page into excell sheet which contains some svg charts and html tables. I searched a lot and couldn't find any solution in javascript. I could find a php solution in this. Only thing i found is a node module(here) which i think cannot be used in a web page js file.
Finally got a solution for inserting image into excel in Excelbuilder.js.
We can insert image by specifying cell or offset positions using this plugin. It works.
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/
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.
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.
I am generating a graph and html table with graph related info in a collapsible div.
Now the problem is I need to add the div content to my PDF export and not just the Graph, I see that there is a chart.exportDivElements but I could not find a related sample on how to use it.
Anybody has an idea about this? or an alternate to export highchart and a specific div to PDF via javascript?
I implemented the export server and saved the svg file (did away with the convert to jpg/png code as was not needed) to the server and used tcpdf to generate PDF with svg and required content, it was a bit hard to understand how to export server worked by got my head around and worked very well.
You can't. The export server exports the chart SVG, not any arbitrary html content of the page. A possible solution is to the alter the export server and introduce an extra POST parameter 'customHtml'. In the phantomJS script you have to detect if the parameter is set and write the tablecontent to the page before it is rendered.