I have a web form that users can fill out and that content fills up a PDF with FPDF and PHP. When a user enters a word with an apostrophe, a slash appears before it on the PDF.
Similarly, special characters like trademark symbols are encoded wrong.
The FPDF FAQs say to use:
$str = utf8_decode($str);
But I'm just not sure how to apply that to the whole PDF. I'm trying to think about it as if it was an HTML page but that isn't helping.
Any ideas?
none of above solutions worked for me, so I solved the problem like this:
Before trying the above lines, do the following:
Copy from c:/Windows/Fonts/Arial.ttf to the /tutorial folder of FPDF.
Edit the content of makefont.php
Execute makefont.php
Copy the following files to the /font folder of FPDF: arial.php arial.ttf arial.z
Finally, define the "font folder". Open fpdf.php (main library file) and add:
The PDF works for me with all special characters, I believe it was the problem in the Arial font itself, which FPDF originally uses. It should work with other fonts aswell, if they support your characters. Good luck!
Try this simple function:
utf8_encode($txt)
. It works for me.All of the above did not work for me, but I did get it to work.
I managed to do it "the barbarian way" by just translating every weird character to its url value. Then simply decode the url and voila!
And of course me calling the function
Giving output:
Días, Miércoles, Sábado,miércoles
None of above had solved my problem. I had solved it by the following way:
Hope you will be helpful.
Reference: Link
Below works for me (Using FPDF):
$content = urlencode($content);
$content = urldecode($pdf->em_jaz($content));
Figured this out by doing the following (pagesubtitle is the name of the text field in the form):
Then print it out:
This will remove any unwanted slashes following apostrophes, as well as use the 'iconv' function to print special characters such as ™