Jump to content

FPDF rendering of worldwide places


richrock

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.

Link to comment
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.