Jump to content

Arabic PDF Invoices Issue with Prestashop 1.6.1


Recommended Posts

Yes, In my desperation I researched and found out that tcpdf is the tool used to create PDF. I compared the two  versions using Winmerge and all files are identical.

 

As for the font. I didn't change it. I am using the default theme and font.

 

Thank you for your reply.

Link to comment
Share on other sites

Hi,,

 

I just installed prestashop 1.6.1 locally to test the pdf issue and I was able to generate PDF in Arabic. So to track down the issue in the live site I tried to disable add-ons one by one but still I couldn't find the source. Can soneone please help. Any suggestions?

Link to comment
Share on other sites

Hi,

 

So I was doing everything I could. For two days. I found out something. If the page interface is English, this issue happens but if I change the interface language to Arabic the issue disappears. Please advice if anyone have a quick fix for this. 

Link to comment
Share on other sites

أهلا وسهلا فيك أخ علي بالمنتدى

 

مشكلتك غريبة جدا!

 

ممكن تعطينا رابط موقعك أو ترسله لي بالخاص؟

 

بالتوفيق

 

 

Thank you Phil,

 

My website is matjarakum.com.

 

And this issue is not in my website, it is in version 1.6.1. I have a portable Apache server in my pc (XAMPP). I do tests on it. If the interface is English, Arabic texts in PDF appears as question marks. But if the interface is in Arabic, PDF files are fine.

 

 

I opened a ticket about it in bug tracker "http://forge.prestashop.com/browse/PSCSX-6252" and still waiting for their reply. But I was in a haste before since I thought there is no work around over it. But still I would want a solution  for this to be able to prent invoices easily.

 

Many thanks,

Link to comment
Share on other sites

Sorry it took me a while but I finally have it.

 

First of all I would like to welcome and thank tuk66 for joining our thread. In case you do not know it Ali, tuk66 is our leading expert when it comes to Presta's PDF and invoice handling.

 

For your current issue, well it is split into two categories. First, you got the currency codes, they are marked with ?? in your invoices and as squares in my invoices (my stores).

 

This is an encoding issue since I knew PrestaShop long time ago. It has to be fixed by the Presta team. For regular text being displayed in ?????, well that's weird because that does not happen with versions of 1.6.0.x

 

If it is really troubling you, you are not left with an option except buying tuk66 PDF component, even though it needs some elements tweaking and repositioning in Arabic invoice templates but it is cleanly encoded.

 

Another slim chance I would think of might be the encoding you used for your database maybe? I do not know if tuk66 would agree on that but still, even if regular text encoding was fixed you will still have the currency code displayed in squares ريال -> [] and so on.

 

By the way, what was the SMS and Mail modules you used??? They are pretty neat!! Good job, keep it up.

 

Good luck.

Edited by PhilCorleone (see edit history)
  • Like 1
Link to comment
Share on other sites

I believe I now figured it for real.

 

I have looked up the script maps tuk66 provided.

 

Dejavu doesn't support Arabic in all of its font versions.

 

There might be 30 versions of it for example and there are 25-24 which support Arabic while 5-6 do not support non-latin.

 

Loool, the font used by the invoice happened to be one of those 5-6 fonts which do not support non-latin.

 

I believe the font is DejaVu Sans ExtraLight. We have to dig up your templates files for the invoices to change that font. Hope tuk66 give us a hand.

 

That's my theory at least and from what I have seen on the website tuk66 provided (ExtraLight font shows up as ????? when testing with Arabic letters).

 

Good luck.

  • Like 1
Link to comment
Share on other sites

Hi  tuk66 and Phil,

 

Thank you for looking into it.

 

Yes, I knew tuk66 by his signature. I saw his site. But right now I am a startup so I am trying to cut costs until I get real benefit from this project. I am still working on the website. Next is online payment and Aramex account.

 

I am a technical guy and the owner. I know tiny bits of web developments which I got from troubleshooting and a little automation. So I am alone in this project.

 

How did you know about the Mail and SMS? Is that you who made the order? Is it a real order :) ? I  was in Jubail in Al Fanateer Beach today morning lol. 

 

I think I need to troubleshoot the free delivery. The order is only SR 10. I don't know how it keeps happening. It keeps setting the delivery costs to 0 although I set it to SR 20. Maybe i will need to re-create the Carrier.

 

