[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

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

Post by emav » Fri Nov 03, 2006 8:10 pm

As it was announced on myjoomla.gr yesterday, this problem has been fixed for Joomla! 1.0.x. Here's how:

1. Download the appropriate version of TCPDF for the php version used by your server (either 4 or 5).

2. Decompress the downloaded file in the includes/ folder. Rename the new folder tcpdf (if it's not already called so).

3. Correct the installation and URL path in includes/tcpdf/config/tcpdf_config.php like so:

Code: Select all

define ("K_PATH_MAIN", "path_to_your_joomla/includes/tcpdf/");
define ("K_PATH_URL", "url_to_your_joomla/includes/tcpdf/");
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.

5. Rename path_to_your_joomla/includes/pdf.php into path_to_your_joomla/includes/pdf.php.bk

6. Download the attached modified pdf.php and copy it to path_to_your_joomla/includes/.

7. Change the following variables as needed in file pdf.php

Code: Select all

/************************ Start editing here ************************/

	$lang = 		'el';				// Language (change it to eng for English)
	$enc = 			'UTF-8';			// Encoding
	$unit = 		'mm';				// Unit of measurement
	$format = 		'A4';		 		// Page format
	$orient = 		'P';		 		// Page orientation
	$fnt = 			'FreeSerif'; 		        // Font name
	$size = 		10; 				// Font size
	$mrgleft = 		20;				// Left margin
	$mrgright = 	        20;				// Right margin
	$mrgtop = 		40;				// Top margin
	$mrgbottom = 	        30;				// Bottom margin
	$mrghead = 		20;				// Header margin
	$mrgfoot = 		20;				// Footer margin
	$scale = 		1;				// Image scale factor

/************************ Stop editing here ************************/
8. That's it! Enjoy unicode-friendly pdf files but don't forget to install fonts as needed in the url_to_your_joomla/includes/tcpdf/fonts/ folder.


This hack has been tested on php4 and php5. Images do not seem to be incorporated in the produced pdf files with php5 and there seems to be a problem with wide tables.

Any suggestions or bug reports are highly appreciated and, if possible, should be cc'ed to the creator of TCPDF.
You do not have the required permissions to view the files attached to this post.
Last edited by infograf768 on Sat May 26, 2007 5:20 am, edited 1 time in total.

user deleted

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

Post by user deleted » Fri Nov 03, 2006 8:13 pm

Hi,

At first glance this looks really good. I'll be trying this hack/patch myself, thanks for posting it.

Regards Robin

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

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

Post by infograf768 » Sat Nov 04, 2006 5:37 am

tcpdf is indeed the solution used in Joomla 1.5, thanks to davidgal.
See libraries/tcpdf  ;)

I will test this too on a utf8 site.
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: Unicode PDF problem solved on Joomla! 1.0.x

Post by emav » Sat Nov 04, 2006 8:16 am

infograf768 wrote: tcpdf is indeed the solution used in Joomla 1.5, thanks to davidgal.
See libraries/tcpdf  ;)
True! I just checked it out!  :)

I thought (and, unfortunately, wrote so to the creator of TCPDF, Nicola Asuni) that the Joomla! team was developing their own solution to the unicode-pdf problem for the upcoming 1.5 version. It seems that Nicola was also unaware of this development.

For those Joomla! users who don't have a local web site set up for testing purposes, you can see how well TCPDF integrates with Joomla! 1.0.11 and php4 here (picture included) and here (wide table problem).

ph55
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Thu Apr 19, 2007 3:27 pm

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

Post by ph55 » Thu Apr 19, 2007 3:44 pm

Many thanks to you.
This really works and you helped me a lot.

User avatar
viet4777
Joomla! Explorer
Joomla! Explorer
Posts: 321
Joined: Sat May 20, 2006 10:02 am
Location: Hà thành
Contact:

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

Post by viet4777 » Fri Apr 20, 2007 11:39 am

Good solution!

But the pdf is very BIG, about 700Kb for only 2 pages without images!
http://kythuatvatlieu.org
http://kulkul.luyenkim.org
The 1st Vietnamse Portal in Metallurgy and Materials Technology
Sắt thép, nhiệt luyện, cán kéo kim loại, thiêu kết, mô phỏng, thí nghiệm, kiểm tra vật liệu, vô định hình, đúc hợp kim, tinh luyện

User avatar
viet4777
Joomla! Explorer
Joomla! Explorer
Posts: 321
Joined: Sat May 20, 2006 10:02 am
Location: Hà thành
Contact:

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

