PHP dompdf Use

Source: Internet
Author: User
New version Dompdf installation
Version is 6 beta


Dompdf Download:
Https://github.com/dompdf/dompdf


Php-font-lib Download:
Https://github.com/PhenX/php-font-lib


1. The new dompdf appears to have no php-font-lib by default and is then placed in the Dompdf\lib\php-font-lib directory after downloading.




2. Check/install new fonts, Chinese fonts recommended to use Google's Droidsansfallback, only more than 3MB.
(1) Modify the dompdf_config.inc.php configuration file before installing the font
def ("Dompdf_admin_username", "yourname");
def ("Dompdf_admin_password", "YourPassword");
User name, which is required when installing fonts.


(2) Check if the dompdf_config.inc.php contains php-font-lib path configuration, make sure the system can find the font.php
Require_once (Dompdf_lib_dir. "/php-font-lib/src/fontlib/font.php");
Add to the configuration file.


(3) browser enters dompdf/www/fonts.php for font installation
Four fonts, normal, bold, italic, etc., installed each.

Include ' dompdf6/dompdf_config.inc.php ';


$html = <<


END;


$html = file_get_contents (' pdf.html ');
There are several ways to reference a template.


$html =
// ''.
// '

Put your HTML here, or generate it with your favourite '.
' Templating system.
A second look at the support Chinese no?

'.
// '';

$dompdf = new Dompdf ();
$dompdf->load_html (Utf8_decode ($html), ' UTF-8 ');
$dompdf->load_html ($html, ' UTF-8 ');
$dompdf->load_html ($html, ' GBK ');
$dompdf->render ();
$dompdf->stream ("sample.pdf");


If Chinese is not supported, add font definition to Chinese:
In the HTML template.



If there is no automatic line-wrapping in Chinese, use div to try. Support for table is not good.
  • Related Article

    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.