Part of the EllisLab Network
   
 
*HELP* Intergrate TCPDF
Posted: 17 July 2007 05:09 PM   [ Ignore ]  
Summer Student
Total Posts:  5
Joined  01-02-2007

Hi Folks,

I’m trying to integrate TCPDF in codeigniter (following the same procedure as for FPDF).

Did anyone already managed to do it? It keeps complaining about fonts that cannot be found.


TCPDF

Profile
 
 
Posted: 17 July 2007 07:27 PM   [ Ignore ]   [ # 1 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3153
Joined  06-11-2007

Search the forums, I answered this question a few times I think.

 Signature 

————————
Blog | Twitter | GitHub | BitBucket
————————-
PyroCMS - open source modular CMS built with CodeIgniter
PancakeApp - Simple, hosted invoicing/w project management

Profile
 
 
Posted: 18 July 2007 12:58 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  5
Joined  01-02-2007

I did search the forums, tcpdf uses also a config file, i think the problem is there.
But i’m not experienced enough to be sure.

I placed tcpdf.php and the config dir the system/application/libraries

In my controller i use this:

function pdf3()
{
    $this
->load->library('tcpdf');
    
define('FPDF_FONTPATH',$this->config->item('fonts_path'));
    
$this->tcpdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN''PDF_FONT_SIZE_MAIN));
    
$this->tcpdf->setFooterFont(Array(PDF_FONT_NAME_DATA''PDF_FONT_SIZE_DATA));
    
$this->tcpdf->Open();
    
$this->tcpdf->AddPage();
    
$this->tcpdf->SetFont('Arial','B',14);
    
$this->tcpdf->SetY(30);
    
$this->tcpdf->Cell(40,10,'Hello World!<br>test');
    
$pdf->SetFont("helvetica""BI"20);
    
$pdf->Cell(0,10,'TEST Bold-Italic Cell',1,0,'C');
    
$this->tcpdf->Output('output.pdf','D');


Whatever i do it keeps complaining about:

A PHP Error was encountered

Severity
Warning

Message
TCPDF::include() [function.include]Failed opening 'C:/website/system/application/libraries/fonts/old/arial.php' for inclusion (include_path='.;C:\xampp\php\pear\')

Filenamelibraries/tcpdf.php

Line Number
1658
TCPDF error
Could not include font definition file 
Profile
 
 
Posted: 04 September 2007 08:15 AM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  5
Joined  01-02-2007

no one? Still having the same issue

Profile
 
 
Posted: 04 September 2007 08:24 AM   [ Ignore ]   [ # 4 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  4785
Joined  07-14-2006

i don’t know anything about tcpfd but the error shows there must be a problem with the font file or the path.

Can you define it in the config?

Profile
 
 
Posted: 01 October 2007 03:43 AM   [ Ignore ]   [ # 5 ]  
Summer Student
Total Posts:  2
Joined  09-11-2007

For one thing, if you look in the fonts folder, you’ll see arial.(php/ctg.z/z) does not exist. Try using a font that comes with the library.

Basically, to get it to work, you need to set up the tcpdf.php to point to the correct folder, if you choose to have all the components in a sub-folder like I do, and I’m assuming anyone else avoiding a headache would do.

I defined my fonts path in the config file, and I found that using the normal $pdf class straight up breaks. I haven’t messed with it enough to see what will unbreak it, and I’m no codeigniter pro here.

Anyway, here’s what I used, and it worked fine. I’ll be using tcpdf to output lots and lots of user reports from a web app I’m making now, I’ll update this with anything I find in the next few days of swearing and experimenting.

<?php

class Pdf extends Controller {
    
    
function Pdf()
    
{
        parent
::Controller();
    
}
    
    
function index()
    
{
        $this
->load->library('tcpdf');
        
$this->tcpdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN''PDF_FONT_SIZE_MAIN));
        
$this->tcpdf->setFooterFont(Array(PDF_FONT_NAME_DATA''PDF_FONT_SIZE_DATA));
        
$this->tcpdf->Open();
        
$this->tcpdf->AddPage();
        
$this->tcpdf->SetFont('Freeserif','B',14);
        
$this->tcpdf->SetY(30);
        
$this->tcpdf->Cell(40,10,'Hello World!<br>test');
        
$this->tcpdf->Output('output.pdf','I');
    
}
}

?> 


Oooooh, okay, so I peeked around in the library for a couple seconds, and it seems as though anything you need to be doing with $pdf (which as far as I remember, is the fdpf class), you can access with the aliased version through tcdpf. So for those lines I dropped out, do this:

$this->tcpdf->SetFont("vera""BI"20);
        
$this->tcpdf->Cell(0,10,'TEST Bold-Italic Cell',1,0,'C'); 

Now to make it pretty. smile

Profile
 
 
Posted: 08 April 2008 09:56 AM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  14
Joined  10-11-2007

Yes Im having trouble using tcpdf too.
Does someone know how to set it up?

Profile
 
 
Posted: 23 May 2008 04:25 PM   [ Ignore ]   [ # 7 ]  
Summer Student
Avatar
Total Posts:  7
Joined  05-23-2008

bjora857: Just put the tcpdf files in your libraries directory and change the two paths in the config file appropriately.

 Signature 

Sacramento, California - Ubuntu 8.04

Profile
 
 
Posted: 15 September 2008 10:54 AM   [ Ignore ]   [ # 8 ]  
Summer Student
Avatar
Total Posts:  23
Joined  08-28-2008

I know this is kind of late, but I hope this will help… just happen to have a need of html-to-pdf kind of viewing thingy. here’s how i did it ^_^

http://www.ikawka.com/2008/09/codeignitertcpdf-plugin/

 Signature 

http://www.ikawka.com/

Profile