John Davidson

php - Wkhtml to export pdf with utf-8 tamil language

0 comments
Message:


In command prompt direct command execution at windows command tamil language is exporting successfully


wkhtmltopdf.exe --encoding UTF-8 http://localhost/pdfexport/phpwkhtmltopdf-master/page.html file/test.pdf


But executing same command via PHP exec($cmd) tamil strings is not exporting.



My Answer:
To export a PDF with UTF-8 Tamil language using wkhtmltopdf in PHP, you can try the following code:

php

$html = file_get_contents('http://localhost/pdfexport/phpwkhtmltopdf-master/page.html');
file_put_contents('file/page.html', $html);

$cmd = 'wkhtmltopdf.exe --encoding UTF-8 file/page.html file/test.pdf';
exec($cmd);

?>


Make sure to replace 'wkhtmltopdf.exe' with the correct path to the wkhtmltopdf executable on your system. Also, ensure that the 'file' directory has the necessary write permissions for the PDF file to be created.

By saving the HTML content to a file before executing the command, you can ensure that the Tamil strings are properly encoded and exported in the PDF file.

Rate this post

3 of 5 based on 7580 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us