KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Export report problem #624

Closed Ant Klad opened this topic on on Jan 28, 2019 - 9 comments

Ant Klad commented on Jan 28, 2019

I'm trying to export a report to PDF that uses the windows-1253 encoding. My report shows perfectly on screen but when I export to PDF I get all the Greek windows-1253 chars converted to ? in black rhombus. I have used ini_set('default_charset', 'windows-1253'); in my index.php and also I have tried putting the encoding in the report.view.php, as suggested in phantomjs site like :

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=windows-1253">
  </head>
  <style>
  body { font-family: Arial, calibri; }
</style>
<div class="report-content">
<div>
<?php $this->subReport("InvoiceItems"); ?>
</div>
<div>
<strong>Ανάλυση ΦΠΑ κατά κατηγορία</strong>
<?php $this->subReport("InvoiceVATAnalysis"); ?>
</div>
<div>
<?php $this->subReport("InvoiceSums"); ?>
</div>
</html>

but the result is always the same!

KoolReport commented on Jan 28, 2019

Could you please try the our cloudexport to see how, please follow the instruction here:

https://www.koolreport.com/forum/topics/614

Ant Klad commented on Jan 28, 2019

This would not be helpful to me since the machine that produces the reports does not have internet connection. They are on an intranet.

KoolReport commented on Jan 28, 2019

I see, I send your case to dev.team so that would find out what happens. I will come back to you.

Ant Klad commented on Jan 28, 2019

If there is a way to use somewhere between the report production and the export a line that converts the report to UTF-8 it would solve the problem, for example:

$MainRep->run()
		->export('MainRep')->     *****iconv ("CP1253","UTF-8", $content)****
		->pdf(array(
			"format"=>"A4",
			"orientation"=>"portrait",
		))
		->toBrowser("INVOICE.pdf");
KoolReport commented on Jan 28, 2019

You may open the file "koolreport/packages/export/Handler.php", look for this line:

$content = $this->report->render($this->view,true);

in the line 88.

$content variable contains the content of report render, you can do conversion after this line.

KoolReport commented on Jan 28, 2019

Second solution is that you can do conversion inside your report for any text in CP1253

Ant Klad commented on Jan 28, 2019

I prefer the handler solution since the data of the report comes from a database with CP1253 encoding. It would be difficult I believe to do conversions everywhere I read from the DB.

Ant Klad commented on Jan 29, 2019

I made a modification to pdf function in and added a parameter to the array: $ReportEncoding = Utility::get($params, 'ReportEncoding', null); Also I changed saveTempContent to : protected function saveTempContent($RepCharacterEncoding=null, $path = null, $ext = "tmp") and added at line 89 : if($RepCharacterEncoding!=null) {

    // Convert from Report Encoding to UTF-8	
$content = iconv ($RepCharacterEncoding, "UTF-8", $content);					

}

And also 195: $tmpHtmlFile = $this->saveTempContent($ReportEncoding, null, "html");

220 : $tmpHtmlFile = $this->saveTempContent($ReportEncoding, "", "html");

236: $source = $this->saveTempContent($ReportEncoding);

Now it is exporting fine to PDF.

I would like to mention here that additionaly I found another solution. I used DomPDF with ob_start(); $content = ob_get_contents(); ob_end_clean(); and then used $content with DomPDF. That worked very well also but it is not as easy as your solution to use with all reports.

KoolReport commented on Jan 29, 2019

That's great to hear that you make it work.

DomPDF is good however it does not support javascript embedded so if your report containing charts or graphs, it will not shown.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

Export