Code Monkey home page Code Monkey logo

tcpdf-laravel's Introduction

Laravel 6-7-8-9-10-11 TCPDF

Latest Stable Version Total Downloads Latest Unstable Version License

A simple Laravel service provider with some basic configuration for including the TCPDF library

TCPDF is not really supported in PHP 7 but there's a plan for supporting it, check this out.

Installation

The Laravel TCPDF service provider can be installed via composer by requiring the elibyy/tcpdf-laravel package in your project's composer.json. (The installation may take a while, because the package requires TCPDF. Sadly its .git folder is very heavy)

composer require elibyy/tcpdf-laravel

or

Laravel 5.5+ will use the auto-discovery function.

{
    "require": {
        "elibyy/tcpdf-laravel": "^9.0"
    }
}

If you don't use auto-discovery you will need to include the service provider / facade in config/app.php.

'providers' => [
    //...
    Elibyy\TCPDF\ServiceProvider::class,
]

//...

'aliases' => [
    //...
    'PDF' => Elibyy\TCPDF\Facades\TCPDF::class
]

(Please note: TCPDF cannot be used as an alias)

for lumen you should add the following lines:

$app->register(Elibyy\TCPDF\ServiceProvider::class);
class_alias(Elibyy\TCPDF\Facades\TCPDF::class, 'PDF');

That's it! You're good to go.

Here is a little example:

use PDF; // at the top of the file

  PDF::SetTitle('Hello World');
  PDF::AddPage();
  PDF::Write(0, 'Hello World');
  PDF::Output('hello_world.pdf');

another example for generating multiple PDF's

use PDF; // at the top of the file

  for ($i = 0; $i < 5; $i++) {
    PDF::SetTitle('Hello World'.$i);
    PDF::AddPage();
    PDF::Write(0, 'Hello World'.$i);
    PDF::Output(public_path('hello_world' . $i . '.pdf'), 'F');
    PDF::reset();
  }

For a list of all available function take a look at the TCPDF Documentation

Configuration

Laravel-TCPDF comes with some basic configuration. If you want to override the defaults, you can publish the config, like so:

php artisan vendor:publish --provider="Elibyy\TCPDF\ServiceProvider"

Now access config/tcpdf.php to customize.

  • use_original_header is to used the original Header() from TCPDF.
    • Please note that PDF::setHeaderCallback(function($pdf){}) overrides this settings.
  • use_original_footer is to used the original Footer() from TCPDF.
    • Please note that PDF::setFooterCallback(function($pdf){}) overrides this settings.
  • use_fpdi is so that our internal helper will extend TcpdfFpdi instead of TCPDF.
    • Please note fpdi is not a dependency in my project so you will have to follow their install instructions here

Header/Footer helpers

I've got a pull-request asking for this so I've added the feature

now you can use PDF::setHeaderCallback(function($pdf){}) or PDF::setFooterCallback(function($pdf){})

tcpdf-laravel's People

Contributors

acirinelli avatar ahmeti avatar elibyy avatar fredmarmillod avatar gabrielmoura avatar honginho avatar it-can avatar laravel-shift avatar luukverhoeven avatar marufmax avatar sebaiturravaldes avatar stelianandrei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tcpdf-laravel's Issues

setHeaderCallback() images missing & header margin

This used to work perfectly until I updated to 5.7. Now the image is missing and my margins are not working. The cell is at the top of the page rather than pushed down by the header margin. Any ideas?

config/tcpdf: 'margin_header' => '0.45'

$pdf = new PDF();
$pdf::SetMargins(0.5, 1.3, 0.5);

return $pdf::setHeaderCallback(function($pdf) use ($title, $subtitle)
{
    $pdf->Image(\URL::asset('css/img/logos/pdf_header.png'), '', 0.5, '', 0.5, '', '', 'T', false, 300, '', false, false, 0, false, false, false);
    $pdf->SetFont('helvetica', 'B', 14);
    $pdf->Cell(0, 0, $title, 0, false, 'R', false, '', 0, false, 'T', 'M');
    $pdf->Ln();
    $pdf->SetFont('helvetica', 'R', 12);
    $pdf->Cell(0, 0.22, $subtitle, 0, false, 'R', false, '', 0, false, 'T', 'B');
});