As for mail, It came built in with prestashop. As for the SMS I got is from http://www.presta-sms.com/

 

I found out that there are great and free modules which I can find using google which are not in prestashop.com store.

 

For Arabic text becoming ???? I think it is a bug in their software since it was working fine on 1.6.0.14 and still if the interface is in Arabic as for ريال symbol, your finding looks promising. I think I will look into using Google fonts with tcpdf, It will take time since I need to figure it out but I think it is as simple as saving the font in "tools\tcpdf\fonts" and changing the font for Arabic in the array of https://github.com/PrestaShop/PrestaShop/blob/develop/classes/pdf/PDFGenerator.php#L42

 

Right now the issue is not troubling me too much since I found out if the customer register in the Arabic interface he can download the invoice without any issues.

 

Thank you

Edited by alihkhawaher (see edit history)
Link to comment
Share on other sites

Hello Ali, oh yeah that was me.

 

It is what I thought, Mail Alerts + PrestaSMS. Good job you got it figured as you know, stores in the middle east need specific solutions which may not work with the European ones etc.

 

Thanks for providing insights of how to change the font. Much appreciated, I needed that!


By the way, the orders are not real, i'm out of the country now :(

Edited by PhilCorleone (see edit history)
  • Like 1
Link to comment
Share on other sites

Hi Phil,

 

Thank you for the modules, I have purchased them. I needed them and great tip regarding the tax. As for PayTabs, yes I found them and I fixed their module and it worked :D and I tried to get to their support to give them the fix but they ignored me and they took 2 whole months to to look at my application while I was following with them almost weekly.  They had main bank account change and they postponed approving new applications for that whole period. Then after that they gave me requirements to do. But I was not active on my site (concentrating on other things) so another month wasted, Just since 1 week I am back working on my site again and I will reply to them to activate my account later.

 

Well I need to use them since they are the cheapest. Everyone else they want to take a percentage and ridiculously huge monthly subscription. Not good for a start up and someone working on his spare time.

 

Regarding their module. I think it didn't fill the billing info automatically. Did you fix that too?

Link to comment
Share on other sites

Hello Ali,

 

Glad you are keeping up. Yeah for PayTabs, I have fixed a redirection problem not what you said. In addition, i'm not that far into testing it yet. I have not purchased the Aramex module yet too. I need more time. I have spent almost 4 months setting up Active directory, Exchange server, Security etc. It is a lot of work!

 

For the billing info, I don't think you need them at all? Why filling? Or do you mean filling them from the website to the paytabs bill? If that's what you meant then yes it fills it correctly in my case.

 

What I like about these guys is flexibility. They save you the headache of dealing with other backward payment processors including banks! (SAMBA, ALAHLI, the suckiest!!)

 

They are a startup venture as you know, I would expect the bank change!

 

For their module's issues. The module was programmed by a freelancer, here they are if you want to contact them:

 

http://www.vnphpexpert.com/

  • Like 1
Link to comment
Share on other sites

Hi Phil,

 

Thanks for the tips. Actually you recommended that Aramex module I bought it since I thought you used it. Well I will buy it eventually. Thank you.

 

Thank you for the more insight of the PayTabs module too.

 

Can I ask why you need Active directory, Exchange server, Security etc for an online shop?

Edited by alihkhawaher (see edit history)
Link to comment
Share on other sites

It is not because i'm recommending it or not. It is because it's the only solution out there you got me?

 

I will buy it eventually soon, I will hand you a copy then. Don't duplicate payments.

 

When your store becomes bigger with time, you will find it difficult to expand as there will be too much variables to take care of.

 

I mean, you setup an infrastructure once and let it live for the next 5 years instead of struggling each couple of months with upgrades. I had guys trying to hack the server's RDP by brute force. I had others trying to DDos other servers through mine by using DNS Amplification attack. If your website's server lay a victim for such attacks? It would be hard to diagnose and you would start to see real weird problems such as the database failing and then restarting, PrestaShop sign in authentication request blacks out on customers etc.

 

For exchange etc. I got two teams one in the US and one in KSA. They need a good communication platform. A regular website ain't going to cut it.

 

The volume of products plays a role too. I see you got a phone shop somehow, your whole design for the store is efficient for current requirement.

 

It depends on your situation, capital, labor at the end.

  • Like 1
Link to comment
Share on other sites

Well I am struggling,

 

