Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Print/ PDF invoice with japanese customers doesn’t display !! 
 
Loic_LC
Sr. Member
 
Avatar
Total Posts:  194
Joined:  2007-12-19
Paris, France
 

Anyone has noticed ?
When I create an invoice with a japanese adresse, it shows only XXXXXXX
Any one has a fix ?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
thegwin
Jr. Member
 
Total Posts:  11
Joined:  2009-05-02
Japan
 

I installed Admin Order Printing Extension http://www.magentocommerce.com/extension/reviews/module/1054/p/3/
on Magento ver. 1.3.1.1 and got the same error as yourself when creating a PDF with Japanese characters.

Am looking into this and if I find a solution, will be sure to share it here. Likewise I hope.

NOTE: If on installing this extension you get a 404 page upon attempting to print, Go System > Configuration > Admin > Security and set Add Secret Key to URLs to NO

 
Magento Community Magento Community
Magento Community
Magento Community
 
thegwin
Jr. Member
 
Total Posts:  11
Joined:  2009-05-02
Japan
 

Have solved this!
*****************************************************************************************************
HOW TO PRINT MAGENTO INVOICE PDFs in JAPANESE (and other non-english alphabets)
*****************************************************************************************************
Basically, the reason for the MOJIBAKE (XXXXXX...japanese characters not displaying properly) is due to the fact that the magento script is setup by default to use LinLibertineFont (at least this is true for version 1.3.1.1 which I am running). When I changed this to point to a Japanese font, the invoice printed in Japanese OK!

There are two files to update:

FILE 1
Copy /app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php to /app/code/local/Mage/Sales/Model/Order/Pdf/Abstract.php (You’ll need to create the folder structure in the local directory. This is just so you are not editing a core file that would just be written over during your next upgrade)

Around line #537 (run a search for Zend_Pdf_Font)

Change

$font Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/LinLibertineFont/LinLibertineC_Re-2.8.0.ttf');

to

//$font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/LinLibertineFont/LinLibertineC_Re-2.8.0.ttf');
$font Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/JpFont/msasahi.ttf');

i.e. comment out one line and add in the new one.

You’ll need to do this a total of 3 times in this file. Just run a search in the file for the text Zend_Pdf_Font.

NOTE: There are 3 options as the script can point to 3 different fonts, for regular, italic and bold text. For simplicities sake, I am pointing all 3 to the same font file.

FILE 2
Copy /app/code/core/Mage/Sales/Model/Order/Pdf/Items/Abstract.php to /app/code/local/Mage/Sales/Model/Order/Pdf/Items/Abstract.php

Run a search for Zend_Pdf_Font and comment out and replace lines as above.

Now the script is pointing to the new Japanese font so we need to upload this.
Create a new file in /lib/ called JpFont and upload the font msasahi.ttf so it should reside in /lib/JpFont/msasahi.ttf

Obviously you can use ANY font you like. This is just one Japanese font which you can download in a zip file from here: http://senduit.com/92ac53

THAT’S IT!

I presume this will work for other international languages by just replacing msasahi.ttf with your own country font and updating the files accordingly.

Once you’ve updated the font, you’ll probably want to start customising the look, for example increasing font size etc.
Here’s a good resource: http://framework.zend.com/manual/en/zend.pdf.html

Hopes this helps someone out!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Loic_LC
Sr. Member
 
Avatar
Total Posts:  194
Joined:  2007-12-19
Paris, France
 

Thank you so much for posting this.
I’ve followed your very well detailed steps, but I get an error :

