A problem with writing pdf in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fxmzb123
Forum Newbie
Posts: 1
Joined: Tue Dec 28, 2004 6:39 am

A problem with writing pdf in PHP

Post by fxmzb123 »

Hello:
I encounter a problem:

Fatal error: PDFlib error: [1016] PDF_findfont: Couldn't open UPR file '/fonts/pdflib.upr' for reading (file not found) in c:\program files\apache group\apache\htdocs\tm\pdf.php on line 14

The souce code is as follow:

<?php
$pdf = pdf_new();
pdf_open_file($pdf,"test.pdf");
pdf_set_info($pdf,"Author","Uwe Steinmann");
pdf_set_info($pdf,"Title","Test for PHP wrapper of PDFlib 2.0");
pdf_set_info($pdf,"Creator","See Author");
pdf_set_info($pdf,"Subject","Testing");
pdf_begin_page($pdf,595,842);
pdf_add_outline($pdf,"Page 1");

// problem is here
pdf_set_parameter($pdf, "resourcefile", "/fonts/pdflib.upr");

$font = pdf_findfont($pdf,"Arial","host",1);
pdf_setfont($pdf,$font,10);
pdf_set_value($pdf,"textrendering",1);
pdf_show_xy($pdf,"Times Roman outlined", 50,750);
pdf_moveto($pdf,50,740);
pdf_lineto($pdf,330,740);
pdf_stroke($pdf);
pdf_close($pdf);
pdf_delete($pdf);
?>

I have already put "pdflib.upr" in the folder "fonts" on my "htdocs" folder. But the PHP keep telling me it can't find "pdflib.upr". What should i DO? Thanks!
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Maybe it requires an absolute path? Try:

Code: Select all

pdf_set_parameter($pdf, 'resourcefile', $_SERVER['DOCUMENT_ROOT'].'/fonts/pdflib.upr');
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Post Reply