EllisLab text mark
Advanced Search
     
How do i use Codeigniter or any existing library to generate pdf files using a blank pdf file
Posted: 25 September 2008 12:59 AM
Joined: 2008-09-24
3 posts

Hi all, i’m new to this framework.

I am working on a project which requires me to

Open up a pdf file (think of it as a template) with all the logos and boxes done up.
Then put text into the pdf file using php and finally save it as a new pdf file.

Anyone have done something similar to this?

i think the closest library that i found is FPDF_TPL.

How do i set up FPDF in codeigniter?

 
Posted: 25 September 2008 04:08 AM   [ # 1 ]   [ Rating: 0 ]
Joined: 2007-06-11
276 posts
natleumas - 25 September 2008 04:59 AM

Hi all, i’m new to this framework.

I am working on a project which requires me to

Open up a pdf file (think of it as a template) with all the logos and boxes done up.
Then put text into the pdf file using php and finally save it as a new pdf file.

Anyone have done something similar to this?

i think the closest library that i found is FPDF_TPL.

How do i set up FPDF in codeigniter?

Checkout this wiki article on the codeigniter wiki: http://codeigniter.com/wiki/fpdf_CIed/

 
Posted: 25 September 2008 04:25 AM   [ # 2 ]   [ Rating: 0 ]
Joined: 2008-09-24
3 posts

Thanks ray73864 for the link.

Any idea how should i setup the FPDF to work with codeigniter? or is it the other way, to setup codeigniter to work with FPDF?

i am confused ~.~.~.~.~.~.~.~

 
Posted: 25 September 2008 05:51 AM   [ # 3 ]   [ Rating: 0 ]
Joined: 2008-02-08
33 posts

Kinda goes something like this:

application
  libraries
    fpdf.php
    fpdf_tpl.php
    fpdi.php
    fpdi_pdf_parser.php
    pdf_context.php
    pdf_parser.php
    wrapper_functions.php


Controller

$this->load->library('fpdf');
define('FPDF_FONTPATH',$this->config->item('fonts_path'));
            
$this->load->library('fpdi');
            
// initiate FPDI   
$pdf =& new FPDI('P','mm','A4');
// add a page
$pdf->AddPage();
// set the sourcefile
$pdf->setSourceFile('resources/pdfs/your_pdf_template.pdf');
// import page 1
$tplIdx $pdf->importPage(1);
// use the imported page and place it at point 10,10 with a width of 100 mm
$pdf->useTemplate($tplIdx11210);
// now write some text above the imported page
$pdf->SetFont('Arial');
$pdf->SetTextColor(0,0,0);

// Write something
$pdf->SetXY(8831);
$pdf->Write(0"Hello world");

// Output
$pdf->Output('resources/pdfs/archives/'$pdf_name'F'); 


Don’t forget the fonts folder:
Add this to config.php

$config['fonts_path']"resources/font/"

Works great for me, hope this helps.

 Signature 
 
Posted: 25 September 2008 10:08 PM   [ # 4 ]   [ Rating: 0 ]
Joined: 2008-09-24
3 posts

Thanks for that Outrage. this is gold!

Appreciate it!

 
Posted: 09 April 2011 04:14 PM   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2010-05-17
12 posts

Hi, I installed the FPDF and FPDI libraries in CI2.

I get the following error when I try to load the library

Instruction:

$this->load->library('fpdf'); 
Fatal errorCall to a member function library() on a non-object
Message
Undefined propertypdf::$load 

I followed the instruction on the post above, a couple of files are missing: fpdf_tpl.php and wrapper_functions.php but I think it is due to the libraries version

Any comment would be appreciated

 Signature 

Paul Vicente Hernández Moreno

 
Posted: 09 April 2011 04:55 PM   [ # 6 ]   [ Rating: 0 ]
Joined: 2010-08-15
154 posts

FPDF has been superceded by TCPDF
http://codeigniter.com/wiki/Category:Contributions::Applications::TCPDF/

 
Posted: 09 April 2011 06:06 PM   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2010-05-17
12 posts

JonoB:

Thank you very much for your fast reply wink

That’s exactly what i need

 Signature 

Paul Vicente Hernández Moreno

 
Posted: 11 April 2011 04:38 AM   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2010-05-17
12 posts

Hi JonoB:

I’m still getting the same error when I tried to load the library:

Message: Undefined property: pdf::$load
Fatal error: Call to a member function library() on a non-object

I read the custom libraries naming conventions and the pdf.php library does not meet them. I changed the file name and capitalized the file name (Pdf.php), the same with the class declaration, but I’m still getting the same error.

Any idea?

Can you post the config file tcpdf.php

Thank and regards

 Signature 

Paul Vicente Hernández Moreno

 
Posted: 11 April 2011 05:37 AM   [ # 9 ]   [ Rating: 0 ]
Joined: 2010-08-15
154 posts

Not sure how you have set it up, but I got it working as follows: http://codeigniter.com/wiki/TCPDF_Integration/

 
Posted: 11 April 2011 05:47 AM   [ # 10 ]   [ Rating: 0 ]
Avatar
Joined: 2010-05-17
12 posts

I have fixed the load library problem and I had to bump up the memory limit in the php.ini file, now I’m having other problems:

- Message: Use of undefined constant K_CELL_HEIGHT_RATIO - assumed ‘K_CELL_HEIGHT_RATIO’

- Message: Cannot modify header information - headers already sent by (output started at /home/pauldj54/Desktop/pdftest/system/core/Exceptions.php:170)

I’ll check your link and others forum post. Thanks for your time!

 Signature 

Paul Vicente Hernández Moreno

 
Posted: 11 April 2011 09:22 AM   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-19
6707 posts

PHP ROS PDF

Download

InsiteFX

 Signature 

Certified State of CT Computer Programming Teacher.
Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

Skype: insitfx

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

Input -> Controller | Processing -> Model | Output -> View

 
Posted: 07 November 2013 11:59 PM   [ # 12 ]   [ Rating: 0 ]
Joined: 2013-11-07
1 posts
outrage - 25 September 2008 05:51 AM

Kinda goes something like this:

application
  libraries
    fpdf.php
    fpdf_tpl.php
    fpdi.php
    fpdi_pdf_parser.php
    pdf_context.php
    pdf_parser.php
    wrapper_functions.php


Controller

$this->load->library('fpdf');
define('FPDF_FONTPATH',$this->config->item('fonts_path'));
            
$this->load->library('fpdi');
            
// initiate FPDI   
$pdf =& new FPDI('P','mm','A4');
// add a page
$pdf->AddPage();
// set the sourcefile
$pdf->setSourceFile('resources/pdfs/your_pdf_template.pdf');
// import page 1
$tplIdx $pdf->importPage(1);
// use the imported page and place it at point 10,10 with a width of 100 mm
$pdf->useTemplate($tplIdx11210);
// now write some text above the imported page
$pdf->SetFont('Arial');
$pdf->SetTextColor(0,0,0);

// Write something
$pdf->SetXY(8831);
$pdf->Write(0"Hello world");

// Output
$pdf->Output('resources/pdfs/archives/'$pdf_name'F'); 


Don’t forget the fonts folder:
Add this to config.php

$config['fonts_path']"resources/font/"

Works great for me, hope this helps.


Outrage - Though your post was made many years ago, that was the key to me figuring out how to use CodeIgniter along with FPDF and FPDI. Thanks a bunch !! I am now able to customize PDF documents with CI and FPDI.

Thanks.