nareboy
(Felipe Moreira)
April 23, 2012, 2:49am
1
Hi guys.
The generation of the pdf using the extension yii was working perfectly on my local machine (Windows 7, php version 5.3.10), but when I moved the application to the server (Linux 5.2.6-1 + lenny16) presents a blank screen after running this line:
$ mPDF1 = Yii :: app () -> EPDF-> mpdf ();
Even enabling all php errors, does not show any error. Someone tell me what might be happening?
Thank you!
rodza
(Rodzadra)
April 24, 2012, 8:35am
2
Hi guys.
The generation of the pdf using the extension yii was working perfectly on my local machine (Windows 7, php version 5.3.10), but when I moved the application to the server (Linux 5.2.6-1 + lenny16) presents a blank screen after running this line:
$ mPDF1 = Yii :: app () -> EPDF-> mpdf ();
Even enabling all php errors, does not show any error. Someone tell me what might be happening?
Thank you!
Hi Felipe,
Did you try in Google Chrome? (sometimes the Firefox (with Acroread plugin) shows a blank page on PDF files).
[]'s
abennouna
(Abennouna)
April 24, 2012, 10:23am
3
Personally here’s what I have that is working in Mac OS X and shared-hosting Linux:
config/main.php:
'ePdf' => array(
'class' => 'ext.yii-pdf.EYiiPdf',
'params' => array(
'mpdf' => array(
'librarySourcePath' => 'application.vendors.mpdf.*',
'constants' => array(
'_MPDF_TEMP_PATH' => Yii::getPathOfAlias('application.runtime'),
),
'class'=>'mpdf',
),
),
),
Controller (e.g.):
$PDF = Yii::app()->ePdf->mpdf('', 'A4', 8, '', 10, 10, 10, 10, 5, 5);
nareboy
(Felipe Moreira)
April 24, 2012, 11:16am
4
Hi rodza. Thank you for your reply!
All browsers the same thing, but the problem is certainly not that it worked perfectly locally.
rodza
(Rodzadra)
April 24, 2012, 11:36am
5
Well, have you ever tried to create a simple "hello world"
If you are using the "WriteHTML" method, you have to make sure the HTML is valid.
In any case, here are the settings that work in one of my projects:
In my config/main.php:
'ePdf' => array(
'class' => 'ext.yii-pdf.EYiiPdf',
'params'=> array(
'mpdf' => array('librarySourcePath' => 'application.vendors.mpdf.*',
'constants' => array(
'_MPDF_TEMP_PATH' => Yii::getPathOfAlias('application.runtime'),
),
'class'=>'mpdf', // the literal class filename to be loaded from the vendors folder
'format' => 'A4',
'default_font_size' => 1,
),
),
),
In my controller:
public function actionPrintAllPDF()
{
ini_set('max_execution_time',360);
ini_set('memory_limit', '128M');
$mPDF1 = Yii::app()->ePdf->mpdf('','A4');
$mPDF1->SetHTMLHeader('<h3 style="text-align: center;">'.mb_strtoupper(str_replace('Administração','',Yii::app()->name),'UTF-8').'</h3>');
// como temos poucos registros aqui, usamos findAll() sem problemas de ficarmos sem memória. <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/smile.gif' class='bbc_emoticon' alt=':)' />
$records = DiamPapers::model()->findAll();
$html = '';
//carrega a folha de estilo
$stylesheet = file_get_contents(Yii::getPathOfAlias('webroot.css') . '/bootstrap_print.css');
$mPDF1->WriteHTML($stylesheet, 1);
foreach($records as $record){
$html .= $this->renderPartial('//diamPapers/print', array('model'=>$record),true);
}
$mPDF1->WriteHTML($html, false);
# Envia o PDF
$mPDF1->Output();
}
nareboy
(Felipe Moreira)
April 24, 2012, 11:47am
6
Personally here’s what I have that is working in Mac OS X and shared-hosting Linux:
config/main.php:
'ePdf' => array(
'class' => 'ext.yii-pdf.EYiiPdf',
'params' => array(
'mpdf' => array(
'librarySourcePath' => 'application.vendors.mpdf.*',
'constants' => array(
'_MPDF_TEMP_PATH' => Yii::getPathOfAlias('application.runtime'),
),
'class'=>'mpdf',
),
),
),
Controller (e.g.):
$PDF = Yii::app()->ePdf->mpdf('', 'A4', 8, '', 10, 10, 10, 10, 5, 5);
Same thing
Does the problem is not the version of php I’m running on the server? I do not know if this component has some limitation in this regard.
abennouna
(Abennouna)
April 24, 2012, 12:37pm
8
The extension needs PHP 5.3. For anterior versions, see the comment. I’ve done it on one 5.2 shared host and it works:
http://www.yiiframework.com/extension/pdf/#c6934
nareboy
(Felipe Moreira)
April 24, 2012, 1:39pm
9
THANK YOU SO MUCH AGAIN FELLA!
I made adjustments to work on versions below 5.3 and it worked beautifully!
abennouna
(Abennouna)
April 24, 2012, 1:51pm
10
De nada, um prazer
In fact, I didn’t read carefull your first post:
nareboy
(Felipe Moreira)
April 24, 2012, 1:58pm
11
Achei que você fosse gringo pow! (Location: Morocco).
Valeu mesmo cara, tudo de bom.
abennouna
(Abennouna)
April 24, 2012, 2:15pm
12
Sim, eu sou de Marrocos, mas eu falo um pouco o Português
elysch
(Ely Yiiframework 1)
January 27, 2015, 8:36pm
13
Hello.
I’m having the same problem: I have PHP 5.2 and it shows empty PDFs.
Tried to find the correction’s mentioned, but couldn’t find them anywhere.
What should I change if I’m using yii-pdf-0.3.2.zip?
Thanks