Special Characters in FPDF with PHP

2019-01-17 10:31发布

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?

8条回答
Summer. ? 凉城
2楼-- · 2019-01-17 11:32

Sounds like you have magic_quotes enabled. See the link to disable magic_quotes.

查看更多
做自己的国王
3楼-- · 2019-01-17 11:35

This class is a modified version of FPDF that adds UTF-8 support. Moreover, it embeds only the necessary parts of the fonts that are used in the document, making the file size much smaller than if the whole fonts were embedded. These features were originally developed for the mPDF project.

http://fpdf.org/en/script/script92.php

查看更多
登录 后发表回答