Welcome Guest, Not a member yet? Register   Sign In
How do i use Codeigniter or any existing library to generate pdf files using a blank pdf file
#1

[eluser]natleumas[/eluser]
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?
#2

[eluser]ray73864[/eluser]
[quote author="natleumas" date="1222333187"]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?[/quote]

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

[eluser]natleumas[/eluser]
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 ~.~.~.~.~.~.~.~
#4

[eluser]outrage[/eluser]
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
Code:
$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($tplIdx, 1, 1, 210);
// now write some text above the imported page
$pdf->SetFont('Arial');
$pdf->SetTextColor(0,0,0);

// Write something
$pdf->SetXY(88, 31);
$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

Code:
$config['fonts_path']= "resources/font/";

Works great for me, hope this helps.
#5

[eluser]natleumas[/eluser]
Thanks for that Outrage. this is gold!

Appreciate it!
#6

[eluser]Paul Hernández[/eluser]
Hi, I installed the FPDF and FPDI libraries in CI2.

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

Instruction:
Code:
$this->load->library('fpdf');

Code:
Fatal error: Call to a member function library() on a non-object
Message: Undefined property: pdf::$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
#7

[eluser]JonoB[/eluser]
FPDF has been superceded by TCPDF
http://codeigniter.com/wiki/Category:Con...ns::TCPDF/
#8

[eluser]Paul Hernández[/eluser]
JonoB:

Thank you very much for your fast reply ;-)

That's exactly what i need
#9

[eluser]Paul Hernández[/eluser]
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
#10

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




Theme © iAndrew 2016 - Forum software by © MyBB