How to convert HTML page into PDF in PHP? - php

I have generated an E-bill using html, css, bootstrap and php. Is there any way I can get it directly into PDF format (easily downloadable format)?
What all I could find was creating pdf using the code(FPDF etc). But that's not what I want. I already have the e-slip structure ready.
Thanks

Related

How to generate an image from mathML (or latex) code using php

I'm developing a small web application (using Apache-MySQL-PHP) that can display text and then transform it in PDF (the text is stored in a database as HTML code).
The problem is that the text I want to display and convert into PDF contains formulas...
The text displays correctly in web pages: I'm using MathJax that displays the formulas inside the math tag (currently in MathML code, but I can easily go for the LaTeX code) in the text.
Now I've to find a way to generate a PDF from the HTML-text that contains formulas...any clue?
Currently, I'm trying to convert HTML-text to PDF using FPDF and TCPDF (php classes) but they don't support the math tag (I didn't find one that does it... for free).
So, I'm trying to find a way to transform dynamically the formula in the math tag into an image (that I will save temporarily in the web server) and create the PDF using the formulas as images. In principle it should work, but at the moment I'm looking for a tool to convert the formula’s code to image and save it to the web server. Anyone know how to do that?
Thanks in advance!

PHP generate HTML convert to JPG then to PDF

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.

Exporting flash content to PDF?

I am using fpdf.php to export the PDF document from PHP. I'm still facing the problem that I couldn't export flash content in to the PDF
What do you mean by flash content? You should separate data generating code from data displaying code, so you can write two components for displaying data: one for flash and one for pdf.
If you mean to take a .swf file and convert it into a PDF then you will need to find a different solution since the fpdpf.php library, since it doesn't support converting .swf files into PDFs.

Create PDF pages in PHP

Which is the best PHP-PDF library that can be used to create PDF files with more than 100 pages?
I am creating an application where there is need of creating PDF reports of account for an entire financial year, which library should is use?
See here:
Converting HTML to PDF using PHP?
Which one is the best PDF-API for PHP?
HTML to PDF vs. Programmatically creating PDF via PHP
Converting HTML to PDF (not PDF to HTML) using PHP
Specifically: https://stackoverflow.com/search?q=php%20pdf
Use tcpdf library. It might be best for you.

PHP to PDF - Use text from XML document to create PDF?

I have some xml files that contain text, which are displayed on my website. I want to extract the text from these xml files and convert them to a pdf document that users can download.
how can I can extract this text from the xml documents? (libraries etc?)
how can I use this text to create a pdf document?
I am working in a PHP environment, however if this is not the suitable language, I could change.
There are many ways to parse an XML file, and many ways to output a PDF file.
I suggest you start with the XML functions within PHP http://php.net/manual/en/book.xml.php
There are also various classes to write PDF files, try googleing for them.

Categories