简体   繁体   中英

PDFLib (PHP) - Characters not Displaying

We use PDFlib (not sure exact version, should be recent) and I'm trying to have a Barcode appear using BCW Code 128 3 (Not A, B or C, but standard) using the same formula we have in an old Crystal Reports 8.0 formula (which DOES display correctly) which starts with Character #205 and ends in Character #206.

The problem is that the Barcode is not appearing at all, BUT ALSO the string is not displayed when I set to another another Textflow field just using the default font, so it is probably some Escaping issue or something like that. I've experimented changing the "escapesequence" and "charref" values to no avail.

The Barcode WILL display (now that it's set to Unicode) for standard characters like "111111111", but the moment a character like chr(205) displays, it displays nothing.

Any ideas?

Thanks!

$p = new PDFlib();

$p->set_option("errorpolicy=return");
$p->set_option("stringformat=utf8");

$p->begin_document("", "");
$doc = $p->open_pdi_document("/usr/local/PDFlib/templates/CertifiedMail.pdf", "");
$page = $p->open_pdi_page($doc, 1, "");

if ($page == 0) throw new Exception("Error: " . $p->get_errmsg());

$p->begin_page_ext(0, 0, "width=letter.width height=letter.height");

$p->fit_pdi_page($page, 0, 0, "");

$sText = chr(205).chr(103).chr(122).chr(232).chr(38).chr(96).chr(42).chr(232).chr(108).chr(115).chr(76).chr(206);

$p->fill_textblock($page, "sReturnAddress", $sText,  "encoding winansi");
$p->fill_textblock($page, "uniBarcode", $sText,  "encoding unicode");

$p->close_pdi_page($page);

$p->end_page_ext("");

$p->end_document("");

$buf = $p->get_buffer();
$len = strlen($buf);

header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=font_resource.pdf");
print $buf;

We use PDFlib (not sure exact version, should be recent)

You can simply determine this, by checking your phpinfo() output.

I would suggest to embed the font, which is always recommended for custom fonts, like a Barcode font. (Otherwise the font must be installed on the system where you view the PDF). Use the option "embedding" in your case in the fill_textblock() option list. Otherwise in the load_font() option list.

Potential additional problem, when your code is a symbol font, you have to load the font with the encoding " builtin ". And then you have to address the glyphs by there code points, not via a Unicode String. Please see PDFlib 9 Tutorial, chapter 5.4.2 "Selecting an Encoding for symbolic Fonts" and 5.4.3 "Example: Selecting a Glyph from the Wingdings Symbol Font" for further background information.

And I'm sure, for further detailed help, the guys from PDFlib will give you a proper help. Then you can also share your resources etc. http://www.pdflib.com/licensing-support/opening-a-support-case/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM