Arabic words in invoice pdf print Magento

1.5k views Asked by At

I'm trying to fix this problem by using integration TCPDF in magento but i don't know how do that

this is my try in this file \app\code\core\Mage\Sales\Model\Order\Pdf\Abstract.php

require_once('TCPDF/TCPDF.php');
$pdf = new TCPDF_TCPDF
(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true,'UTF-8', false);

I don't know waht i'm doing wrong. thank you.

1

There are 1 answers

2
Claudiu Creanga On BEST ANSWER

1) Don't edit core files.

2) There are multiple invoice generators in magento: invoice from the backend, invoice on success page etc. So make sure that you are editing and testing the right one. The example below works for invoices in the backend.

3) There may be custom modules that are overwriting your xml, like Webshopapps_Invoicing, check that or it will not work (that's the issue that I had when trying something similar).


After you copied TCPDF to your magento lib folder so that you will have now root/TCPDF/TCPDF.php edit TCPDF.php by changing the class name from tcpdf to TCPDF_TCPDF

Go into code/local/Yourcompany and create the folder invoices. In this folder create etc/config.xml with this content:

<?xml version="1.0"?>
<config>
    <modules>
         <Yourcompany_Invoices>
            <version>0.0.1</version>
        </Yourcompany_Invoices>
    </modules>
    <global>
        <models>
            <sales>
                <rewrite>                    
                    <order_pdf_invoice>Yourcompany_Invoices_Sales_Model_Order_Pdf_Invoice</order_pdf_invoice>
                </rewrite>
            </sales>
        </models>
   </global>
</config>

Create another folder structure in code/local/Yourcompany like this Sales/Model/Order/Pdf and add Invoice.php:

class Yourcompany_Invoices_Sales_Model_Order_Pdf_Invoice extends Mage_Sales_Model_Order_Pdf_Invoice { 
// it can be another class if you have a custom module overwriting it, like Webshopapps_Invoicing_Sales_Model_Order_Pdf_Invoice
  $pdf = new TCPDF_TCPDF();//your stuff here
}

Then submit a test order and go into admin and check a pdf invoice.