Noticeiconv() [function.iconv]Wrong charsetconversion from `MacRoman' to `UTF-16BE' is not allowed  in /home/admin/petiteparis/shop/lib/Zend/Pdf/FileParser.php on line 449
Trace:
#0 [internal function]: mageCoreErrorHandler(8, '
iconv() [readStringMacRoman(47'UTF-16BE')
#3 /home/admin/petiteparis/shop/lib/Zend/Pdf/FileParser/Font/OpenType.php(356): Zend_Pdf_FileParser_Font->readStringMacRoman(47)
#4 /home/admin/petiteparis/shop/lib/Zend/Pdf/FileParser/Font/OpenType.php(119): Zend_Pdf_FileParser_Font_OpenType->_parseNameTable()
#5 /home/admin/petiteparis/shop/lib/Zend/Pdf/FileParser/Font/OpenType/TrueType.php(80): Zend_Pdf_FileParser_Font_OpenType->parse()
#6 /home/admin/petiteparis/shop/lib/Zend/Pdf/Font.php(747): Zend_Pdf_FileParser_Font_OpenType_TrueType->parse()
#7 /home/admin/petiteparis/shop/lib/Zend/Pdf/Font.php(663): Zend_Pdf_Font::_extractTrueTypeFont(Object(Zend_Pdf_FileParserDataSource_File), 0)
#8 /home/admin/petiteparis/shop/app/code/local/Mage/Sales/Model/Order/Pdf/Abstract.php(531): Zend_Pdf_Font::fontWithPath('/home/admin/pet...')
#9 /home/admin/petiteparis/shop/app/code/core/Mage/Sales/Model/Order/Pdf/Invoice.php(44): Mage_Sales_Model_Order_Pdf_Abstract->_setFontBold(Object(Zend_Pdf_Style), 10)
#10 /home/admin/petiteparis/shop/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php(366): Mage_Sales_Model_Order_Pdf_Invoice->getPdf(Object(Mage_Sales_Model_Mysql4_Order_Invoice_Collection))
#11 /home/admin/petiteparis/shop/app/code/core/Mage/Core/Controller/Varien/Action.php(367): Mage_Adminhtml_Sales_OrderController->pdfinvoicesAction()
#12 /home/admin/petiteparis/shop/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(247): Mage_Core_Controller_Varien_Action->dispatch('pdfinvoices')
#13 /home/admin/petiteparis/shop/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#14 /home/admin/petiteparis/shop/app/Mage.php(457): Mage_Core_Controller_Varien_Front->dispatch()
#15 /home/admin/petiteparis/shop/index.php(52): Mage::run()
#16 {main}

Any idea ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
thegwin
Jr. Member
 
Total Posts:  11
Joined:  2009-05-02
Japan
 

Bonjour Loïc

Error message is obviously to do with parsing a font called MacRoman. Have you tried other fonts as that would seem to be the problem.

Here is the MSASAHI font file (Japanese Windows Font) again that I got working OK
http://senduit.com/9631c3

And another alternative Japanese font (Windows) called MSGOTHIC
http://senduit.com/9aa6fa

All the best!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Loic_LC
Sr. Member
 
Avatar
Total Posts:  194
Joined:  2007-12-19
Paris, France
 

Merci !

Thank you so much for getting bact to me this quick.

I DO think it is a font issue, since I get different error message depending on the font.
I’ll try with the font you provided, and post feedback.

Loic

 
Magento Community Magento Community
Magento Community
Magento Community
 
Loic_LC
Sr. Member
 
Avatar
Total Posts:  194
Joined:  2007-12-19
Paris, France
 

Yes !
It does work !

So I guess the font used matters.

Thanks for your very helpfull code.

 
Magento Community Magento Community
Magento Community
Magento Community
 
thegwin
Jr. Member
 
Total Posts:  11
Joined:  2009-05-02
Japan
 

Tres bien. That’s great to hear!

It doesn’t matter which font you use as long as it’s a Japanese font if you want to display Japanese characters.

Happy customizing!

 
Magento Community Magento Community
Magento Community
Magento Community
 
jazkat
Sr. Member
 
Total Posts:  154
Joined:  2009-07-09
 

Doesn’t help for me :-(
I don’t need japanese font, just european characters like “Å¡” etc.

I just posted on this thread, hoping someone might find the right solution:
http://www.magentocommerce.com/boards/viewthread/17974/

Cheers,
K

 
Magento Community Magento Community
Magento Community
Magento Community
 
Loic_LC
Sr. Member
 
Avatar
Total Posts:  194
Joined:  2007-12-19
Paris, France
 

For those interested, Fooman has released an excelent module to customise your PDF (adding a logo, adress etc)
I just made it compatible with Japanese, and I don’t need the (helpfull) hack above anymore.

 
Magento Community Magento Community
Magento Community
Magento Community
 
RealZen
Jr. Member
 
Total Posts:  8
Joined:  2009-09-02
 

I’ve got a very big file around 1mb when generate pdf.
How about yours?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Loic_LC
Sr. Member
 
Avatar
Total Posts:  194
Joined:  2007-12-19
Paris, France
 

With fooman’s module, I don’t have this problem anymore.
It’s around 24 Ko

 
Magento Community Magento Community
Magento Community
Magento Community
 
RealZen
Jr. Member
 
Total Posts:  8
Joined:  2009-09-02
 

With CJK characters?

 
Magento Community Magento Community
Magento Community
Magento Community
 
saideva
Jr. Member
 
Total Posts:  4
Joined:  2009-09-14
 

In admin sale order print, when I print the pdf, I can see only last 4 digits of the credit card number and the remaining numbers as x’s. Is their any way I can see the whole credit card number in the pdf print out.

 
Magento Community Magento Community
Magento Community
Magento Community
 
moomoo
Sr. Member
 
Avatar
Total Posts:  192
Joined:  2009-07-10
 

If anyone else is looking to show Japanese characters, this is specifically built into my Customise Magento PDF extension, pickPack.

There is one dropdown menu option in the config to enable japanese characters. For other ‘non-roman’ characters, there is another option to load the default fonts with the PDF, which means that you can show correctly the various accents in the various typefaces of the world. I also offer free customisation to get it to work with your typeface if it doesn’t work out the box.

 
Magento Community Magento Community
Magento Community
Magento Community
 
aegold
Jr. Member
 
Total Posts:  3
Joined:  2012-12-13
 

YEAH it works!
Thank you for your helps!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top