EllisLab text mark
Advanced Search
1 of 5
1
   
CodeIgniter Community Voice - Generating PDF files using CodeIgniter
Posted: 31 July 2008 02:33 PM   [ Ignore ]
Avatar
Joined: 2006-03-23
3194 posts

This week, our Community Voice author is Chris Monnat, known on the forums as mrtopher, who writes a helpful step by step guide to generating PDF files from CodeIgniter.  Chris is a full time web application developer and part time entrepreneur. In addition to building web sites for the medical industry during the day, at night Chris also runs his own development company Left of Center Communications. He recently started a personal blog at http://www.chrismonnat.com where he keeps a record of his exploits and discusses, among other things, CodeIgniter.

Read the full article

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design

 
Posted: 31 July 2008 08:14 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2007-04-03
118 posts

Just curious if the author knew about www.tcpdf.org (TCPDF).  Seems like it does a lot more (an easier) than the cited library of choice.

 
Posted: 01 August 2008 04:40 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2006-10-02
332 posts

dompdf is reduced to “dom” in the article and thus generates a 404.

 Signature 

Dotted line.

 
Posted: 01 August 2008 07:26 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-23
3194 posts
Crimp - 01 August 2008 08:40 AM

dompdf is reduced to “dom” in the article and thus generates a 404.

Got that fixed up now Crimp.  Thanks!

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design

 
Posted: 01 August 2008 09:15 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2006-06-03
58 posts
a&w; - 01 August 2008 12:14 AM

Just curious if the author knew about www.tcpdf.org (TCPDF).  Seems like it does a lot more (an easier) than the cited library of choice.

No, I wasn’t aware of this library but it looks interesting. I will have to check it out.

 Signature 

The blog: ChrisMonnat.com

 
Posted: 01 August 2008 09:42 AM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Joined: 2007-04-03
118 posts

One more thought just FYI, the author and forum for TCPDF is very active still.  There are updates, enhancements, fixes on a frequent basis (sometimes a couple times a week).  Other libraries like FPDF and the one you cited haven’t had activity in years (as far as I could tell at a glance).

 
Posted: 01 August 2008 12:39 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Joined: 2006-06-03
58 posts

a&w;, your right. The development for the R&OS;library has stalled. As I said in the article, there are plenty of options out there for PDF libraries. I just chose to highlight the one that I use.

 Signature 

The blog: ChrisMonnat.com

 
Posted: 04 August 2008 08:50 AM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2006-12-10
35 posts

Hey guys !

Thanks for this very interesting article ! In fact, it came out just at the moment I needed it !

I’m experiencing some problems with this library with CI. Even with the most basic “Hello World!” code, the library returns an error (notice in fact) :

A PHP Error was encountered
Severity
Notice
Message
Undefined index
Filenamelibraries/class.pdf.php
Line Number
1934 

Then, with the same error on these lines

Line Number2421
Line Number
1631 

Then,

A PHP Error was encountere
Severity
Warning
Message
Cannot modify header information headers already sent by (output started at /opt/lampp/htdocs/acbulle/system/libraries/Exceptions.php:164)
Filenamelibraries/class.pdf.php
Line Number
1916 

And the same error on line 1917 and 1919

The PHP code is pretty basic :

$this->load->library('cezpdf');
$this->cezpdf->ezText('Hello World'12, array('justification' => 'center'));
$this->cezpdf->ezStream(); 

The files are in the correct directories, the font directory is readable and writable…

What’s wrong?
(I’m using CI 1.6.3)
Thanks !

PS: don’t know if it’s the right place to post, sorry if not.

 Signature 

: ) metalking

 
Posted: 04 August 2008 11:47 AM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Joined: 2007-04-03
118 posts

metalking:

php is saying some variables haven’t been declared while the error_reporting is set to alert you of warnings.  You have two options: change the error_reporting in index.php to a lower level so it doesn’t display the warnings or go into the problem files and make sure the variables in question are declared properly.

