Yii Framework Forum: Yii-PDF shows blank page on linux - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii-PDF shows blank page on linux

#1 User is offline   Felipe_Moreira 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 73
  • Joined: 01-December 11

Posted 22 April 2012 - 09:49 PM

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!
0

#2 User is offline   rodzadra 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 09-May 09

Posted 24 April 2012 - 03:35 AM

View PostFelipe_Moreira, on 22 April 2012 - 09:49 PM, said:

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
0

#3 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,180
  • Joined: 05-January 12
  • Location:Morocco

Posted 24 April 2012 - 05:23 AM

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);

0

#4 User is offline   Felipe_Moreira 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 73
  • Joined: 01-December 11

Posted 24 April 2012 - 06:16 AM

View Postrodza, on 24 April 2012 - 03:35 AM, said:

Hi Felipe,

Did you try in Google Chrome? (sometimes the Firefox (with Acroread plugin) shows a blank page on PDF files).

[]'s


Hi rodza. Thank you for your reply!

All browsers the same thing, but the problem is certainly not that it worked perfectly locally.
0

#5 User is offline   rodzadra 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 09-May 09

Posted 24 April 2012 - 06:36 AM

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. :)   
            $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();
        }

0

#6 User is offline   Felipe_Moreira 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 73
  • Joined: 01-December 11

Posted 24 April 2012 - 06:47 AM

View Postbennouna, on 24 April 2012 - 05:23 AM, said:

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.
0

#7 User is offline   Felipe_Moreira 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 73
  • Joined: 01-December 11

Posted 24 April 2012 - 06:52 AM

View Postrodza, on 24 April 2012 - 06:36 AM, said:

Well, have you ever tried to create a simple "hello world"

Quote

If you are using the "WriteHTML" method, you have to make sure the HTML is valid
.
Certainly this is not because the application stops working in the call this instruction mPDF1 $ = Yii :: app () -> EPDF-> mpdf (); well before the function WriteHTML

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. :)   
            $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();
        }


0

#8 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,180
  • Joined: 05-January 12
  • Location:Morocco

Posted 24 April 2012 - 07:37 AM

Quote

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.


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.yiiframew...sion/pdf/#c6934
0

#9 User is offline   Felipe_Moreira 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 73
  • Joined: 01-December 11

Posted 24 April 2012 - 08:39 AM

View Postbennouna, on 24 April 2012 - 07:37 AM, said:

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.yiiframew...sion/pdf/#c6934

THANK YOU SO MUCH AGAIN FELLA! :D

I made adjustments to work on versions below 5.3 and it worked beautifully!
0

#10 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,180
  • Joined: 05-January 12
  • Location:Morocco

Posted 24 April 2012 - 08:51 AM

De nada, um prazer :lol:

In fact, I didn't read carefull your first post:

Quote

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)

0

#11 User is offline   Felipe_Moreira 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 73
  • Joined: 01-December 11

Posted 24 April 2012 - 08:58 AM

View Postbennouna, on 24 April 2012 - 08:51 AM, said:

De nada, um prazer :lol:

In fact, I didn't read carefull your first post:


Achei que você fosse gringo pow! (Location: Morocco).

Valeu mesmo cara, tudo de bom.
0

#12 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,180
  • Joined: 05-January 12
  • Location:Morocco

Posted 24 April 2012 - 09:15 AM

Sim, eu sou de Marrocos, mas eu falo um pouco o Português
0

#13 User is offline   Ely Sch 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 27-January 15

Posted 27 January 2015 - 03:36 PM

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
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users