The PDFlib extension gives a UPR description error.
Applies to: Grid System
The UPR error occurs when you attempt to use a "non-native" font without a UPR description file.
PDFlib's "native" (built-in) fonts are:
Courier, Courier-Bold, Courier-Oblique, Courier-BoldOblique,
Helvetica, Helvetica-Bold, Helvetica-Oblique, Helvetica-BoldOblique,
Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic, Symbol, ZapfDingbats
Here's sample PHP code that shows how to generate a PDF using a "native" font (and therefore has no UPR description problems)
$pdf = pdf_new();
PDF_begin_page($pdf, 595, 842);
pdf_set_font($pdf, "Times-Roman", 30, "winansi");
# the font is spelled exactly as specified in the above list
pdf_set_value($pdf, "textrendering", 1);
pdf_show_xy($pdf, "A PDF document", 50, 750);
$data = pdf_get_buffer($pdf);
header("Content-disposition: inline; filename=test.pdf");
header("Content-length: ". strlen($data));
If you use "native" (built-in) fonts, as in the example above, you will never get a UPR error. Only when you try using a "non-native" font with no UPR description file will you get any UPR errors.
If you insist on using a "non-native" font, then you need a UPR description file to avoid getting UPR errors. You can download one from pdflib.com. A sample UPR file is in included in the distribution at that link.
To use a UPR file with your PDF generating PHP script, you put one of these inside the php script in order to tell the PDF functions where to find the UPR file:
(both of which say to find the file in the current directory -- you could put an absolute path instead). Either way, you must make sure that you actually put the UPR file in the place where you are telling the PHP script to find it.
If you get PDF errors about font metrics, try changing the font encoding from "winansi" to "host".
There is more information about using PDFlib with PHP at the PDFlib website here. Most of the information at that link concerns building and compiling. However, there is a link on that page to download a PDFlib 4.x (current pdflib version is 5.x but they do not offer a pre-compiled PHP shared object or free source for that version) shared object designed to work with PHP. If you download the PDFlib PHP extension from the pdflib.com website, instructions on how to install it in your account are in this other FAQ.
Be advised that the PDFlib extension for PHP obtained from the above link will print a DEMO watermark across all your pdf pages unless you buy a commercial license from PDFlib.
Remember, when using UPR files to make PDF documents that contain non-native fonts, that you will have to correctly set a path inside the UPR file (and precede that path with an extra / ). You you will also have to have all the appropriate .afm font files that you will need to obtain on your own.
There are some default .pfb files that come with RedHat in the following directories:
Because there are commercial licensing restrictions on PDFlib, it is up to you, the user of the software, to determine whether your use falls under the "free" part of their license, or whether you need to pay PDFlib a licensing fee for using their product when you download the latest PDFlib PHP extension from them at http://www.pdflib.com.
A less complicated approach to generating PDF documents with PHP scripts would be to use one of the PDF alternative PHP classes which are freely available and do not use the proprietary pdflib at all.
23536/0%Last update: 2010-09-27 15:24
Author: FAQ Admin
You can comment this FAQ
Comment of Anonymous:
Adobe.com had some afm and pfb files on its FTP site for a while, but I just checked and they are not there anymore.
I don't know where you can get a package containing them.
Added at: 2004-02-27 22:28
Comment of Anonymous:
U can find some afm-files here: http://cvs.easysw.com/cvsweb.cgi/htmldoc/fonts/
Added at: 2004-05-10 18:21