11
dnprossi
Re: News 1.63 - PDF Creation: UTF-8 not working and xLanguage Problems
  • 2008/12/15 14:05

  • dnprossi

  • Not too shy to talk

  • Posts: 107

  • Since: 2006/3/15


OK... fpdf and tcpdf are quite hard to cope with as there are so many possible settings.

here is a temporary solution...

This is what I did to get at least tcpdf to run with utf-8 and run without error on xlanguage.

First remove all calls to function news_unhtml() in news/pdf/pdf.php lines 243,257,258 - UTF-8 will start working if language files have been set correctly.

Second I changed end of line 240 from
.....$article->uname()).'<br />'._MD_POSTEDON.' '.formatTimestamp($article->published(),$dateformat).'<br /><br /><br />';

to
.....$article->uname()).'<br /><br /><br /><br />';


formatTimestamp($article->published(),$dateformat);

seems to be the problem...

removing all date stuff and now when language is changed in xlanguage all works with no error.

Hope this can help find better solutions..

12
culex
Re: News 1.63 - PDF Creation: UTF-8 not working and xLanguage Problems
  • 2009/11/12 1:32

  • culex

  • Module Developer

  • Posts: 711

  • Since: 2004/9/23


I realize I am a bit late to dis thread, but also i have problems on this subject.

Tried your solution dnprossi but no success. The danish letters still prints as iso characters.

13
ghia
Re: News 1.63 - PDF Creation: UTF-8 not working and xLanguage Problems
  • 2009/11/13 1:12

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Did you check the language file as mentioned in post #10?

14
culex
Re: News 1.63 - PDF Creation: UTF-8 not working and xLanguage Problems
  • 2009/11/13 10:40

  • culex

  • Module Developer

  • Posts: 711

  • Since: 2004/9/23


yes i have a dk file set up like this but the pdf created still show utf-8 as ISO-8859-1

$l['a_meta_charset'] = "UTF-8";
$l['a_meta_dir'] = "ltr";
$l['a_meta_language'] = "dk";


I even tried changing 'dk' with 'da' to see if this gives any effect.

15
ghia
Re: News 1.63 - PDF Creation: UTF-8 not working and xLanguage Problems
  • 2009/11/13 11:27

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


For the da, dk question, you need a /modules/news/pdf/config/lang/MyLang.php, where MyLang is the _LANGCODE defined in global.php This is normally da, while DK is the country code.

The
return utf8_encode($chaine);
in function news_unhtml of /pdf/pdf.php should need a conditional and be skipped in the case the site is not in ISO character encoding. A simple
return $chaine;
will do there.
Furthermore, it may be needed that depending the character encoding used on the site, the pdf.php file itself, must be encoded in ansi or UTF-8 without BOM, by a suitable editor as eg Notepad++.




16
culex
Re: News 1.63 - PDF Creation: UTF-8 not working and xLanguage Problems
  • 2009/11/13 12:17

  • culex

  • Module Developer

  • Posts: 711

  • Since: 2004/9/23


Thanks Ghia, but no total success.

I did see a difference when correcting the function as above and I see now diffence when switching from ansi / utf-8 (without bom) but it still comes out wrong.

I checked the status of the pdf page created and I am beginning to think this is read in the reader as ANSi. Maybe the page generated is read as utf-8, converted as utf-8 and read by acrobat as ANSi ??

You can check my news athttp://www.culex.dk :)

17
ghia
Re: News 1.63 - PDF Creation: UTF-8 not working and xLanguage Problems
  • 2009/11/13 12:41

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


I did a pdf from story 1 in Danish and the body text was OK for the UTF-8 encoding.

The title was still a mess and the body contains all languages and the HTML tags visible.
I try to check later on these issues.


18
culex
Re: News 1.63 - PDF Creation: UTF-8 not working and xLanguage Problems
  • 2009/11/13 20:10

  • culex

  • Module Developer

  • Posts: 711

  • Since: 2004/9/23


I managed to get a little further using some tweaking of the code..But finished pdf still reveals languages in a mess as you described Ghia, however..

In pdf.php I changed line 243
from
$content news_unhtml($content);


to
$content $content;


line 250 - 255
from
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor(PDF_AUTHOR);
$pdf->SetTitle($doc_title);
$pdf->SetSubject($doc_title);
$pdf->SetKeywords($doc_keywords);


to this..
$pdf->SetCreator(news_unhtml(PDF_CREATOR));
$pdf->SetAuthor(news_unhtml($article->uname()));
$pdf->SetTitle(news_unhtml($doc_title));
$pdf->SetSubject(news_unhtml($doc_title));
$pdf->SetKeywords(news_unhtml($doc_keywords));


line 270 - 271
from
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN''PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA''PDF_FONT_SIZE_DATA));


to
$pdf->SetFont('FreeSans'''11);
$pdf->setHeaderFont(Array('FreeSans'''10));
$pdf->setFooterFont(Array('FreeSans'''10));


and now at least the danish letters get translated ok... I will continue to see if I can get the xlanguage working

19
ghia
Re: News 1.63 - PDF Creation: UTF-8 not working and xLanguage Problems
  • 2009/11/13 20:59

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


I checked again, but now I have nothing than what looks like all graphic characters in the content. There is nothing I can read. It was better before.

For the xLanguage filtering you need to do:
include_once(XOOPS_ROOT_PATH.'/modules/xlanguage/include/vars.php');
include_once(
XOOPS_ROOT_PATH.'/modules/xlanguage/include/functions.php');

// filter all items
$content := xlanguage_ml($content);

20
culex
Re: News 1.63 - PDF Creation: UTF-8 not working and xLanguage Problems
  • 2009/11/14 6:47

  • culex

  • Module Developer

  • Posts: 711

  • Since: 2004/9/23


Quote:

ghia wrote:
I checked again, but now I have nothing than what looks like all graphic characters in the content. There is nothing I can read. It was better before.

For the xLanguage filtering you need to do:
include_once(XOOPS_ROOT_PATH.'/modules/xlanguage/include/vars.php');
include_once(
XOOPS_ROOT_PATH.'/modules/xlanguage/include/functions.php');

// filter all items
$content := xlanguage_ml($content);


Very strange with this your last filter for xlanguage I get perfect output. I tried to empty all caches + browser cache but I still cant replicate the output you are getting. In my browser version I have the translated clean version I was looking fore ?

I added this

line 237-238
Inserted
include_once(XOOPS_ROOT_PATH.'/modules/xlanguage/include/vars.php');
include_once(
XOOPS_ROOT_PATH.'/modules/xlanguage/include/functions.php');


and line
from 245
$content $content;


to
$content xlanguage_ml($content);


and finaly line 259
from

$firstLine $article->title();


to

$firstLine xlanguage_ml($article->title());


any idea why we get different output ?

Login

Who's Online

165 user(s) are online (103 user(s) are browsing Support Forums)


Members: 0


Guests: 165


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits