Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Magento 2.1.6 - Invoice PDF doesn't support Thai #9666

Closed
jsdupuis opened this issue May 17, 2017 · 15 comments

Comments

@jsdupuis
Copy link

commented May 17, 2017

Preconditions

  1. Magento CE 2.1.6

Steps to reproduce

  1. In the admin, go to Sales > Orders
  2. Select one 'completed' order and select the action 'Print Invoices' (any of the Print... actions actually)

Expected result

  1. Be able to read Thai names and Thai adresses in Thai alphabet

Actual result

  1. Thai letters are replaced by squares. Thai baht currency symbol is also unreadable.
    invoice2017-05-17_11-19-09.pdf
@1408sheva

This comment has been minimized.

Copy link
Contributor

commented Jun 26, 2017

Internal ticket MAGETWO-70209 was created;

@jsdupuis

This comment has been minimized.

Copy link
Author

commented Aug 20, 2017

Any suggestion for a temporary fix?

@natawut-ch

This comment has been minimized.

Copy link

commented Aug 24, 2017

@jsdupuis

Here is very dirty workaround / backup all file before doing these steps. ->

  1. Get Thai font and upload to /lib/web/fonts (Font-version must be table v3, since the library can't parse table v4 font.)
  2. Change font-location to uploaded fonts' location in /vendor/magento/module-sales/Model/Order/Pdf/AbstractPdf.php
   function _setFontRegular
   function _setFontBold
   function _setFontItalic

** you might need to adjust font size according to your font, finding "setFontSize"

  1. Modify $drawingString in same file :: /vendor/magento/module-sales/Model/Order/Pdf/AbstractPdf.php
        $drawingString = '"libiconv"' == ICONV_IMPL ? iconv(
            'UTF-8',
            'UTF-16BE//IGNORE',
            $string
        ) : @iconv(
            'UTF-8',
            'UTF-16BE',
            $string
        );

to

        $drawingString = mb_convert_encoding($string, "UTF-16BE", "UTF-8");

If you get the error about cannot convert MacRoman. then you might have to edit /vendor/magento/zendframework1/library/Zend/Pdf/FileParser.php and look for

function readStringMacRoman

replace

return iconv('MacRoman', $characterSet, $bytes);

with

return mb_convert_encoding($bytes, $characterSet, 'UTF-8');

PS. This is not appropriate way to deal with this issue. However LinLibertineFont contains no Thai-characters , and iconv lib can't properly convert MacRoman to UTF16BE (Used in thai font like TH Sarabun)

PS.2. This is very dirty fix. If your store is in EN/TH then it might work. But this might raise some errors if dealing with other char-encoding.

-------- BTW, Thai-font issue is in magento since 1.xx

@kp-drc

This comment has been minimized.

Copy link
Contributor

commented Sep 14, 2017

I am using Magento 2.1.7 and facing same character issue when printing invoice of arabic order. Any update for solution ?
screenshot from 2017-09-14 11 48 14

@magento-engcom-team

This comment has been minimized.

Copy link
Contributor

commented Oct 10, 2017

@jsdupuis, thank you for your report.
We've created internal ticket(s) MAGETWO-70209 to track progress on the issue.

@kp-drc

This comment has been minimized.

Copy link
Contributor

commented Oct 10, 2017

@magento-engcom-team Please check same for arabic too as I am facing same issue.

@magento-engcom-team

This comment has been minimized.

Copy link
Contributor

commented Apr 14, 2018

Hi @jsdupuis. Thank you for your report.
The issue has been fixed in #13016 by @rossmc in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.5 release.

@tmleeek

This comment has been minimized.

Copy link

commented Apr 17, 2018

great news , thanks every one

@magento-engcom-team

This comment has been minimized.

Copy link
Contributor

commented Apr 17, 2018

Hi @jsdupuis. Thank you for your report.
The issue has been fixed in #14711 by @rossmc in 2.1-develop branch
Related commit(s):

The fix will be available with the upcoming 2.1.15 release.

@magento-engcom-team

This comment has been minimized.

Copy link
Contributor

commented Apr 17, 2018

Hi @jsdupuis. Thank you for your report.
The issue has been fixed in #14710 by @rossmc in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

@o0mohammed0o

This comment has been minimized.

Copy link

commented Apr 23, 2018

@magento-engcom-team
Hello,
https://github.com/magento/magento2/commit/abd7be087cebeae8109f8d998d24361cedb2d554

this fix is not enough to fix the problem. the characters become supported but. still the letters are not connected together.

letters not connected

@o0mohammed0o

This comment has been minimized.

Copy link

commented Apr 23, 2018

After long investigation I found that zend pdf library doesn't support arabic language.
the solution for this is to use extension use another pdf library.
i found this extension uses another library and support arabic. you have to pay for it sorry didn't found free one. https://www.vnecoms.com/magento2-extensions/magento2-pdf-invoice-pro.html

@msliman

This comment has been minimized.

Copy link

commented May 30, 2018

@o0mohammed0o I have this error, did you suggest any solution except this one
https://www.vnecoms.com/magento2-extensions/magento2-pdf-invoice-pro.html

@ecombluesand

This comment has been minimized.

Copy link

commented Aug 13, 2018

i am getting same font issues in order invoice print out from admin panel.
from customer panel its working perfectly. if any solution please put it here.

@mohit724

This comment has been minimized.

Copy link

commented Feb 6, 2019

If anyone found solution for Arabic. Please let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.