Discusses how to generate images of text with HTML content in PHP

Source: Internet
Author: User
Discusses how to create a picture of text with HTML content in PHP
Like what:

Text message


Line break


Such a piece of HTML code, how to keep his format, create a picture

Share to: more


------Solution--------------------
Possible off-the-shelf approach:
1. Using Java html2image
2. Use TCPDF to generate PDF and then ...
3, the use of PHP screenshot function Imagegrabscreen, Imagegrabwindow
------Solution--------------------
I add a
Https://zh.wikipedia.org/wiki/Webkit
Https://en.wikipedia.org/wiki/Webkit
------Solution--------------------
Example
Define (' Dompdf_pdf_backend ', ' GD ');
Require_once ("dompdf_config.inc.php");

$html =<<< HTML


Text message


Line break

HTML;

$dompdf = new Dompdf ();
$dompdf->load_html ($html);
$dompdf->render ();
$dompdf->stream (");

------Solution--------------------
Dompdf's Download Address
Http://code.google.com/p/dompdf/downloads/list
------Solution--------------------
Different versions of Dompdf will have different performance (I'm dompdf.php,v 1.24 2009-04-29)
It uses DOMDocument to parse HTML
Print_r ($dompdf->_xml);
You can see that parsing is ok
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.