SpartnerNL / Laravel-Excel

🚀 Supercharged Excel exports and imports in Laravel
https://laravel-excel.com
MIT License
12.29k stars 1.92k forks source link

[Bug]: Exported PDFs with custom unicode font has unreadable (square) characters #3884

Closed bkkrishna closed 1 year ago

bkkrishna commented 1 year ago

Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?

What version of Laravel Excel are you using?

3.1.30

What version of Laravel are you using?

9.19

What version of PHP are you using?

8.0.2

Describe your issue

Hi there! When exporting PDF files (using MPDF library) with custom unicode font (Noto Sans), Laravel Excel renders the characters as squares making them unreadable (like the image below).

Screenshot 2023-02-28 at 5 26 31 PM

What I'm actually trying to do is implement a custom unicode font that supports Devanagari in Laravel Excel exported PDFs.

To test for the file, I've created a blade template and created a PDF with just mPDF library and it gets the required result like this:

Screenshot 2023-02-28 at 5 23 22 PM

But when I try to export the same blade view with Laravel Excel, it gets the square characters like the first image shown. I've even tried to set the default font using the WithDefaultStyles concern as shown in the docs, like the image below but couldn't fix the issue:

Screenshot 2023-02-28 at 5 41 54 PM

Am I missing something here or Laravel Excel doesn't support any custom loaded unicode fonts? Would really help if someone could kindly enlighten me on this issue.

How can the issue be reproduced?

  1. Add this package to install mPDF driver and add Noto Sans as the default font of the driver (which is a Devanagari unicode font).
  2. Create a simple blade file with something like the following html table in Devanagari script. Export the PDF with just the mPDF driver using the above package, everything gets rendered as expected. Trying the same with Laravel Excel using the FromView concern (along with explicitly defining the font like the image code above) will return the unreadable square characters.

    What should be the expected behaviour?

    Exporting the PDF with just the standalone mPDF driver using the above package, everything gets rendered as expected. Trying the same with Laravel Excel using the FromView concern should generate the same pdf with the Devanagari unicode characters properly rendered. Maybe there's something missing with Laravel Excel & it's underlying unicode rendering process.

    patrickbrouwers commented 1 year ago

    PDF is handled by PHPSpreadsheet, there's nothing this package can do to improve that. Best to report over there instead.

    नाम स्त्री/पुरुष उमेर
    सुविधा मुस्ताङ्ग स्त्री ४१