The other errors will go away once you fix that, it’s just complaining that headers were already sent (ehco’ing the error message causes this error).

 
Posted: 05 August 2008 06:17 AM   [ Ignore ]   [ # 9 ]   [ Rating: 0 ]
Avatar
Joined: 2006-12-10
35 posts

Thanks a&w;!

In fact, I don’t know how to fix the missing variables because it is actually a library I downloaded. I doubt there is a problem with the library ‘cause many people use it without any problem.
I’ll try to lower the error_reporting level, but when another solution is possible, I’d prefer it, cause I need those reports for the development.

Thanks!

EDIT : Lol, the problem was this : I placed the “font” directory in a “static” subdirectory. I just moved it and now it works !
Thanks wink

 Signature 

: ) metalking

 
Posted: 18 August 2008 03:13 AM   [ Ignore ]   [ # 10 ]   [ Rating: 0 ]
Avatar
Joined: 2008-06-14
56 posts

Hi, I haven’t checked out the lib yet, but from the examples that you gave in the article, it looks like we have to insert every piece of text into the PDF by ourself, from headers, spacing, tables… which can be very tedious, especially for dynamic contents.

So, can I ask does this pdf lib give us the option to convert the whole page on the fly into a pdf file? I know a pdf lib for PHP that can do this, but cant remember the name right now. What it can do is: I include a button, say, ‘print’ on the page, and when user clicks it, it will automatically convert the whole page into PDF document and download it to the browser. It will use the normal css or print CSS if we have one. It works just as you have the adobe PDF print driver installed on your computer (well, not that good, but close). Can we do that with this library?

Thanks.
Khoa

 
Posted: 25 August 2008 10:36 AM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Joined: 2006-06-03
58 posts

Khoa, nope… this library can’t handle something like that. The R&OS;library is for those programmers who like to have access to ALL settings and such. I do know there are libraries that do what your referring to and I’ve even tried one or two. My issue with the ones I tries were they didn’t handle text formatting (bold, italics, etc.) very well. Plus, R&OS;handles tables very well where other libraries take more work.

It all boils down to personal preference.

 Signature 

The blog: ChrisMonnat.com

 
Posted: 01 September 2008 11:39 AM   [ Ignore ]   [ # 12 ]   [ Rating: 0 ]
Avatar
Joined: 2007-07-18
10 posts

Thanks for this intresting article, I’m nearly new to CI and before I used FPDF library who can use an existing PDF file to write on.
I have read (very fast) the R&OS;documentation and I haven’t found any function who can permit the same thing…

So (my english is poor) I don’t understand the doc or the feature is not prĂ©sent ?

Thank by advance.

 
Posted: 01 September 2008 06:55 PM   [ Ignore ]   [ # 13 ]   [ Rating: 0 ]
Joined: 2006-06-03
58 posts

If I understand you correctly, you are looking for a library that can use an existing PDF file to create a report. Is that correct?

If this is your question the answer is no. The R&OS;class does not provide this kind of functionality.

 Signature 

The blog: ChrisMonnat.com

 
Posted: 01 September 2008 08:07 PM   [ Ignore ]   [ # 14 ]   [ Rating: 0 ]
Avatar
Joined: 2007-07-18
10 posts

In fact I have a PDF document who have allready logo and text refinements and I put some informations on this document to generate a new document form DB and user input.
This is my syntax with FPDF :

$pdf = new fpdi();
$pagegab $pdf->setSourceFile("gabarit_per2.pdf");
$pagetpl $pdf->ImportPage(1);
$pdf->addPage();
$pdf->useTemplate($pagetpl,0,0,0);
// remplissage du pdf
$pdf->SetFont('Helvetica','',8);
$pdf->SetXY(85,51);
$pdf->Cell(80,8,utf8_decode("Saisie le ".date("d/m/Y")));
$pdf->SetFont('Helvetica','B',11);
$pdf->SetXY(120,47);
$pdf->Cell(50,8,$nabo);
$pdf->SetFillColor(0,0,0);
if (
$_POST['pervac']!=""){$pdf->Rect(26.5,71.5,3,3,'F');}
if ($_POST['perval']!=""){$pdf->Rect(77.5,71.5,3,3,'F');}
if ($_POST['peroedi']!=""){$pdf->Rect(129,71.5,3,3,'F');}
...
// generation du pdf
$fichier "bulletins/".$nabo.".pdf";
$pdf->Output($fichier,"F");
$pdf->closeParsers(); 

After reading carfully the doc of R&OS;he seems no capable to do that. :(

So, I continue to use FPDF, thanks anyway wink

 
Posted: 14 September 2008 09:07 PM   [ Ignore ]   [ # 15 ]   [ Rating: 0 ]
Joined: 2008-05-28
1 posts

Hi, thanx for this great article.

I’m just wondering if anyone knows if it is possible to have utf-8 support in R&OS;?

I tried to figure it out, but it still doesn’t work for me :(

 
1 of 5
1