mercredi 17 octobre 2018

laravel-snappy (wkhtmltopdf) title utf-8 encoding

I have a snappy generated base64 SVG embedded to my page in an <object> tag dynamically with React. My problem is that the title option of wkhtmltopdf doesn't respect UTF-8 characters. And the title shown in Chrome's PDF plugin skips the UTF-8 characters (not even shows wrong characters). My php code is:

  // This generates a string like: '<svg>...</svg>'
  $svgString = getSvgStringFromSvgFile(session('svgFile'));

  $output = $snappy->getOutputFromHtml($svgString, [
    'encoding' => 'utf-8',
    'title' => session('svgTitle')
  ]);
  $output = base64_encode($output);

  return response()->json($output);

Then I dynamically embed this into my page in React:

        <object data={'data:application/pdf;base64,' + pdfData} type="application/pdf">
          Your browser doesn't support pdf embedding.
        </object>

How can I solve this? Thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire