/php-html-to-pdf

PHP HTML-to-PDF Converter with UTF-8 Support (Chinese, Japanese, European, etc.)

Primary LanguagePHPBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

PHP HTML-to-PDF Converter with UTF-8 Support

(supports Chinese, Japanese, European, etc.)

This project provides a simple, easy-to-use HTML-to-PDF converter in PHP, with full, out-of-the-box support for UTF-8 and non-Latin-based languages.

Demos

Dependencies

PHP HTML-to-PDF Converter makes use of :

  • tFPDF (based on FPDF 1.7)
  • FPDF ("Free PDF")
  • DejaVu Language Pack
  • ZCOOL_QingKe_HuangYou Chinese Language Pack
  • rounded-mgenplus-20140828 Japanese Language Pack

Sample Use

English Example

	require('../php-html-to-pdf/php-html-to-pdf.php');
	
	$pdf_object = new HTMLtoPDF([
		'Author'=>'HoldOffHunger',
		'Title'=>'Privacy Policy',
	]);
		
	$pdf_object->WriteHTML([
		'html'=>'<h1>I can say hello in English!</h2><p>Hello!</p>',
		'language'=>'en',
	]);

	$pdf_object->Output('file.pdf', "F", TRUE);

Japanese Example

	require('../php-html-to-pdf/php-html-to-pdf.php');
	
	$pdf_object = new HTMLtoPDF([
		'Author'=>'HoldOffHunger',
		'Title'=>'Privacy Policy',
	]);
		
	$pdf_object->WriteHTML([
		'html'=>'<h1>I can say hello in 日本人!</h2><p>こんにちは!</p>',
		'language'=>'ja',
	]);

	$pdf_object->Output('file.pdf', "F", TRUE);

Chinese Example

	require('../php-html-to-pdf/php-html-to-pdf.php');
	
	$pdf_object = new HTMLtoPDF([
		'Author'=>'HoldOffHunger',
		'Title'=>'Privacy Policy',
	]);
		
	$pdf_object->WriteHTML([
		'html'=>'<h1>I can say hello in 汉语!</h2><p>你好!</p>',
		'language'=>'zh',
	]);

	$pdf_object->Output('file.pdf', "F", TRUE);