[Hack] Unicode PDF problem solved on Joomla! 1.0.x

General questions regarding the use of languages and encoding issues in Joomla! 1.0.x. Multi-lingual site solutions can be discussed in the child board. Translation discussions are now separate and can be found in the Working Groups Area.

Moderator: General Support Moderators

User avatar
emav
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Fri Nov 03, 2006 7:39 pm
Location: Thessaloniki, Greece

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by emav » Wed Dec 05, 2007 12:14 pm

Hi, Mati!

That's the idea. I moved all changes from pdf.php to the TCPDF files since the last time we exchanged messages. As soon as all is tested and well, I'll notify Nicola Asuni, who might want to incorporate the changes to TCPDF's official release.

mtk
Joomla! Guru
Joomla! Guru
Posts: 856
Joined: Sat Nov 12, 2005 10:55 pm
Location: Israel
Contact:

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by mtk » Wed Dec 05, 2007 12:21 pm

OK, just please notify me, so I could test it on a real RTL site (maybe on a J!1.5 site as well)
"In a world without walls and fences,
who needs Windows & Gates?"

http://www.smartmtk.com | http://www.lighthost.co.il/webhosting-for-joomla

User avatar
emav
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Fri Nov 03, 2006 7:39 pm
Location: Thessaloniki, Greece

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by emav » Sat Dec 08, 2007 8:54 pm

Here's the latest news on TCPDF with support for Arabic and Hebrew.

Work is progressing well. So far we've got:
  • Proper alignment of text on the right side of the page
  • Text is properly displayed from top to bottom and from right to left
  • PDF file pages are displayed from right to left when Two-Up Display Mode is selected
  • Arabic letters are properly joined (thanks to ArGlyphs)
  • Mirrored punctuation marks (parentheses etc) are properly reversed
  • Numbers appear from left to right (not tested for Arabic)
  • Limited support for the bidirectional algorithm
What needs to be done:
  • More testing and yet more testing. Beta testers, please, come forth!
  • Fix alignment of pictures
  • Expand support for the bidirectional algorithm
  • Add support for the FriBiDi library
  • Clean up the messy code and fix bugs that have undoubtedly slipped in
  • Many more things that I have no idea of yet ;-)
Attached to this message you can find the tcpdf.php file, as it has been modified so far for PHP5, and ArGlyphs_utf8.class.php (modified version for UTF-8 -- Mostafa, there's something wrong with your project on sourceforge... there's nothing to download in the download area).

Sample pdf files you can find at:

http://www.esperanto.gr/tcpdf/arabic.pdf
http://www.esperanto.gr/tcpdf/hebrew.pdf

Please, test and offer feedback, suggestions, corrections etc.
You do not have the required permissions to view the files attached to this post.
Last edited by emav on Sat Dec 08, 2007 9:10 pm, edited 1 time in total.

mtk
Joomla! Guru
Joomla! Guru
Posts: 856
Joined: Sat Nov 12, 2005 10:55 pm
Location: Israel
Contact:

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by mtk » Sat Dec 08, 2007 11:29 pm

Hey,
great job.
I just can't seem to have any content produced - just the title header & page counter on footer (although it is align correctly)...
"In a world without walls and fences,
who needs Windows & Gates?"

http://www.smartmtk.com | http://www.lighthost.co.il/webhosting-for-joomla

User avatar
emav
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Fri Nov 03, 2006 7:39 pm
Location: Thessaloniki, Greece

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by emav » Sat Dec 08, 2007 11:33 pm

You're probably using tables. They are handled separately by TCPDF and I haven't worked on that yet. Try it on plain text with , tags and so on.

mtk
Joomla! Guru
Joomla! Guru
Posts: 856
Joined: Sat Nov 12, 2005 10:55 pm
Location: Israel
Contact:

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by mtk » Sat Dec 08, 2007 11:42 pm

I've edit the content & now I have it on the PDF.

I made a content with only 2 lines, which created a 200kb(!!!) PDF file...
after ZIP its 187 so I can't attach it...
"In a world without walls and fences,
who needs Windows & Gates?"