Config not loading

It seems the config is not loading in 5.2, when I add the tcpdf.php file to my confg dir...

Images in the pdf results have some kind of transparency, instead of rendering fully opaque

Hello! Thanks for your work on this package.

I have an issue where the images seem to have some transparency instead of rendering full color,

Please see page 2 of this pdf,
http://customizer.prolook.com/design_sheets/A6D6B362-32E6-5154-93EB-59FC24258811.pdf

Also theres a small thumbnail of a mascot on page 5, the appear to have some king of transparency setting.

The full color of the image which is also the same as the source image being used by the pdf is at
https://s3-us-west-2.amazonaws.com/uniformbuilder/uploads/staging/884ab11e1d16911d3d41aae1334ca4b9.png

Thanks! Any help would be really appreciated.

Arthur

Undefined offset: 0 while setting digital signature

in tcpdf.php (line 9925)

at HandleExceptions->handleError(8, 'Undefined offset: 0', 'C:\laragon\www\docesign\vendor\tecnickcom\tcpdf\tcpdf.php', 9925, array('esa' => array('objid' => 6, 'page' => 0, 'name' => 'Signature', 'rect' => '510.236220 572.598661 552.755906 615.118346'), 'key' => 0, 'out' => '6 0 obj<< /Type /Annot /Subtype /Widget /Rect [510.236220 572.598661 552.755906 615.118346]'))

in tcpdf.php (line 9925)

at TCPDF->_enddoc()

in tcpdf.php (line 2982)

at TCPDF->Close()

in tcpdf.php (line 7552)

[question] FPDI ?

could you integrate Fpdi with your package for manipulation with exists PDF as a template ?

startPageGroup doesn't work

Please i need to restart the page number in the pdf but the startPageGroup doesn't work.
Can you help me?

Output($tmp_file, 'F') using Job dispatched to queue.

Hello,

I need to have a job dispatched to queue in order to generate a big pdf. First time when the job is dispatched I have this error:
TCPDF ERROR: Empty font family

After the retries mechanism starts it works.

Regards,
Radu

PDF Output function: Special character in file name not generated

Wanted to output filename like below.

Expected File name needs to be created: Mindre_TS_jobber_Ø.F.pdf

Current file name created: Mindre_TS_jobber_├ÿ.F.pdf

I'm using below code to generate pdf file.

$pdf = new PDF($orientation = 'P', $unit = 'in', $format = 'A4', $unicode = false, $encoding = 'UTF-8', $diskcache = false, $pdfa = false);

$pdf::SetPrintHeader(false);
$pdf::SetPrintFooter(false);
$pdf::AddPage();

$viewData = view($this->view, $this->data)->render();
$pdf::writeHTML($viewData);

$filename = storage_path($this->storagePathInternal) . $this->fileName;
$pdf::output($filename, 'F');
$pdf::reset();

Would you guys please help me getting this resolved?

Thanks,

How to edit existing pdf file

hi,
I trying upload pdf file (already signature) and i want add more signature into pdf file, but when i add new signature then old signature will lost.
so if you have any idea or example please tell me.
many thanks!

TCPDF Custom Font

Hi,
please help me how to add a custom font in TCPFD Laravel

thanks.

Error

Hi when creating a PDF (in a queue job), I get this error sometimes:

Undefined property: Elibyy\TCPDF\TCPDFHelper::$font_subsetting

Happens when setting a font like this

PDF::SetFont('helvetica', '', 11);

Move fonts folder to app directroy

Hi ,

I'm trying to move fonts directory to app folder because I have some custome fonts

I change config file and change font directory but still have error

this is my config file

<?php
return [
    'font_directory'        => app_path('fonts'),
    'image_directory'       => '',
];
?>

the fonts folder located in app folder /home/myuser/myproject/app/fonts
and the error is

TCPDF ERROR: Could not include font definition file: helvetica
so , I need your help to solve this problem

Store PDF file on Amazon S3

I am using TCPDF to convert a view into a PDF, then I want to store the PDF to an S3 bucket. I can't figure out to do this properly.

Below is the snippet of code I have been trying. The problem is how do I get the contents of the file to include in the $contents variable?

