I'm trying to implement this pdf lib for my Laravel project: link . Since I'm having trouble with the implementation, because its documentation is not very clear with the method I need to use to create a PDF.
I'm trying to implement this pdf lib for my Laravel project: link . Since I'm having trouble with the implementation, because its documentation is not very clear with the method I need to use to create a PDF.
To implement, as you are using a framework, I would suggest installing through composer.
First, add the TCPDF dependency to composer.json
:
"require": {
// Aqui terá todas as dependencias do Laravel, coloque em baixo o tcpdf.
"tecnickcom/tcpdf": "^6.2.13"
}
Then run the command composer install
if there is the file composer.lock
, otherwise use composer update
.
To use TCPDF, it would look something like this:
<?php
// Acredito que não será necessário a etapa abaixo, mas faça o teste com ou sem.
require __DIR__ . '/vendor/autoload.php';
$pdf = new TCPDF();
$pdf->AddPage();
$pdf->Write(1, 'Hello world');
$pdf->Output('hello_world.pdf');
?>
Examples of how to use the library here .
I recommend you use DOMPdf, which is already widely accepted and used in the Laravel community.
In addition, it is easy to install and has great documentation.
Worth checking out: link