http://www.smartmtk.com | http://www.lighthost.co.il/webhosting-for-joomla

User avatar
emav
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Fri Nov 03, 2006 7:39 pm
Location: Thessaloniki, Greece

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by emav » Sat Dec 08, 2007 11:46 pm

The file size is due to the fonts that need to be attached to the file. We could look into that later... The issue now is whether the outcome is correctly displayed and what kind of problems still need to be fixed. There will be lots of them.  8)

tln
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Mon Oct 29, 2007 11:31 am

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by tln » Fri Dec 14, 2007 8:27 pm

guys, how about I applied the fix for php4 suggested earlier and my pdf now shows all squares instead of characters? Why would that be? My web site is bilingual (Russian - English) with JoomFish. :'(

User avatar
emav
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Fri Nov 03, 2006 7:39 pm
Location: Thessaloniki, Greece

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by emav » Fri Dec 14, 2007 8:38 pm

Try different fonts to solve the problem.

ivo.apostolov
I've been banned!
Posts: 1868
Joined: Thu Aug 25, 2005 2:33 pm

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by ivo.apostolov » Fri Dec 14, 2007 9:10 pm

tln wrote: guys, how about I applied the fix for php4 suggested earlier and my pdf now shows all squares instead of characters? Why would that be? My web site is bilingual (Russian - English) with JoomFish. :'(
Do you run it in UTF?

tln
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Mon Oct 29, 2007 11:31 am

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by tln » Mon Dec 17, 2007 12:00 pm

The fonts that I use are just Joomla's standard fonts, arial or something, but nothing fancy. So that shouldn't be the problem. And no, I don't run it in UTF.

ivo.apostolov
I've been banned!
Posts: 1868
Joined: Thu Aug 25, 2005 2:33 pm

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by ivo.apostolov » Mon Dec 17, 2007 12:12 pm

Well, the thread is about the "Unicode" (meaning UTF) hack

notion
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Dec 05, 2007 10:26 pm
Location: Iran
Contact:

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by notion » Fri Dec 21, 2007 1:43 am