If I replace $contents with a string it pushes it to my s3 bucket but the file is corrupt and I assume that's because it's not sending the file contents.

PDF::output(Storage::disk('s3')->put($user->contractDir() . '/contract.pdf', $contents, 'public'), 'F');

conflicts with laravel/framework v5.5.*

This package conflicts with laravel version 5.5

  Problem 1
    - Conclusion: remove laravel/framework v5.5.40
    - Conclusion: don't install laravel/framework v5.5.40
    - Conclusion: don't install laravel/framework v5.5.39
    - Conclusion: don't install laravel/framework v5.5.38
    - Conclusion: don't install laravel/framework v5.5.37
    - Conclusion: don't install laravel/framework v5.5.36
    - Conclusion: don't install laravel/framework v5.5.35
    - Conclusion: don't install laravel/framework v5.5.34
    - Conclusion: don't install laravel/framework v5.5.33
    - Conclusion: don't install laravel/framework v5.5.32
    - Conclusion: don't install laravel/framework v5.5.31
    - Conclusion: don't install laravel/framework v5.5.30
    - Conclusion: don't install laravel/framework v5.5.29
    - Conclusion: don't install laravel/framework v5.5.28
    - Conclusion: don't install laravel/framework v5.5.27
    - Conclusion: don't install laravel/framework v5.5.26
    - Conclusion: don't install laravel/framework v5.5.25
    - Conclusion: don't install laravel/framework v5.5.24
    - Conclusion: don't install laravel/framework v5.5.23
    - Conclusion: don't install laravel/framework v5.5.22
    - Conclusion: don't install laravel/framework v5.5.21
    - Conclusion: don't install laravel/framework v5.5.20
    - Conclusion: don't install laravel/framework v5.5.19
    - Conclusion: don't install laravel/framework v5.5.18
    - Conclusion: don't install laravel/framework v5.5.17
    - Conclusion: don't install laravel/framework v5.5.16
    - Conclusion: don't install laravel/framework v5.5.15
    - Conclusion: don't install laravel/framework v5.5.14
    - Conclusion: don't install laravel/framework v5.5.13
    - Conclusion: don't install laravel/framework v5.5.12
    - Conclusion: don't install laravel/framework v5.5.11
    - Conclusion: don't install laravel/framework v5.5.10
    - Conclusion: don't install laravel/framework v5.5.9
    - Conclusion: don't install laravel/framework v5.5.8
    - Conclusion: don't install laravel/framework v5.5.7
    - Conclusion: don't install laravel/framework v5.5.6
    - Conclusion: don't install laravel/framework v5.5.5
    - Conclusion: don't install laravel/framework v5.5.4
    - Conclusion: don't install laravel/framework v5.5.3
    - Conclusion: don't install laravel/framework v5.5.2
    - Conclusion: don't install laravel/framework v5.5.1
    - elibyy/tcpdf-laravel 5.6.0 requires illuminate/support 5.6.* -> satisfiable by illuminate/support[v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.3, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9].
    - elibyy/tcpdf-laravel 5.6.1 requires illuminate/support 5.6.* -> satisfiable by illuminate/support[v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.3, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9].
    - elibyy/tcpdf-laravel 5.6.2 requires illuminate/support 5.6.* -> satisfiable by illuminate/support[v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.3, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9].
    - don't install illuminate/support v5.6.0|don't install laravel/framework v5.5.0
    - don't install illuminate/support v5.6.1|don't install laravel/framework v5.5.0
    - illuminate/support v5.6.10 conflicts with laravel/framework[v5.5.0].
    - illuminate/support v5.6.11 conflicts with laravel/framework[v5.5.0].
    - illuminate/support v5.6.12 conflicts with laravel/framework[v5.5.0].
    - illuminate/support v5.6.13 conflicts with laravel/framework[v5.5.0].
    - illuminate/support v5.6.14 conflicts with laravel/framework[v5.5.0].
    - illuminate/support v5.6.15 conflicts with laravel/framework[v5.5.0].
    - illuminate/support v5.6.16 conflicts with laravel/framework[v5.5.0].
    - illuminate/support v5.6.17 conflicts with laravel/framework[v5.5.0].
    - illuminate/support v5.6.19 conflicts with laravel/framework[v5.5.0].
    - don't install illuminate/support v5.6.2|don't install laravel/framework v5.5.0
    - illuminate/support v5.6.20 conflicts with laravel/framework[v5.5.0].
    - illuminate/support v5.6.21 conflicts with laravel/framework[v5.5.0].
    - illuminate/support v5.6.22 conflicts with laravel/framework[v5.5.0].
    - illuminate/support v5.6.23 conflicts with laravel/framework[v5.5.0].
    - illuminate/support v5.6.24 conflicts with laravel/framework[v5.5.0].
    - illuminate/support v5.6.25 conflicts with laravel/framework[v5.5.0].
    - illuminate/support v5.6.26 conflicts with laravel/framework[v5.5.0].
    - don't install illuminate/support v5.6.3|don't install laravel/framework v5.5.0
    - don't install illuminate/support v5.6.4|don't install laravel/framework v5.5.0
    - don't install illuminate/support v5.6.5|don't install laravel/framework v5.5.0
    - don't install illuminate/support v5.6.6|don't install laravel/framework v5.5.0
    - don't install illuminate/support v5.6.7|don't install laravel/framework v5.5.0
    - illuminate/support v5.6.8 conflicts with laravel/framework[v5.5.0].
    - illuminate/support v5.6.9 conflicts with laravel/framework[v5.5.0].
    - Installation request for laravel/framework 5.5.* -> satisfiable by laravel/framework[v5.5.0, v5.5.1, v5.5.10, v5.5.11, v5.5.12, v5.5.13, v5.5.14, v5.5.15, v5.5.16, v5.5.17, v5.5.18, v5.5.19, v5.5.2, v5.5.20, v5.5.21, v5.5.22, v5.5.23, v5.5.24, v5.5.25, v5.5.26, v5.5.27, v5.5.28, v5.5.29, v5.5.3, v5.5.30, v5.5.31, v5.5.32, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.38, v5.5.39, v5.5.4, v5.5.40, v5.5.5, v5.5.6, v5.5.7, v5.5.8, v5.5.9].
    - Installation request for elibyy/tcpdf-laravel 5.6.* -> satisfiable by elibyy/tcpdf-laravel[5.6.0, 5.6.1, 5.6.2].


