doujianwan7570 2010-08-18 16:00
浏览 137
已采纳

FPDF中的特殊字符与PHP

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?

  • 写回答

7条回答 默认 最新

  • duanmei1850 2010-08-25 18:54
    关注

    Figured this out by doing the following (pagesubtitle is the name of the text field in the form):

    $reportSubtitle = stripslashes($_POST['pagesubtitle']);
    $reportSubtitle = iconv('UTF-8', 'windows-1252', $reportSubtitle);
    

    Then print it out:

    $pdf->Write (6, $reportSubtitle);
    

    This will remove any unwanted slashes following apostrophes, as well as use the 'iconv' function to print special characters such as ™

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(6条)

报告相同问题?

悬赏问题

  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失