hey guys...
yes this is my first message in this commuinty...
by the way..
1.i wanted to ask tcpdf team.. that the arabic peroject has been finished or u guys are still working on that?
(and also i'm gonna use it for farsi language! i guess it works)
2.and also i have a problem (sorry i'm new here) what do u mean by installing language.. is it just copying or something else...
3.i like to take part in testers project of this pdf solving for arabic or farsi joomla..but i don know how and where, all links were in languags i really don understand.. except the download link(thanks god!)

thanks for anyones answer... and guide

User avatar
emav
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Fri Nov 03, 2006 7:39 pm
Location: Thessaloniki, Greece

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by emav » Fri Dec 21, 2007 1:45 pm

notion wrote:hey guys...
yes this is my first message in this commuinty...
by the way..
Welcome to the forum!
notion wrote:1.i wanted to ask tcpdf team.. that the arabic peroject has been finished or u guys are still working on that?
(and also i'm gonna use it for farsi language! i guess it works)
Well, actually, there's no team. Nicola Asuni is responsible for TCPDF. I simply adapted his work to Joomla! 1.0.x.

Now, as far as the project you refered to is concerned... It's not purely Arabic. It hopefully supports Hebrew as well. As a matter of fact, I'm currently rewriting the whole thing to closely follow Unicode standards. Specifically:
  • The new adaptation of TCPDF for Joomla! 1.0.x will support all right-to-left languages in accordance with Unicode 5.0 standards
  • It will be based on a new lighter adaptation of ArGlyphs to support Arabic scripts
  • It will closely follow Unicode's bidirectional algorithm (revision 17) to display bidirectional text independently of FriBiDi (which may or may not be installed on your system)
  • HTML Bidirectional tags will be supported and/or a plugin will be released that will allow you to control the directionality of your text without ever leaving your WYSIWYG editor
  • If all's well, a beta version will be released by the end of this year for 1.0.x (PHP 4 & 5) and, hopefully, another version for Joomla! 1.5 will follow suit
notion wrote:2.and also i have a problem (sorry i'm new here) what do u mean by installing language.. is it just copying or something else...
Are you talking about the installation of TCPDF for Joomla! or something else?
notion wrote:3.i like to take part in testers project of this pdf solving for arabic or farsi joomla..but i don know how and where, all links were in languags i really don understand.. except the download link(thanks god!)
A website for my projects will be set up some time in the close future. A forum for beta testers will be set up there as well. In any case, until then, watch out for any developments and invitations to beta testers in this thread.

notion
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Dec 05, 2007 10:26 pm
Location: Iran
Contact:

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by notion » Fri Dec 21, 2007 2:07 pm

hey dear emav...
well thanks for your reply...and really for your efforts in this project... i'm not a professional in php or solving unicode matters.. but honestly i really like to help you in this project in the role i can ... ( now just a tester!  :( , but hopefully i'm a good tester!)
     - it was a good news.. so seems it's improving alot.. thanks again
     - well my question about installation is exactly about the number 4 of your notes  in beginig of this post.. which u were speaking about "installing" greek languge... this is it... i don understand you from installing ... is it just copying or something else..i guess this is about words!
4. Download the attached Greek language file to display e.g. "Page 1/12" in Greek at the bottom of each page (an English language file is installed by default and new translations can be added as needed). Install it in folder tcpdf/config/lang.
     
     -and am happy about your project website... waiting for that..



with regards
Last edited by notion on Fri Dec 21, 2007 2:13 pm, edited 1 time in total.

User avatar
emav
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Fri Nov 03, 2006 7:39 pm
Location: Thessaloniki, Greece

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by emav » Fri Dec 21, 2007 3:02 pm

notion wrote:    - well my question about installation is exactly about the number 4 of your notes  in beginig of this post.. which u were speaking about "installing" greek languge... this is it... i don understand you from installing ... is it just copying or something else..i guess this is about words!
I see... That note is about the language file that comes with TCPDF. It only displays the word "page" at the bottom of each page. You can create your own language file in includes/tcpdf/tcpdf_php5(or 4)/config/lang (just make sure you save it using the encoding "utf-8 without BOM"). Let tcpdf know which language file you want it to load by changing the configuration appropriately in includes/pdf.php.

notion
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Dec 05, 2007 10:26 pm
Location: Iran
Contact:

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by notion » Sat Dec 22, 2007 12:24 am

so just thanks dude.. looking to hearing good news from you in this project.. i really have problem with joomla pdf creation for farsi ( utf-8 . right to left .joind letters.. seems a hard language we have )
am looking for that eagerly and also ready to do anything i can in this project....i guess now have to  :pop ...... :(

hope u success ang good luck
Last edited by notion on Sat Dec 22, 2007 12:31 am, edited 1 time in total.

User avatar
emav
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Fri Nov 03, 2006 7:39 pm
Location: Thessaloniki, Greece

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by emav » Wed Jan 02, 2008 5:48 am

Hi, there and a happy new year to you all!

As promised here's the new EXPERIMENTAL version of TCPDF for Joomla! 1.0.x with support for RTL languages (Arabic, Farsi, Hebrew, etc.). It's as easy to install as ever. Just follow the instructions here but download this file instead.

Here are some of the main characteristics of the new version:
  • Based on the PHPBiDi class (beta) which I wrote in accordance to Unicode's Bidirectional Algorithm (revision 17) and Unicode 5.0.0
  • Proper alignment of text on the right side of the page
  • Text is properly displayed from top to bottom and from right to left
  • PDF file pages are displayed from right to left when Two-Up Display Mode is selected in Adobe Acrobat Reader
  • Arabic letters are properly joined
  • Mirrored punctuation marks (parentheses etc) are properly reversed
  • Numbers appear from left to right
  • Support for the dir="rtl"/"ltr" tag attributes ( but they are only needed in case of ambiguity)
  • Support for the zero-width joiner and zero-width non-joiner characters for languages using the Arabic alphabet
  • Paragraphs are identified as RTL or LTR by their first letter. If you start with a foreign language quotation, just use the dir="rtl"/"ltr" attributes to get the result you want.
Attached you can also find the updated files for Joomla! 1.5RC4. Just rename libraries/tcpdf/tcpdf.php to libraries/tcpdf/tcpdf.old.php and extract the zipped file in libraries/tcpdf.

I look forward to your beta reports.  :)
You do not have the required permissions to view the files attached to this post.

notion
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Dec 05, 2007 10:26 pm
Location: Iran
Contact:

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by notion » Wed Jan 02, 2008 10:29 am

hey emaw..
happy new year to you and all other joomla guys all over the world... i wish a peaceful life for all.
i was waiting for this great job... i'm gonna start using it...

thanks again...  ;)

notion
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Dec 05, 2007 10:26 pm
Location: Iran
Contact:

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by notion » Wed Jan 02, 2008 11:56 am

WOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOW ;D
i hope u don think i'm gay, but really feel in love with u :P..... but it's great.. working !!! finally i got my farsi PDF.... it's full working....
easy installation... no error... full working... thanks again..
WOW.. it was couples of monthes... i was waiting for this great oppertunity... in joomla..
the interesting part is when i was using english language... my farsi characters in joomla was wrong.. i mean "«" characters.. they were in end of sentence instead of begining.... but it was correct in your PDF... thanks again..i appreciate this great job.. it was a great news for me in new year.. seems 2008 is a jooml year ! ;)

a question.. how can i fix my little program with my photo gallery module ... it shows the syntax code used in content instead of image.. do u think we can fix it.. but really not important now.. and the matter is your great job !!

Saman Zareian

User avatar
emav
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Fri Nov 03, 2006 7:39 pm
Location: Thessaloniki, Greece

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by emav » Wed Jan 02, 2008 2:01 pm

I'm happy that it works for you. There's still a lot of work to be done though. For example, we need to optimize PHPBiDi for speed, fix any bugs that might appear under unexpected circumstances and improve pdf rendering where it's still messy (links, tables, etc). However, I thought that it would be a pity to have a brand new stable Joomla! 1.5 without any sort of support for RTL languages in PDF. So, I thought I should release whatever I've done so far in this field.

Anyway, as I've mentioned above, I would appreciate any and all comments that might help improve this little project.

notion
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Dec 05, 2007 10:26 pm
Location: Iran
Contact:

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by notion » Wed Jan 02, 2008 2:43 pm

Dear friend emaw..
after my successful experiment in your hack .. i spoke with my persian joomla friends about your hack.. and now they wanna use this hack in their joomla....
i wanted to know... do u let me to help them and teach them the procedure how to use it in joomla...

thanks

User avatar
emav
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Fri Nov 03, 2006 7:39 pm
Location: Thessaloniki, Greece

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by emav » Wed Jan 02, 2008 3:06 pm

notion wrote:i wanted to know... do u let me to help them and teach them the procedure how to use it in joomla...
What kind of question is this? Of course!  :D

notion
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Dec 05, 2007 10:26 pm
Location: Iran
Contact:

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by notion » Wed Jan 02, 2008 5:13 pm

yes i know here is the open source world.. but u didn give any license type for your project.. so i just thought you may wanna keep the right for yourself as the only one to publish or maybe help others to use it.. but anyway thank you.. for your great job..

you gave me a gret feeling this morning...was a good present for new year.. i guess english guys may don understand..why i'm happy... before this.. they had PDF solutions as default without a momnet to think about how much could the world could be worse without that tiny beauty button.. ;)


wish u a great year.. my friend

User avatar
emav
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Fri Nov 03, 2006 7:39 pm
Location: Thessaloniki, Greece

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by emav » Wed Jan 02, 2008 5:35 pm

notion wrote:yes i know here is the open source world.. but u didn give any license type for your project..
I do have a license. It's at the top of every file. TCPDF is distributed under GNU LGPL (http://www.gnu.org/copyleft/lesser.html) while PHPBiDi under GNU GPL (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
notion wrote:i guess english guys may don understand..why i'm happy... before this.. they had PDF solutions as default without a momnet to think about how much could the world could be worse without that tiny beauty button.. ;)
As a native speaker of Greek, I know the feeling.  ;)
notion wrote:wish u a great year.. my friend
All the best to you, too.
Last edited by emav on Wed Jan 02, 2008 5:38 pm, edited 1 time in total.