passing arguments in setHeaderCallback

Hi, I am able to create static header using the setHeaderCallback method. I want to make my header dynamic and hence need to pass variable to this method. please advise

FPDI on Lumen

Hi @elibyy, I need to use FPDI with TCPDF on Lumen.
I installed FPDI with Composer, and created the file config/tcpdf.php.
I setup use_fpdi = true but the configuration seems to be false:

$ php artisan tinker
Psy Shell v0.9.6 (PHP 7.1.14 — cli) by Justin Hileman
New version is available (current: v0.9.6, latest: v0.9.8)
>>> >>> var_dump(config('tcpdf'));
array(11) {
  ["page_format"]=>
  string(2) "A4"
  ["page_orientation"]=>
  string(1) "P"
  ["page_units"]=>
  string(2) "mm"
  ["unicode"]=>
  bool(true)
  ["encoding"]=>
  string(5) "UTF-8"
  ["font_directory"]=>
  string(0) ""
  ["image_directory"]=>
  string(0) ""
  ["tcpdf_throw_exception"]=>
  bool(false)
  ["use_fpdi"]=>
  bool(false)
  ["use_original_header"]=>
  bool(false)
  ["use_original_footer"]=>
  bool(false)
}
=> null
>>>

Where I am wrong?

setProtection() doesn't work with PHP 7.1.3

I am currently running Laravel 5.6 with PHP 7.1.3 and everything works except when I use setProtection(). I get the following error:

mcrypt_get_cipher_name() is deprecated

Is there a workaround for this?

Version 5.5 doesn't work with laravel 5.3

