Chinaunix

标题: php使用PDF出现这样的错误是什么原因啊 [打印本页]

作者: bowenpro    时间: 2011-03-31 15:29
标题: php使用PDF出现这样的错误是什么原因啊
Fatal error: Uncaught exception 'PDFlibException' with message 'Metrics data for font 'Arial' not found' in D:\wamp\www\forextjs\test.php:7 Stack trace: #0 D:\wamp\www\forextjs\test.php(7): pdf_findfont(Resource id #2, 'Arial', 'host', 1) #1 {main} thrown



下面是源程序
  1. <?php
  2. phpinfo();
  3. $pdf   =   PDF_new();
  4. PDF_open_file($pdf,   "LineExam.pdf ");
  5. PDF_begin_page($pdf,   595,   842);
  6. //设定Arial字体
  7. $arial   =   PDF_findfont($pdf,   "Arial",   "host",   1);
  8. PDF_setfont($pdf,   $arial,   12);

  9. //   设定直线的颜色
  10. PDF_setcolor($pdf,   "stroke ",   "rgb ",   0,   0,   0);

  11. //画出直线
  12. PDF_moveto($pdf,   20,   780);
  13. PDF_lineto($pdf,   575,   780);
  14. PDF_stroke($pdf);

  15. //   在页面底部画出另外一条直线
  16. PDF_moveto($pdf,   20,50);
  17. PDF_lineto($pdf,   575,   50);
  18. PDF_stroke($pdf);

  19. //   输出一些文字
  20. PDF_show_xy($pdf,   "Meng 's   Corporation ",   200,   35);
  21. //结束PDF内容的绘制和制作
  22. PDF_end_page($pdf);
  23. //关闭PDF文档
  24. PDF_close($pdf);
  25. ?>
复制代码

作者: ws00377531    时间: 2011-03-31 16:11
字体找不到
作者: bowenpro    时间: 2011-03-31 16:31
回复 2# ws00377531


    这是在windows下的,字体不是默认在windows/font下吗
作者: ws00377531    时间: 2011-03-31 17:17
回复 3# bowenpro


    Search for a font and prepare it for later use with PDF_setfont().
作者: bowenpro    时间: 2011-04-01 10:11
这个不好用,找到好用的了,FPDF,确实不错




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2