Generate accents and ç for PDF with PDFlib + PHP

2

I made the following code to pass a sequence and generate my lines in pdf with PDFlib:

função text_block ( $ p , $ text , $ xcrd , $ ycrd ) 
{ 
    $ FONT_SIZE = 24 ;   // tamanho da fonte, usada para linhas de espaço no eixo y 
    $ tmplines = explode ( "\ n" , $ text ); 
    for ( $ j = 0 ; $ j < contagem ( $ tmplines ); $ j ++) { 
      $ tmptxt = explode ( " " , $tmplines [ $j ]); 
      $str = "" ; 
      for ( $i = 0 ; $i < count ( $tmptxt ); $i ++){ 
      if ( $str == "" ) 
        $str = sprintf ( "%s" , $tmptxt [ $i ]); 
      else 
        $str = sprintf ( "%s %s" , $str , $tmptxt [ $i ]); 
      if (( strlen ( $str )* $font_size + strlen ( $tmptxt [ $i + 1 ])* $font_size )  >  1512 ){ 
        $p -> fit_textline ( $str , $xcrd , $ycrd , "" ); 
        $str = "" ; 
        $ycrd -= $font_size ; 
      } 
    } 
      $p -> fit_textline ( $str , $xcrd , $ycrd , "" ); 
      $ycrd -= $font_size ; 
  } 
    return $ycrd ; 
}

Because when I pass something like "ç" or "is" to PDF it appears strange characters "is".

How do I fix this?

UPDATE

I tried to do this but it did not work, it neither generated my pdf nor returned to my page.

$font = $p->load_font("Helvetica-Bold", "unicode", "");
$font_size=24.0;  //font size, used to space lines on y axis
$p->setfont($font, $font_size);
...
$p->fit_textline($str,$xcrd,$ycrd,"utf8");

UPDATE2

If I try to set my pdf to utf8 the code ends up locking, but it does not return an error, it just keeps forever processing.

$p = new PDFlib();
$p->set_option("stringformat=utf8");
    
asked by anonymous 22.03.2016 / 20:38

0 answers