When i tried to install the newest version of this composer package i got the following error messages:
Problem 1 - Conclusion: don't install elibyy/tcpdf-laravel 5.5.1 - Installation request for elibyy/tcpdf-laravel ^5.5 -> satisfiable by elibyy/tcpdf-laravel[5.5.0, 5.5.1]. - Conclusion: remove laravel/framework v5.3.31 - elibyy/tcpdf-laravel 5.5.0 requires illuminate/support 5.5.* -> satisfiable by illuminate/support[v5.5.0, v5.5.2]. - don't install illuminate/support v5.5.0|don't install laravel/framework v5.3.31 - don't install illuminate/support v5.5.2|don't install laravel/framework v5.3.31 - Installation request for laravel/framework (installed at v5.3.31, required as 5.3.*) -> satisfiable by laravel/framework[v5.3.31].

When i installed version 5.3 it worked.
Is this intented that the laravel version needs to be te same as the tcpdf-laravel package version?

(Sorry for the bad english)

support laravel >=5.3*

I use this plugin in my app in laravel5.2 now laravel5.3 is released and i want to update my laravel
but the elibby dont support laravel5.3
please release stable version for laravel >=5.3.
Tnk.

TCPDF functions missing?

image
image
image
image
I'm having some issues with the library, I'm not sure if I'm doing anything wrong. It also throws errors when trying to use any other method; SetTitle, SetAuthor, AddPage, etc.

Issue rendering a view

im having a little issue, im trying to use writeHTMLCell function and on the html param i set a var with a view rendered but on the pdf output is a pdf in blank, im code looks like this http://prntscr.com/amg46v

this only happpends when i trye to create a pdf with too many data

Sum of table fields on every page.

I have total of 14 records and when I print them in tcpdf I'm getting them as two pages as shown below.
Page1
image1
Page2
image2

In the 1st image final row is showing 11th record.

But I want it to show my total marks of current page. My expected PDF format is mentioned below.
Expected Page1:
image3
Expected Page2:
image4

How can I achieve this in tcpdf? or is there any alternative for this to use in laravel?

local Image example ??

how can i place jpg or png file into pdf and what is the path for the libery in tcpdf config file.

for example Laravel -> storage -> pics

??

'image_directory' => '????',

setHeaderCallback cuts text vertically

Hi,
with this simple code:

PDF::setHeaderCallback(function($pdf) {
	$pdf->SetFont('helvetica', 'B', 20);
	// Title
	$pdf->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M');
});

PDF::AddPage();
PDF::Write(0, 'Hello World');
PDF::Output($codice . '.pdf');

I get this PDF:
schermata a 2018-03-29 11-17-09

Same if I add footer.
What I am doing wrong?

Problem with laravel 5.4

I have a problem with laravel 5.4
When i add tcpdf and run composer update, i receive this error
- The requested package elibyy/laravel-tcpdf 5.4.* exists as elibyy/laravel-tcpdf[5.1.x-dev, dev-master, v0.0.1, v0.0.2, v0.0.3, v0.0.4, v0.0.5, v0.0.6] but these are rejected by your constraint.

How To Export PDF from blade with image

Hi,

I'm trying to export a table blade with an image to PDF Using elibyy/tcpdf-laravel.

My Controller:

`public function exportPDF(){
      $users = User::orderBy('id','DESC')->get();
     $view = View::make('admin.users.export',compact('users'));
     $contents = (string) $view;
      $contents = $view->render();
     $pdf = new PDF();
  $pdf::SetTitle('Users List');
  $pdf::SetSubject('Users List');
  $pdf::SetKeywords('User');
  $pdf::SetTitle('User List');
  $pdf::AddPage();
  $pdf::writeHTML($contents, true, false, true, false, '');
  $pdf::Output('users.pdf');`

My Blade:

<html>
<head>
<body>
<h4>Users List</h4>
<table>
<tr>
<th>Image</th>
<th>First Name</th>
<th>Last Name</th>
<th>User Name</th>
<th>Email</th>
<th>Role</th>
</tr>     
@if($users->count())  
@foreach($users as $user)  
<tr> 
<td><img src="{{asset('images/users/'.$user->image_path)}}"></td> 
<td>{{$user->first_name}}</td>
<td>{{$user->last_name}}</td>
<td>{{$user->username}}</td>
<td>{{$user->email}}</td>
<td>{{$user->role}}</td>
</tr>
@endforeach 
</table>
</body>
</html>

But when i want to get the pdf it take a long time and after that it gave me this message

TCPDF ERROR: [Image] Unable to get the size of the image:http://127.0.0.1:8000/images/users/1523518590.jpg

