Using Javascript with MPDF - javascript

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.

Related

convert html page to pdf from jquery plugin

i have designed a page in html. i need to find a way to save the html body section as pdf. can some one suggest me a jquery plugin where i can get this work done?
am using C# as my back end coding.

How show jsPDF data on image

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/

create dynamic image with php

I need to create image chart dynamically as shown bellow,
First I tried with php ImageCreate but it is hard to manage the space with that.
Then I tried the html5 canvas and that is also having a same issue. What I need to know is whether there is an easy way to do html to image conversion. Then I can manage the space easy with other styles.
Thanks in advance.
With wkhtmltoimage you can convert HTML to an images. You would need a VPS to run it on though. You can then create the HTML and call wkhtml2image via PHP to convert the given HTML to an image.
I am creating dynamic image with php with `GDLibrary. Here is the script of creating dynamic image.

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!

How to generate a PDF out of a rendered HTML element?

Is there a way to generate a PDF file in JavaScript out of a given rendered and styled element of a webpage and its content? Is there already a library for this?
I've never put it to use, but could https://github.com/thebluber/htmlToPdf be what you're looking for?
There is a library called jsPDF. It provides basic functionality to create PDF documents. It even comes with a plugin to add elements from basic HTML.

Categories