User avatar
emav
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Fri Nov 03, 2006 7:39 pm
Location: Thessaloniki, Greece

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by emav » Wed Jan 02, 2008 7:30 pm

emav wrote:TCPDF is distributed under GNU LGPL (http://www.gnu.org/copyleft/lesser.html)
Reading my reply again, I thought I should avoid any misunderstandings by giving due credit once more to Nicola Asuni, who created TCPDF in the first place. I simply modified it for use with Joomla! 1.0.x and PHPBiDi.

User avatar
emav
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Fri Nov 03, 2006 7:39 pm
Location: Thessaloniki, Greece

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by emav » Wed Jan 02, 2008 9:10 pm

To avoid double headers in Joomla! 1.5RC4, please, comment out lines 65 and 68 in components/com_content/views/article/view.pdf.php, like so:

Code: Select all

	if ($article->usertype == 'administrator' || $article->usertype == 'superadministrator') {
		//$text .= "\n";
		$text .= JText::_('Written by').' '. ($article->created_by_alias ? $article->created_by_alias : $article->author);
	} else {
		//$text .= "\n";
		$text .= JText::_('Contributed by').' '. ($article->created_by_alias ? $article->created_by_alias : $article->author);
	}

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 19133
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by infograf768 » Thu Jan 03, 2008 7:51 am

@emav

Any change you are sure is necessary now in 1.5 to get tcpdf working in RTL, or avoiding double headers, or whatever needed improvement please post urgently in Tracker with code.
Jean-Marie Simonet / infograf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

User avatar
emav
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Fri Nov 03, 2006 7:39 pm
Location: Thessaloniki, Greece

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by emav » Thu Jan 03, 2008 1:52 pm

@infograf768

Please, bear with me as I also prepare a solution to the problem of links appearing on top of one another (but this will only affect TCPDF).

If anybody else has noticed anything else apart from problems with tables and pictures (which need much more work to be fixed), please, come forward with a bug report.
Last edited by emav on Thu Jan 03, 2008 1:53 pm, edited 1 time in total.

User avatar
dzed
Joomla! Guru
Joomla! Guru
Posts: 994
Joined: Sun Feb 18, 2007 6:40 pm
Location: California, USA
Contact:

Re: [Hack] Unicode PDF problem solved on Joomla! 1.0.x

Post by dzed » Sat Jan 05, 2008 2:51 pm

Hey,
good job.

i tested your hack in Joomla v1.5-RC4 and up to v1.5 Build-9867 2008-01-05
- Language *en-GB* end *fr-FR*
- TinyMCE 2.1.2

1 - work fine in article with arabic

2 - the alignement of line made by the editor e.g. Aligne centre, Aligne left, etc... not work

3 - the variation of the line e.g. bold, bold oblique, etc... not work only Underline work see pic

4 - all latin Language is aligne auto to the right of pdf page and arabic to left


see pic

- Joomla article in IE7
Image

- PDF file generated with TCPDF(+hack)
Image

Note about arabic fonts used in my test

i use Andalus(microsoft-Not free ) + (trado -free) to generat smale PDF file all other inclu in TCPDF package and support arabic generated big file

info about file generated and size

- Andalus = 68 Ko
- trado = 112 Ko
- DejaVuSans = 646 Ko
Saber Bousba - صابر بوصبع
Former Member of the Arabic [ar-DZ] Joomla Translation Team :  http://joomlacode.org/gf/project/ardz/


Locked

Return to “Language - 1.0.x”