Yii Framework Forum: Yii Pdf Style - Yii Framework Forum

Jump to content

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

Yii Pdf Style Rate Topic: -----

#1 User is offline   darsa 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 28-January 13

Posted 24 June 2013 - 05:20 AM

Pdf generation extension in yii not support style sheet? I want to generate a pdf doc with a template design. How can i access style sheet for that template in yii?? I am using mpdf extension. please help me

I include the file name as
<link rel="stylesheet" type="text/css" href="<?php// echo Yii::app()->request->baseUrl; ?>/css/style.css" media="screen, projection" /> in pdf generated page but its not working so am included a line of code in its controller like:
$stylesheet = file_get_contents(Yii::getPathOfAlias('webroot.css') . '/style.css');
$mPDF1->WriteHTML($stylesheet, 1);

but pdf generate without any style... Can anyone help me??

or how can i pass style sheet as a parameter in controller
0

#2 User is offline   mbala 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 174
  • Joined: 21-July 12
  • Location:Chennai, Tamilnadu, India

Posted 24 June 2013 - 05:56 AM

design the html file and convert into pdf. include your css in viewfile
html2pdf
0

#3 User is offline   darsa 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 28-January 13

Posted 24 June 2013 - 06:30 AM

View Postmbala, on 24 June 2013 - 05:56 AM, said:

design the html file and convert into pdf. include your css in viewfile
html2pdf



I included the css file in css folder... You mean i need to include the file in protected/views/myview
0

#4 User is offline   mbala 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 174
  • Joined: 21-July 12
  • Location:Chennai, Tamilnadu, India

Posted 24 June 2013 - 08:03 AM

using html2pdf file, i got the pdf files.
I work out only for single page so i added the css style in same view file. I used internal styles instead of external style sheet.
0

#5 User is offline   outrage 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 313
  • Joined: 10-November 09
  • Location:Blackpool, United Kingdom

Posted 24 June 2013 - 08:38 PM

I've had problems with PDF generation in the past.

It was always a path issue which I fixed by using something like this:

<img src="<?php echo Yii::getPathOfAlias('webroot'); ?>/images/CompanyProfilesImage.jpg" alt="" />


Instead of this:

<img src="<?php echo Yii::app()->baseUrl; ?>/images/CompanyProfilesImage.jpg" alt="" />


Same for your css.

Give it a go.
0

#6 User is offline   mbala 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 174
  • Joined: 21-July 12
  • Location:Chennai, Tamilnadu, India

Posted 25 June 2013 - 06:45 AM

I tried to apply style for pdf using stylesheet. But pdf not affected. So i included styles in view page. See demo
html2pdf demo
0

#7 User is offline   yogi123 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 18-July 14

Posted 18 July 2014 - 07:21 AM

I have problem in generation of Yii pdf, I done all the process but it shows this error...

Error 500

Alias "ext.yii-pdf.EYiiPdf" is invalid. Make sure it points to an existing PHP file and the file is readable.

Can You Help me?
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