shamuntoha Posted October 5, 2008 Share Posted October 5, 2008 I have this script, and php.ini, but i cant create pdf test yet, getting Fetal error. i am using NuSphere PHPed. Any suggestion? <?php // create handle for new PDF document $pdf = PDF_new(); // open a file pdf_open_file($pdf, "philosophy.pdf"); // start a new page (A4) pdf_begin_page($pdf, 595, 842); // get and use a font object $arial = pdf_findfont($pdf, "Arial", "host", 1); pdf_setfont($pdf, $arial, 10); // print text pdf_show_xy($pdf, "There are more things in heaven and earth, Horatio,",50, 750); pdf_show_xy($pdf, "than are dreamt of in your philosophy", 50,730); // end page pdf_end_page($pdf); // close and save file pdf_close($pdf); ?> php.ini : ;extension=php_bz2.dll ;extension=php_curl.dll ;extension=php_dba.dll ;extension=php_dbase.dll ;extension=php_exif.dll ;extension=php_fdf.dll ;extension=php_gd2.dll ;extension=php_gettext.dll ;extension=php_gmp.dll ;extension=php_ifx.dll ;extension=php_imap.dll ;extension=php_interbase.dll ;extension=php_ldap.dll ;extension=php_mbstring.dll ;extension=php_mcrypt.dll ;extension=php_mhash.dll ;extension=php_mime_magic.dll ;extension=php_ming.dll ;extension=php_msql.dll ;extension=php_mssql.dll extension=php_mysql.dll ;extension=php_mysqli.dll ;extension=php_oci8.dll ;extension=php_openssl.dll extension=php_pdo.dll ;extension=php_pdo_firebird.dll ;extension=php_pdo_mssql.dll extension=php_pdo_mysql.dll ;extension=php_pdo_oci.dll ;extension=php_pdo_oci8.dll ;extension=php_pdo_odbc.dll extension=php_pdo_pgsql.dll extension=php_pdo_sqlite.dll extension=php_pgsql.dll ;extension=php_pspell.dll ;extension=php_shmop.dll ;extension=php_snmp.dll ;extension=php_soap.dll ;extension=php_sockets.dll extension=php_sqlite.dll ;extension=php_sybase_ct.dll ;extension=php_tidy.dll ;extension=php_xmlrpc.dll ;extension=php_xsl.dll ;extension=php_zip.dll Quote Link to comment Share on other sites More sharing options...
DarkWater Posted October 5, 2008 Share Posted October 5, 2008 What error are you getting? P.S: It's fatal, not "fetal". Fetal is referring to unborn babies. Quote Link to comment Share on other sites More sharing options...
shamuntoha Posted October 5, 2008 Author Share Posted October 5, 2008 #recompile code Fatal error: Fatal error: Uncaught exception 'PDFlibException' with message 'Metrics data for font 'Arial' not found' in D:\noname1.php:11 Stack trace: #0 D:\noname1.php(11): pdf_findfont(Resource id #1, 'Arial', 'host', 1) #1 {main} thrown in D:\noname1.php on line 11 #First was a php_pdf.dll file missing, i download it. - http://pecl4win.php.net/ext.php/php_pdf.dll #phpinfo() showing: PHP Version 5.2.6 PDF Support enabled PDFlib GmbH Version 5.0.3 PECL Version 2.1.4 Revision $Revision: 1.155 $ Quote Link to comment Share on other sites More sharing options...
DarkWater Posted October 5, 2008 Share Posted October 5, 2008 It can't find the Arial font. Quote Link to comment Share on other sites More sharing options...
budimir Posted October 5, 2008 Share Posted October 5, 2008 Try some other fonts ... Quote Link to comment Share on other sites More sharing options...
shamuntoha Posted October 5, 2008 Author Share Posted October 5, 2008 Changed the fonts to same error. Fatal error: Uncaught exception 'PDFlibException' with message 'Metrics data for font 'Verdana' not found' in D:\noname1.php:9 Stack trace: #0 D:\noname1.php(9): pdf_findfont(Resource id #1, 'Verdana', 'host', 1) #1 {main} thrown in D:\noname1.php on line 9 Quote Link to comment Share on other sites More sharing options...
budimir Posted October 5, 2008 Share Posted October 5, 2008 PDF_setfont() was deprecated since PDFlib version 5 http://uk3.php.net/manual/en/function.pdf-findfont.php Check it out. That's you're problem! Quote Link to comment Share on other sites More sharing options...
shamuntoha Posted October 5, 2008 Author Share Posted October 5, 2008 Thanks working, i just manualy fix the path of font directory. And php parameters from code. <?php /* * This is an example of my first PDF test * Worked by NuSphere PHPed * Manualy downloaded library from * http://pecl4win.php.net/ext.php/php_pdf.dll */ /* * Stage - 1 * Resource create for PDF library */ $pdf = PDF_new(); /* * Stage - 2 * Save where? Path to create the file. */ pdf_open_file($pdf, "c:\heloworld.pdf"); /* * Stage - 3 * Page diemention (A4) */ pdf_begin_page($pdf, 595, 842); /* * Stage - 4 * path of your TTF font directory * can also use pdf_load_font(); * http://uk3.php.net/manual/en/function.pdf-findfont.php */ $fontdir = "C:\WINDOWS\Fonts"; pdf_set_parameter($pdf, "FontOutline", "arialMyName=$fontdir\arial.ttf"); $arial = PDF_findfont($pdf,"arialMyName","host",0 ); /* * Stage - 5 * Set font size and font name */ pdf_setfont($pdf, $arial, 10); /* * Stage - 6 * print text */ pdf_show_xy($pdf, "Hellow World? ",50, 750); pdf_show_xy($pdf, "Test 1, 2, 3, 4 working. ", 50,730); /* * Stage - 7 * end page */ pdf_end_page($pdf); /* * Stage - 8 * close and save file */ pdf_close($pdf); ?> Output as pdf: ################################### # # Hellow World? # Test 1, 2, 3, 4 working. # ################################### Quote Link to comment Share on other sites More sharing options...
budimir Posted October 5, 2008 Share Posted October 5, 2008 Great!!! Hit "Topic Solved" Quote Link to comment Share on other sites More sharing options...
shamuntoha Posted October 5, 2008 Author Share Posted October 5, 2008 How we do that? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.