-2

I have researched this question on stackoverflow, but I'm confused by the answers. I've created an application in php that produces a report. I'd like for the report to be created as a pdf on a button push.

Using google chrome and firefox manually to 'file>print as pdf' renders the text of the report generated by my php script, but doesn't produce any of the colours.

Is there a relatively simple way to do this without apis, to take exactly what appears in the browser, and create a pdf of it? If there is, could somebody please tell me how?

Thank you.

bevc
  • 203
  • 3
  • 14
  • 1
    A quick Google search immediately found this: http://stackoverflow.com/questions/25046187/how-to-generate-a-pdf-from-html-web-page Though the question is essentially off-topic. If you're asking for a library, library recommendations are off-topic. If you're asking how to build a PDF without a library, that's *very* broad. – David Sep 14 '16 at 18:38

1 Answers1

0

If you have time to look at server side stuff, check out phantomjs, can generate a PDF from html in one line using the rasterize.js example:

e.g

phantomjs rasterize.js index.html index.pdf A4

I normally create the HTML using PHP and then use php to execute phantomjs with exec().

MikeyBeLike
  • 813
  • 1
  • 9
  • 15