This question already has answers here:
Convert HTML to Image in PHP without shell
(5 answers)
Closed 6 years ago.
Is there a php script that allow to convert a html code to a png image.
The problem with GD library is that only convert text to image( and not html code )
There is no pure PHP solution to this.
Basically you've got two options:
Client-side rendering
Use something like html2canvas to render your image using javascript in the browser.
Server-side rendering
Use a library like wkhtmltopdf which can be invoked by PHP to generate the image.
Another server-side solution would be using Phantom.js which can also run javascript before capturing the screen.
Related
This question already has answers here:
How Can I add HTML And CSS Into PDF [closed]
(30 answers)
Closed 5 years ago.
How could i generate a pdf file using url without using any api ?
Or if any free api provider then please tell me.
I have a file www.highstore.in/myticket.php
In this file php & MySQL is used to get data now i want to convert this data as it is in PDF format.
this is not an API, but you can use a FPDF OPEN SOURCE library, it's too easy to use. you can see some examples here :
FPDF LIBRARY
You can use one of free libraries to generate pdf files
https://ourcodeworld.com/articles/read/226/top-5-best-open-source-pdf-generation-libraries-for-php
If you want to return generated pdf as a result of execution of a PHP script you should change header content-type into
header("Content-type:application/pdf");
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Convert HTML + CSS to PDF with PHP?
How to convert current html rendered in browser
to an image or pdf (so later on i can convert it to image),
using javascript (canvas or anything) or php?
what are the alternative solution?
For PDF conversion, it will help you.
dompdf: HTML to PDF Converter
If you want to generate PDF of HTML+CSS through PHP then There is TCPDF for generating PDF from HTML + CSS.
TCPDF is a PHP class for generating PDF documents without requiring
external extensions. TCPDF Supports UTF-8, Unicode, RTL languages,
XHTML, Javascript, digital signatures, barcodes and much more.
For creating pdf im using FPDF - php library, if you have an option do it with it...
[For converting html to PDF in client side you can use printElement
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Website screenshots using PHP
Can someone tell me how to take a thumbnail off of a web page using php or js without any 'API' support? Otherwise convert HTML to PS and PS to jpeg is also possible.
Thank you.
Try Phantom JS. It can be used to render HTML from the commandline, using various output formats. Creating a thumbnail can be done by setting the zoom factor.
WKHtmlToImage is able to render a webpage using webkit engine. You will have to launch an executable on server-side though.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Convert HTML + CSS to PDF with PHP?
What's the fastest, cleanest and best way to export from PHP a webpage (given URL) into PDF?
Hard. You wont be able to convert HTML to PDF just like that without any manipulation. One shot may be using mPDF, but that probabliy won't satisfy your needs, since it has limited HTML functionality.
The other way would be making a screenshot of a webpage and including it in PDF document, but you'll need specialized software, or at least libray. Read further on that topic.
You can go for TCPDF.
dompdf is an HTML to PDF converter. At its heart, dompdf is (mostly) CSS 2.1 compliant HTML layout and rendering engine written in PHP domPdf
This question already has answers here:
Closed 11 years ago.
Possible Duplicates:
Convert URL to screenshot (script).
PHP: How to capture browser window screen with php?
I have a URL and I want to convert that webpage screenshot to an image. Please let me know if we can do this using php or some other tools that can be used with PHP/Linux.
This isn't the best solution, but you could convert the HTML page to a PDF, then use imagemagick to convert the pdf to a jpeg using this command exec("convert sample.pdf sample.jpeg"). To convert HTML to pdf, see this question.
Convert HTML + CSS to PDF with PHP?
The shutter screenshot tool is able to do that.
It's in the menu: File -> New -> Web
Can be used with Linux and PHP on the same system. See the manpage for commandline options to be invoked from PHP.