2 ms·
Thanks, that made my day. I'll see about doing that for A/Bingo if I can get it to work without majorly changing the API... What sort of charts are you using?
by patio11 16y ago
Thanks, that made my day. I'll see about doing that for A/Bingo if I can get it to work without majorly changing the API...
What sort of charts are you using? (Not the name of the Javascript, I mean, bar charts, pie charts, etc?) If you're using anything that can be done with the Google Chart API, then doing PDFs is fairly easy: you grab the GIFs from Google, convert them into PNG or whatever, insert them into your PDF template, and you are pretty much done.
I unfortunatley am not at liberty to just give you the code to do this, but if you are comfortable with Ruby, this is only a few hundred lines in Prawn (think single-page reports of middling complexity, with data access included). I don't work professionally with PHP and am unaware of good ways to do PDF generation in it.
P.S. If you want to fake it, render the report as HTML using webkit2png, then use ImageMagick or GraphicsMagick to turn the PNG into a PDF. It won't be editable but, hey, who cares. :)
- paraschopra 16y agoThanks! The issue is not PDF generation per se. The only bottleneck is the charts, they are rendered on CANVAS element directly. The charts are mainly sparklines and line chart. Replacing them will be a non-trivial task. Your suggestion of converting HTML -> PDF is a great one but then again the rendered HTML will require static charts (as GIF or JPG). I will probably go down this route: Screenshot of Report -> Image -> PDF. Inefficient, yes. Heavy file, yes. But it will work :)