I am making a tool that needs to generate a PDF report with charts and tables from data that was imported via excel upload.
I would like use HTML5 charts. We are currently using PHP.
I am looking for a a real browser (or something that behaves like a browser) in order to have those html5 charts rendered properly. The new html5 charts rely on javascript, so it's not just a matter of rendering html into pdf, but also executing javascript to generate the charts on the fly.
Any suggestions?
Thanks
ZingChart exports to PDF from canvas, SVG, and VML.
I'm on the team, so if you have any questions about implementation or other features, just reach out!
You might be able to convert the HTML to a CANVAS image (http://html2canvas.hertzen.com/), and then save via jsPDF (https://github.com/MrRio/jsPDF)
What have you tried?
Related
Is it possible to Print the highchart as a PDF using DOMPDF or any other PHP Html pdf generators?
Version 2 of Highcharts includes PDF generation. The Highcharts client side will export an SVG string, and there will be server modules based on Batik that do the conversion to PDF. You can try it out at Link.
This component will only convert the chart itself. If you want to convert the whole webpage or parts of it, check out the server library with the name of wkhtmltopdf (read WebKit HTML to PDF). It converts the charts too.
Take a look at their latest announcement about generating images on the server.
Once you save the images, you can add them to a pdf using libraries such as tcpdf
Please familiarise yourself with the included exporing module and parameters which can be used http://api.highcharts.com/highcharts#exporting
I have two basic bar charts and I am currently using XML/SWF Charts which is great but the problem I have is I need to be able to send these graphs via email to the user. As well as display them on the site.
I know sending Flash is a bad idea, I would love to find a way to convert my current graphs to an image, but am pretty certain there is no quick fix without building a work around myself.
Therefore what are the best open source or closed solutions for this problem.
I need to be able to display two graphs dynamically and then email them to users.
Any advice is appreciated.
You may want to check out the "Google Image Chart Api" (not to be confused with the Google Chart API).
http://code.google.com/apis/chart/image/
It allows you to generate numerious different types of charts just from the URL.
For example:
https://chart.googleapis.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World
That URL could also be put into an HTML e-mail.
Alternatively, looking at this stackoverflow quesiton FLASH save frame, to image (tiff, bmp, jpg, gif, png)
If you can modify the flash movie. It appears that you can save frames in AS3 via BitmapData. So you may be able to send the data back to the server for processing (emailing). But I can't vouch for this as I haven't tried it.
jqPlot seems pretty good. Piwik uses it. http://www.jqplot.com/
I would recommend using gRaphael. It is a javascript library for rendering graphs using svg(or vml for IE8 and below). I've personally use it and it is quite good.
This probably won't work for you since you're not running .net, but for anyone else who's looking for resources for generating charts there's the MS Chart controls.
I want to create PDF reports containing some pie/bar charts. I have to create them with my PHP web app and cannot use commandline tools. For the frontend I use flot. However, I don't know how to get these charts in a PDF, because my project is constrained to PHP.
How do I generate images from my charts to render a PDF?
Update: The solution has to be open source since my project will be open source, too.
Best,
Stefan
Of course you won't be able to use a javascript charting solution to generate graphics to be used directly in a PDF. What you could do however, is use a PHP charting solution to create the graphs. Provided you have GD support built-in (it usually is) you could use pChart or libChart to create GIF/PNG charts you can embed within your PDF.
And for PDF generation I would personally recommend using TCPDF.
Can you use PDFLib ?
http://php.net/manual/en/ref.pdf.php
http://www.pdflib.com/pdflib-cookbook/graphics/fill-pattern/
I'm developing an app where the user adds items to a list. That list is stored in an array and passed to PHP with JSON.
The objective is to then create a PDF with all the values extracted from the user. The PDF is quite complicated. It includes images depending on what the user selects and the text varies depending on the images and the input data.
The first idea was to generate the pdf in php with one of those pdf libraries, but that's going to be a real hassle.
Then I thought of creating an html & css (much easier) and the convert it to PDF. But since the html & css are quite complex I don't think those pdf converters will work with this.
Then I thought I could convert the html to jpg and then to pdf.
It'll be much simpler if I could just use html but the output needs to be pdf.
What do you suggest?
Here's a post that discusses creating PDF files with PHP and the PDFLib extension.
Generate PDFs with PHP it's on sitepoint.
Or if you want to go from HTML to the PDF it looks like TCPDF might work.
You can try using FPDF
Then I thought of creating an html & css (much easier) and the convert it to PDF. But since the html & css are quite complex I don't think those pdf converters will work with this.
wkhtmltopdf to the rescue! If you are on a VPS or dedicated machine, it's probably the best (open source) HTML-to-PDF engine out there. It leverages Webkit, the rendering engine used by Google Chrome and Apple Safari, amongst others.
Otherwise, your only other options are going to involve drawing every aspect of the PDF or image yourself, "by hand" in your code.
HI. I wanted to know if we could create pie and bar charts based on info from the database on a php website. I want to grab some information from the database and show it as an image so better analysis. Is there anyway to do this?
Also, If i am using fpdf to generate pdfs from php and mysql, can i also design pie charts in that pdf and show it as an image in that?
You could use the Google Chart API
I'd recommend using tcpdf instead of fpdf. fpdf was pretty good, but is no longer actively developed. tcpdf is.
http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf
As for the graphs there are many libraries displaying image graphs like http://jpgraph.net/
or client side JS libraries that will create flash graphs like ExtJS
JpGraph is a pure php library for generating graphs which outputs an image. I'm not familiar with fpdf but if it can embed images then this solution should work out.
http://jpgraph.net/
I'm using ChartDirector (not free) and FPDF to do this (today as a matter of fact).
ChartDirector can write the chart to a file, which I stick in /tmp. Then I import the file into the PDF file. Then I delete the file from the disk. Then I do it twenty more times with different data.
I'm sure any chart library that can write to disk will work. With FPDF, you can set the size of the image you import. So here's a trick: create the chart image twice as large as you need it and tell FPDF to place it at the size you want. This way, you'll get an image in the PDF file at around 144 dpi (assuming your library exports at 72dpi for the screen). You'll have a PDF that doesn't look as pixelated when zoomed in, and it will print better.
Check out this article on A List Apart for a method using the Raphael javascript graphics library. It demonstrates how to take a generic HTML table and replace it with a cross-browser, dynamic, scalable pie chart. The same could probably be done for a bar chart.
The advantage of this method is semantically correct markup - useful for users without JavaScript, as well as bots and screen readers.