Post by viet4777 » Mon Apr 23, 2007 3:58 pm

I have two questions:
- How do we display image in case using {mosimage} in the content?
- How to make {mosPageBreak} also work for PDF file? I mean we also make a break page in pdf file!

Thanks.
http://kythuatvatlieu.org
http://kulkul.luyenkim.org
The 1st Vietnamse Portal in Metallurgy and Materials Technology
Sắt thép, nhiệt luyện, cán kéo kim loại, thiêu kết, mô phỏng, thí nghiệm, kiểm tra vật liệu, vô định hình, đúc hợp kim, tinh luyện

ph55
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Thu Apr 19, 2007 3:27 pm

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

Post by ph55 » Thu May 17, 2007 9:46 am

viet4777 wrote: - How do we display image in case using {mosimage} in the content?
I also had this problem and what i did was that i removed ability to insert {mosimage} and use WYSIWYG editor, that inserts images as links directly.

Another problem also exist - GIF images are not supported. If some topic contains gif image and you generate pdf, you simply get an error and not even a part of document (nor document without images)

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

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

Post by ivo.apostolov » Fri May 25, 2007 9:21 pm

JM,
please stick the thread :)

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 » Sat May 26, 2007 5:21 am

Done. But I changed the Title as the hack is quite consequent.
Jean-Marie Simonet / infograf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

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 May 28, 2007 12:29 am

OK, improved version (easier):

1. Backup the file includes/pdf.php
2. Download
- This file, if you use php4
- This file, if you use php5
3. Unzip and upload to your Joomla! folder.

Note: You need to edit the includes/tcpdf/config/lang/english.php if you are using right to left language.

I am trying at the moment to make it load the language automatically, so no manual code inputs to be needed. After that I might consider to make it installable as a component. :)

alem2007
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sat Nov 03, 2007 1:13 am

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

Post by alem2007 » Sat Nov 03, 2007 1:19 am

I am having the same problem. I used the instruction give above but can't seem to change the title and diplay it in Unicode.

Any help is appreciated!

Thank you.

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 » Sat Nov 03, 2007 2:18 am

Please checkup if the problem is in your database first and not in the hack?

alem2007
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sat Nov 03, 2007 1:13 am

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

Post by alem2007 » Sat Nov 03, 2007 4:26 am

Apoligies, my problem is not Unicode PDF. It is unicode on title field. I guess I am on a wrong topic.

Thank you.

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 Nov 03, 2007 9:21 am

It's been since March 2007 that I offered this solution to the Greek Joomla! forum but I completely forgot to mention it here. Today I received a notification regarding the latest mesages so... here it goes:
  • Rename includes/pdf.php to includes/pdf.php.bk
  • Download TCPDF for Joomla! 1.0.x here.
  • Upload and decompress the file in the includes folder.
  • You are ready to go!
The file is a bit bulky because it contains both TCPDF versions for PHP 4 & 5. The appropriate php version is selected automatically and a few of TCPDF's configuration files have been tampered with, so there is no need for you to edit any other files apart from includes/pdf.php as proposed in the first post of this thread (of course, you can also translate and change the language file that's been loaded if you speak any language other than English or Greek).

The file is based on the latest TCPDF version, which has been slightly changed (actually, bent) to support .gif images apart from .jpg and .png, which were already fully supported. Support for {mosimage}, {mospagebreak} and {jumi} has also been added.

Enjoy!

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 » Mon Nov 26, 2007 9:41 am

Hi,
this is indeed a great solution to all the non-Latin languages, & it does work.
but there's a problem setting the PDF to display in RTL.

This issue is a problem to both 1.0.x & 1.5.x PDF's...

can anyone share a solution for this?
"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
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 » Mon Nov 26, 2007 1:25 pm

TCPDF issue?
Jean-Marie Simonet / infograf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

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 » Mon Nov 26, 2007 1:31 pm

very probable...
but if so, we need a second plan for J!1.5
"In a world without walls and fences,
who needs Windows & Gates?"

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

Maksin
Joomla! Intern
Joomla! Intern
Posts: 93
Joined: Wed Nov 28, 2007 3:22 pm
Location: Belgrade, Serbia
Contact:

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

Post by Maksin » Wed Nov 28, 2007 3:44 pm

This is great & work like a charm.
But can some one help me make custom footer message.
Would like to show domain name and email address.