Cannot declare class PDF, because the name is already in use

I installed tcpdf-laravel 5.6 on Lumen 5.6.

I registered the class into bootstrap/app.php:

// TCPDF
$app->register(Elibyy\TCPDF\ServiceProvider::class);
class_alias(Elibyy\TCPDF\Facades\TCPDF::class, 'PDF');

But when I try to use it I get this error:

ErrorException: Cannot declare class PDF, because the name is already in use

If I remove the class_alias declaration I get this (correct) error:

Error: Class 'PDF' not found

Where I am wrong?

Thanks!

How to set custom page format and orientation?

I checked the TCPDF class there is a method

public static function changeFormat($format)
{
    static::$format = $format;
}

but when I use it, it is not working.

PDF::changeFormat('A6');
PDF::SetTitle('Sample PDF');
PDF::AddPage();
PDF::SetFont('dejavusans', '', 12);
PDF::writeHTML($html_content, true, 0, true, 0);
PDF::setRTL(false);

How to override the default configs? I want to use multiple sizes

Undefined property: Elibyy\TCPDF\TCPDFHelper::$h

Hi @elibyy (and others),

I'm recieving structural errors when calling the function below from a queue. When I'm calling the exact same function (with the same content, etc) to render it in my browser, it's going great. The content is simple plain html, no magic.

The error is:

ErrorException: Undefined property: Elibyy\TCPDF\TCPDFHelper::$h in ../vendor/tecnickcom/tcpdf/tcpdf.php:2793

This is the function; regarding other issues I tried the reset(); method, but no success.

PDF::reset();
PDF::SetTitle('Foobar');
PDF::SetMargins(15,30,15);
PDF::AddPage();
PDF::writeHTML($this->content);
$this->content = PDF::Output('Foobar.pdf','S');
Storage::put($this->archive_file, $this->content);

Do you have an idea what might go wrong? Thank you for your time.

Class 'PDF' not found in Lumen

I am using the 5.2 version on Lumen 5.4.7, i registered the class with

$app->withFacades();
$app->register(Elibyy\TCPDF\ServiceProvider::class);

but my route returns me this error

Fatal error: Class 'PDF' not found in /Users/m/Documents/Projects/pdf/app/Http/Controllers/PdfController.php on line 15
(1/1) FatalErrorException
Class 'PDF' not found
in PdfController.php (line 15)
at Application->handleShutdown()
in RegistersExceptionHandlers.php (line 54)
at Application->Laravel\Lumen\Concerns\{closure}()

I am wondering if I missing something but I read the documentation at https://github.com/elibyy/tcpdf-laravel/tree/5.4.2 and I followed what is written at "for lumen you should add the following line".

Laravel 5.6 support

I am upgrading to Laravel 5.6 and tcpdf-laravel requires Laravel 5.5.*. I Know Laravel 5.6 is still very fresh (released yesterday), but are there any plans for supporting it? Thanks in advance!

Header and footer fails to render

Not sure why. TCPdf fails to render header and footer. But TCPDF(original tecknicom/TCPDF) is fine. I have to switch to TCPDF for my PdfWriter.

Laravel 5.5 with PHP 7.2.0 - The each() function is deprecated. This message will be suppressed on further calls

Hello, I'm developing a project with laravel and php version 7.2.0. When i tried create my PDF file using tcpdf, i had this message

The each() function is deprecated. This message will be suppressed on further calls

And the message showed is related to the next file at lines 16548 and 16561

vendor\tecnickcom\tcpdf\tcpdf.php

