Page 1 of 3

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

Posted: Fri Nov 03, 2006 8:10 pm
by emav
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.

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

Posted: Fri Nov 03, 2006 8:13 pm
by user deleted
Hi,

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

Regards Robin

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

Posted: Sat Nov 04, 2006 5:37 am
by infograf768
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.

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

Posted: Sat Nov 04, 2006 8:16 am
by emav
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).

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

Posted: Thu Apr 19, 2007 3:44 pm
by ph55
Many thanks to you.
This really works and you helped me a lot.

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

Posted: Fri Apr 20, 2007 11:39 am
by viet4777
Good solution!

But the pdf is very BIG, about 700Kb for only 2 pages without images!

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

Posted: Mon Apr 23, 2007 3:58 pm
by viet4777
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.

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

Posted: Thu May 17, 2007 9:46 am
by ph55
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)

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

Posted: Fri May 25, 2007 9:21 pm
by ivo.apostolov
JM,
please stick the thread :)

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

Posted: Sat May 26, 2007 5:21 am
by infograf768
Done. But I changed the Title as the hack is quite consequent.

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

Posted: Mon May 28, 2007 12:29 am
by ivo.apostolov
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. :)

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

Posted: Sat Nov 03, 2007 1:19 am
by alem2007
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.

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

Posted: Sat Nov 03, 2007 2:18 am
by ivo.apostolov
Please checkup if the problem is in your database first and not in the hack?

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

Posted: Sat Nov 03, 2007 4:26 am
by alem2007
Apoligies, my problem is not Unicode PDF. It is unicode on title field. I guess I am on a wrong topic.

Thank you.

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

Posted: Sat Nov 03, 2007 9:21 am
by emav
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!

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

Posted: Mon Nov 26, 2007 9:41 am
by mtk
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?

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

Posted: Mon Nov 26, 2007 1:25 pm
by infograf768
TCPDF issue?

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

Posted: Mon Nov 26, 2007 1:31 pm
by mtk
very probable...
but if so, we need a second plan for J!1.5

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

Posted: Wed Nov 28, 2007 3:44 pm
by Maksin
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!  :)

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

Posted: Wed Nov 28, 2007 6:15 pm
by emav
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.  ;)

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

Posted: Wed Nov 28, 2007 6:53 pm
by infograf768
@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

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

Posted: Wed Nov 28, 2007 7:09 pm
by mtk
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...

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

Posted: Wed Nov 28, 2007 9:07 pm
by Maksin
Thanks emav.
Work perfectly.  :)

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

Posted: Wed Nov 28, 2007 9:15 pm
by emav
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.  :)

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

Posted: Wed Nov 28, 2007 9:22 pm
by mtk
sure, you need plain text here, or PDF on a file?

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

Posted: Tue Dec 04, 2007 9:27 pm
by alavi nik
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 :-(

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

Posted: Tue Dec 04, 2007 9:44 pm
by emav
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...  :)

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

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

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

Posted: Tue Dec 04, 2007 10:17 pm
by emav
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.

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

Posted: Wed Dec 05, 2007 8:53 am
by mtk
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...