Search code examples
phppdflib

How to use PDF_get_option() method to get font name?


function nvpdf_WrapString($my_pdf,$string,$width,$width_in_chars = "") {

    // known problem: can only be called after the pdf document has been
    // started, font size set, etc as it relies on the pdf being in the
    // page scope to use pdf_stringwidth (see PDFLib manual p.83).
    // returns an array: 1st level column
    //                   2nd level data string broken up into lines that fit the column
  $string = str_replace('\n', "\n", $string);
  $inlines = explode("\n",$string);
    $outlines = array();

    $font_size = PDF_get_option($my_pdf, "fontsize", "");
    $font_name = pdf_get_parameter($my_pdf, "fontname", 0);
    $font_id = PDF_load_font($my_pdf, $font_name, "host","");

I got a deprecation warning from php saying that I should use pdf_get_option() instead of pdf_get_parameter(). But how can I convert this pdf_get_parameter() to pdf_get_option()?

I need a method that will return me the font name of $mypdf.


Solution

  • Found the solve. pdf_get_option() wont give me the font name. All I have to do is use pdf_info_font() and then use pdf_get_string() to get the fontname.