Welcome Guest, Not a member yet? Register   Sign In
*HELP* Intergrate TCPDF
#1

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

[eluser]Phil Sturgeon[/eluser]
Search the forums, I answered this question a few times I think.
#3

[eluser]jjbakker[/eluser]
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:

Code:
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:

Code:
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\')

Filename: libraries/tcpdf.php

Line Number: 1658
TCPDF error: Could not include font definition file
#4

[eluser]jjbakker[/eluser]
no one? Still having the same issue
#5

[eluser]xwero[/eluser]
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?
#6

[eluser]Jonathan Gordon[/eluser]
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.

Code:
&lt;?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');
    }
}

?&gt;


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:

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

Now to make it pretty. Smile
#7

[eluser]bjora857[/eluser]
Yes Im having trouble using tcpdf too.
Does someone know how to set it up?
#8

[eluser]yekibud[/eluser]
bjora857: Just put the tcpdf files in your libraries directory and change the two paths in the config file appropriately.
#9

[eluser]pixelazion[/eluser]
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/




Theme © iAndrew 2016 - Forum software by © MyBB