KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Note: Convert to PDF with 4D v12 and PHP
PRODUCT: 4D | VERSION: 12.1 | PLATFORM: Mac & Win
Published On: March 3, 2011

Generating PDF documents is a common task within 4D databases. Differences in Mac OS and Windows OS have made it difficult to develop a standard for generating PDFs on both operating systems. Thanks to the addition of PHP within 4D v12, it is now possible to generate PDF documents on both Mac OS and Windows OS, using the exact same method, resulting in the exact same PDF. On top of this, it is possible to programmatically control all aspects of the PDF generation. This Tech Note describes how this is possible and goes into a number of examples.

Download Complete Tech Note and Example: Tech Note Document and Demo Database

Commented by Jesse Pina on March 16, 2012 at 3:57 PM
Special characters (accentuated) could not be correctly displayed in the generated PDF file. It is the case in the list form for "Frédérique" for example.

The solution is to use the utf8_decode PHP function in the PHP code to be executed by PHP Execute.

In the demo database, in the project method "fPDF_Cell", line 36,
replace
$result_t:=$result_t ",'" $text_t "'"
by
$result_t:=$result_t ",utf8_decode('" $text_t "')"
and run again the demo.Now you should have correct accented characters in the list form PDF.