16548 while (list($id, $name) = each($attr_array[1])) {

16561 while (list($id, $name) = each($attr_array[1])) {

I replaced the line with the next code in both lines and it worked

foreach($attr_array[1] as $id => $name) {

If it is rigth and it is useful, add the change at project else i hope the right fix.

Thank you so much!

fpdi or similar

I need to add to my pdf, some other pdf. There is the possibility to do this?

Can you help me ?

thanks

Config tcpdf.php wrong variable "page_units"

I spent hours trying to figure out why the margins were not changing per the config file and then I discovered this minor discrepancy:

The package's TCPDFHelper calls "Config::get('tcpdf.page_unit', 'mm')," as the default ,while the config tcpdf.php file calls out "page_units" (plural)

So what I thought was 0.5in was really 0.5mm, basically zero margins.

Can't download sample.pdf

I tried your tutorial but then it always says can't download the file.
untitled

Hope you see this. Thanks !

Header & Footer

Hi, I tried to use the helper function
image

But not rendering even the Write function for simple text, nothing rendered. Am I missing something?Please enlighten me.

thanks

issues with Lumen

Thx for your work !
it really helps. I had some issues to make it work with Lumen.
i had to create a helpers.php file in app/
(with this content) :

<?php
  if ( ! function_exists('config_path'))
    /**
       * Get the configuration path.
       *
       * @param  string $path
       * @return string
       */
     function config_path($path = '')
      {
          return app()->basePath() . '/config' . ($path ? '/' . $path : $path);
      }
  }

and to modify composer.json to add

,
"files": [
"app/helpers.php"
]

Then, it works.
Am i the only one ? did i miss something ?
Thx

tcpdf.php throws error if HTML has 2 HREFs in it

I am using Laravel 5.3 and the current version of this wrapper. Not sure if this is an error in this wrapper, or the underlying library for tcpdf. But I think it is this wrapper because I am converting a static app to laravel and tcpdf works in my static app, and also, the tcpdf example pages have html data with multiple links in it.

I have now tested this in many ways, and if I have HTML data to convert to pdf that has 2 links in the data e.g. something like this:

<p>Lorem ipsum dolor sit amet <a href="http://www.somelink.com/">link</a>
consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et 
dolore magna aliqua <a href="http://www.somelink2.com/">link2</a> etc...</p>

I always get a failure throwing the error: ErrorException in tcpdf.php line 18807: Illegal string offset 'url'

But, if I have HTML data with just one href link in it, the PDF resolves fine.

Line 18807 in tcpdf.php is:

$this->HREF['url'] = $tag['attribute']['href'];

The code near there in tcpdf.php is:

case 'a': {
    if (array_key_exists('href', $tag['attribute'])) {
	$this->HREF['url'] = $tag['attribute']['href'];
    }
    break;
}

I do not think this will matter, but my PDF generating code (sans the actual html) is:

      PDF::SetTitle('Title of PDF');
      PDF::SetFont('times', '', 11);
      PDF::AddPage();
      $image = public_path().'/images/logo.jpg';
      PDF::Image($image,
        $x = '10',
        $y = '10',
        $w = 75,
        $h = 0,
        $type = 'JPG',
        $link = '',
        $align = 'N',
        $resize = false,
        $dpi = 300,
        $palign = 'L',
        $ismask = false,
        $imgmask = false,
        $border = 0,
        $fitbox = false,
        $hidden = false,
        $fitonpage = false,
        $alt = false,
        $altimgs = array());
      PDF::WriteHTML($docbody);
      PDF::writeHTMLCell(120, 0, '', '', $html, '', 1, 0, true, 'R', true);
      $attachment = storage_path().'/filelocation/'.$var->name.'_'.date("F j, Y").'.pdf';
      PDF::Output($attachment,'FI');

How to define config settings?

Is there an easy way to define a couple of of constants from the tcpdf_config?

Now I have to do this on every function that I use tcpdf

define('K_THAI_TOPCHARS', false);

Is there a way to do this globally? I tried adding it to the tcpdf.php config file in Laravel, but then the tests fail...

How to use it on Lumen?

Hi @elibyy

Thank you for making this great wrapper

I tried to use this repo with Lumen by adding this line to bootstrap/app.php (of course after composer require elibyy/tcpdf-laravel)

$app->register(Elibyy\TCPDF\ServiceProvider::class);

I got these error:

PHP Fatal error: Class 'Config' not found in /Applications/XAMPP/xamppfiles/htdocs/lumen-api/vendor/elibyy/tcpdf-laravel/src/ServiceProvider.php on line 73

Fatal error: Class 'Config' not found in /Applications/XAMPP/xamppfiles/htdocs/lumen-api/vendor/elibyy/tcpdf-laravel/src/ServiceProvider.php on line 73

How can I resolve this?
Thank you very much.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.