Looked at pdf.php, but couldn't figure out where to put it.
Just a simple line of text.

Thanks!  :)
CEO & Lead Developer at WebHostLab
https://www.webhostlab.com

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 Nov 28, 2007 6:15 pm

Change line 1443 (if you've got PHP5) or line 1436 (if you've got PHP4) in includes/tcpdf/tcpdf_php5/tcpdf.php or includes/tcpdf/tcpdf_php4/tcpdf.php respectively as follows:

Code: Select all

$this->Cell(0, $footer_height, 'my message here!', 'T', 0, 'R');
Change the final 'R' to 'L', if you'd like to align your text to the left.

PS: Ah, yes! There is also 'C' for center.  ;)
Last edited by emav on Wed Nov 28, 2007 6:18 pm, edited 1 time in total.

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 » Wed Nov 28, 2007 6:53 pm

@MTK
If this works, would be good to find a way to change this parameter in 1.5.
Issue would be that ideally it should change on an article basis and not globally.
Not sure this would be possible for 1.5
Jean-Marie Simonet / infograf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

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 Nov 28, 2007 7:09 pm

As soon as, RTL issue is solved, I'll be more than happy to try & find the way to set this by template/language params...
"In a world without walls and fences,
who needs Windows & Gates?"

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

Maksin
Joomla! Intern
Joomla! Intern
Posts: 93
Joined: Wed Nov 28, 2007 3:22 pm
Location: Belgrade, Serbia
Contact:

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

Post by Maksin » Wed Nov 28, 2007 9:07 pm

Thanks emav.
Work perfectly.  :)
CEO & Lead Developer at WebHostLab
https://www.webhostlab.com

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 Nov 28, 2007 9:15 pm

mtk wrote: Hi,
this is indeed a great solution to all the non-Latin languages, & it does work.
but there's a problem setting the PDF to display in RTL.

This issue is a problem to both 1.0.x & 1.5.x PDF's...

can anyone share a solution for this?
I started looking into this since you mentioned the problem. It never occured to me that it wouldn't work for RTL languages (actually, I never gave it a thought). Could you send me a sample text mixing Hebrew and/or Arabic with English to try and fix/hack the problem?
Maksin wrote: Thanks emav.
Work perfectly.  :)
I'm always glad to help.  :)

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 Nov 28, 2007 9:22 pm

sure, you need plain text here, or PDF on a file?
"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
alavi nik
Joomla! Explorer
Joomla! Explorer
Posts: 344
Joined: Wed Sep 20, 2006 7:48 pm
Location: Tehran,Iran
Contact:

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

Post by alavi nik » Tue Dec 04, 2007 9:27 pm

emav wrote: Change line 1443 (if you've got PHP5) or line 1436 (if you've got PHP4) in includes/tcpdf/tcpdf_php5/tcpdf.php or includes/tcpdf/tcpdf_php4/tcpdf.php respectively as follows:

Code: Select all

$this->Cell(0, $footer_height, 'my message here!', 'T', 0, 'R');
Change the final 'R' to 'L', if you'd like to align your text to the left.

PS: Ah, yes! There is also 'C' for center.  ;)
Hello,
for rtl don`t work :-(
Joomfa Team(Joomla farsi) ==> http://joomfa.org

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 » Tue Dec 04, 2007 9:44 pm

modern wrote:Hello,
for rtl don`t work :-(
Watch out for a solution to the rtl problem by the end of the month. First tests look promising...  :)

User avatar
alavi nik
Joomla! Explorer
Joomla! Explorer
Posts: 344
Joined: Wed Sep 20, 2006 7:48 pm
Location: Tehran,Iran
Contact:

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

Post by alavi nik » Tue Dec 04, 2007 9:58 pm

Joomfa Team(Joomla farsi) ==> http://joomfa.org

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 » Tue Dec 04, 2007 10:17 pm

Great analysis, Mostafa (?).

I followed the same methodology more or less when the rtl problem was first reported and came against the bottom-lines-up issue you mentioned. So, I gave that up and started modifying the pdf file that's finally produced by TCPDF. This seems to solve the problem at the source. Maybe we could merge the two projects together once I'm finished hacking away to solve this issue effectively and quickly.

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 8:53 am

Emav,
can you please try & keep your hack to TCPDF as long as possible?
This way we could merge it easily for J!1.5...
"In a world without walls and fences,
who needs Windows & Gates?"

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


Locked

Return to “Language - 1.0.x”