This is my first experience and I don't know anyone who knows better than me and it is all self learn with small budget. So I am alone on this.I still don't even have suppliers. Currently I am buying from China and resell locally. I try to find solution for common issues.

 

Regarding the ريال symbol in invoices. I downloaded the font pack from tcpdf website (http://sourceforge.net/projects/tcpdf/files/) and installed it on my localhost test server and changed the font for 'ar' to freeserif in "PDFGenerator.php". It worked. For Google fonts i think they need a conversion or something. I don't want to waste time on them.

 

What I feel from what you are saying is that you are configuring your own server. Well I am using (www.a2hosting.com). Their servers are fast and they provide CloudFlare protection against DDos. At the start I hosted my website at go daddy which was painfully slow. After one week of struggles I found that their servers are slow so I switched.

 

As a communication platform. Did you try Google Apps for Business? I tried it just to see what is is :D. It is only $5/mo. They give me all the Google services and MDM for devices on my Domain and totally under my control. It is nice.

 

Until the Arabic invoices get fixed I need to fix RTL CSS. The only solution I know is this file (https://github.com/nashcontrol/prestashop-default-bootstrap-rtl/tree/master/css) but it is not complete and have many issues. I am struggling to fix them, Do you have a better/updated version?

 

Many thanks,

Edited by alihkhawaher (see edit history)
Link to comment
Share on other sites

I found a work around that fixes both ريال symbol AND Arabic text. It is to change the font for both Arabic AND English to 'freeserif'. In classes\PDF\PDFGenerator.php. It will be like this:

class PDFGeneratorCore extends TCPDF
{
	const DEFAULT_FONT = 'freeserif';

	public $header;
	public $footer;
	public $content;
	public $font;

	public $font_by_lang = array(
		'ja' => 'cid0jp',
		'bg' => 'freeserif',
		'ru' => 'freeserif',
		'uk' => 'freeserif',
		'mk' => 'freeserif',
		'el' => 'freeserif',
		'vn' => 'dejavusans',
		'pl' => 'dejavusans',
		'ar' => 'freeserif',
		'fa' => 'dejavusans',
		'ur' => 'dejavusans',
		'az' => 'dejavusans',
		'ca' => 'dejavusans',
		'gl' => 'dejavusans',
		'hr' => 'dejavusans',
		'sr' => 'dejavusans',
		'si' => 'dejavusans',
		'cs' => 'dejavusans',
		'sk' => 'dejavusans',
		'ka' => 'dejavusans',
		'he' => 'dejavusans',
		'lo' => 'dejavusans',
		'lt' => 'dejavusans',
		'lv' => 'dejavusans',
		'tr' => 'dejavusans',
		'ko' => 'cid0kr',
		'zh' => 'cid0cs',
		'tw' => 'cid0cs',
		'th' => 'freeserif'
	);

The only problem is that the Arabic font ugly in freeserif :D . We don't need to download the font pack. The freeserif font comes with prestashop or the mini tcpdf.

Link to comment
Share on other sites

After thinking and testing. I think the better option is using 'dejavusans' for both ar and DEFAULT_FONT. It is a better Arabic font. so the new code is:

class PDFGeneratorCore extends TCPDF
{
	const DEFAULT_FONT = 'dejavusans';

	public $header;
	public $footer;
	public $content;
	public $font;

	public $font_by_lang = array(
		'ja' => 'cid0jp',
		'bg' => 'freeserif',
		'ru' => 'freeserif',
		'uk' => 'freeserif',
		'mk' => 'freeserif',
		'el' => 'freeserif',
		'vn' => 'dejavusans',
		'pl' => 'dejavusans',
		'ar' => 'dejavusans',
		'fa' => 'dejavusans',
		'ur' => 'dejavusans',
		'az' => 'dejavusans',
		'ca' => 'dejavusans',
		'gl' => 'dejavusans',
		'hr' => 'dejavusans',
		'sr' => 'dejavusans',
		'si' => 'dejavusans',
		'cs' => 'dejavusans',
		'sk' => 'dejavusans',
		'ka' => 'dejavusans',
		'he' => 'dejavusans',
		'lo' => 'dejavusans',
		'lt' => 'dejavusans',
		'lv' => 'dejavusans',
		'tr' => 'dejavusans',
		'ko' => 'cid0kr',
		'zh' => 'cid0cs',
		'tw' => 'cid0cs',
		'th' => 'freeserif'
	);
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...