Search code examples
pdflib

PDFlib create_textflow --> Unknown option


when I want to create a textflow with the sign "<" in the text I got an error:

$text = 'my test < text<nextline>and a new line';

$tf = PDF_create_textflow($pdf, $text, "fontname=Helvetica encoding=winansi fontsize=11 escapesequence=true fillcolor=black");

PDF_fit_textflow($pdf, $tf, 160, 110, 550, 50, ' minfontsize=8 fitmethod=auto');

Fatal error: Uncaught exception 'PDFlibException' with message 'Unknown option 'text

some ideas?

I already test some escapes without success =(

pdflib full version


Solution

  • $text = 'my test < text<nextline>and a new line';
    

    the < is the starting character for an inline option. (as you do exactly in the next word with the option "nextline".)

    There are in general two strategies to solve this:

    • The most simple way, is to apply the < as a character reference &lt;. PDFlib will interpreter character references, when you set the option charref=true.
    • you can redefine the option list begin character with the option begoptlistcharto a character which is not used in your text.

    This is all described in detail within the PDFlib 9 Tutorial, chapter 9.2.3 "Inline Option Lists and Macros"

    I would recommend the first one.