Jump to content

Archived

This topic is now archived and is closed to further replies.

richrock

FPDF rendering of worldwide places

Recommended Posts

Hi,

 

Tearing my hair out with this one, it seems that the inevitable choices of solutions are both intensive pieces of work.

 

I've created a delivery/invoice note generated by FPDF from a shopping cart object in PHP.  It's fine, it's been working well, some teething issues and then this:

 

We had some orders from abroad, namely Saudi Arabia and Israel.  The system uses country codes which are sent to the payment gateway, and the system also determines regions within a country as linked drop-down list with country.

 

So, in one example, someone has selected Israel, and some indecipherable region/state within Israel.

 

This renders in the PDF as:

 

מחוז המרכז

 

Which is no good to anyone!   :happy-04:

 

So I tried to convert DejaVuSans (as recommended in a St***k O******w thread) using the makefont tool, using CP1252 encoding, which is the default.  No luck.  Tried with ISO-8859-1 - still no luck.  Also reran versions with utf8_encode (and utf8_decode just to see what it would do - I was getting desperate at this point).  Nothing.  The best I got was:

 

???? ?????

 

Which showed me that FPDF is generating the region - country parts of the address.

 

I now have two options:

 

1.  Convert every non-english address using english characters.  A massive job as the cart system doesn't do this, but has the capability (?!?)

 

2.  Create a pdf system for each encoding type - something I would like to avoid too, as some of them may never place orders.

 

The ideal solution, and my question is - is there a font or way I can render foreign character sets without determining the encoding of the PDF?

 

Hope that all makes sense.

 

tl:dr - Can't make fonts work in FPDF for foreign places.  Want one solution that doesn't involve masses of work editing databases or files.

Share this post


Link to post
Share on other sites

It sounds like your font simply doesn't have those characters. You'll want to pick a simple font, probably a system one.

Share this post


Link to post
Share on other sites

You will also want to make sure that your website and database are all UTF-8 (at least) enabled. If the form is not UTF-8, then you may be sending the wrongly encoded data to the server. If the database is not UTF-8 you may be storing it wrongly. If the Database connection is not using UTF-8 (immediately after connecting) it may not be retrieving it correctly. I have not worked with FPDF, but you need to look at its settings for UTF-8 as well. The CP1252 encoding, and ISO-8859-1 are not likely to support those characters at all.

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.