Question:How to convert html to PDF and show output result UTF-8.I use some library but it doesn't support UTF-8.Please tell me which libraries I can use and how to solve this problem. BMW, I need to run the conversion from PHP, is there any solution on VeryDOC?
Answer: According to your needs, maybe you can have a free trial of this software: VeryDOC Doc Converter COM, by which you can convert HTML to PDF from PHP code and output result UTF-8. When output UTF-8, there is no special parameters as it supports UTF-8 as default. UTF-8 (UCS Transformation Format—8-bit) is a variable-width encoding that can represent every character in the Unicode character set. It was designed for backward compatibility with ASCII and to avoid the complications of endianness and byte order marks in UTF-16 and UTF-32. So when you have UTF-8 requirement of output, this software can help you make that. Please check more related information of this software on its website, in the following part, let us check how to make it work.
Step 1. Free download Doc Converter COM
- This is COM version and there is DLL Library, or Command Line available, enabling developers to access the converter via any programming or scripting languages, such as Visual Basic, C/C++, Delphi, ASP, PHP, C#, .NET, etc.
- When downloading finishes, there will be a zip file. Please extract it to some folder then you can use it normally.
Step 2. Convert HTML to PDF using PHP
-
- When you use this software, first you need to install it. Download PDFcamp Printer Pro and unzip "doc2pdf_com_trial.zip" package to a folder, and run "install_as_exe.bat" file to install the DocConverter COM into your system, then you can run HTML2PDF.exe by script from MS Dos Windows.
- When you call the conversion from PHP code, please refer to the following code template:
Example 1
<?php
$url = "http://www.verypdf.com";
$path = "C:\\test.pdf";
$com = new COM("PdfOut.PdfCreator");
$com->html2PDF = $url;
$com->fileName = $path;
$com->Doc2PDFViaSocket();
?>
Example 2:
<?php
$PdfCreator =new COM("PdfOut.PdfCreator") or die("Cannot start PdfCreator");
$PdfCreator->Doc2PDFCommandLine(' "c:\input.doc" "c:\output.pdf" ');
$PdfCreator = null;
?>
Example 3:
<?php
$url = "http://www.verypdf.com";
$path = "C:\\test.pdf";
$com = new COM("PdfOut.PdfCreator");
$com->Doc2PDFCommandLine("\"$url\" \"$path\" \"paperType=0,PrintHTMLBackground=yes,overwrite=yes\"");
During the using, if you have more questions about it, please contact us as soon as possible.