Coder Social home page Coder Social logo

laravel-tcpdf's Introduction

PLEASE NOTE: This repository is no logner maintained please use new one

Laravel 5 TCPDF

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

Installation

#for laravel 5.1 use the 5.1 branch or version 0.0.4

The Laravel TCPDF service provider can be installed via composer by requiring the elibyy/laravel-tcpdf 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)

{
    "require": {
        "elibyy/laravel-tcpdf": "0.*"
    }
}

Next, add the service provider to config/app.php.

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

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

Here is a little example:

use PDF;

PDF::SetTitle('Hello World');

PDF::AddPage();

PDF::Write(0, 'Hello World');

PDF::Output('hello_world.pdf');

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

Now access config/laravel-tcpdf.phpto customize.

laravel-tcpdf's People

Contributors

eli-amazing avatar elibyy avatar gitter-badger avatar

Stargazers

 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

laravel-tcpdf's Issues

Your example doc does not work.

I put in the required file.

I inserted the provider you gave.

I ran composer update.

I attempted to create a file.

An error is not thrown, but it ceases working for some reason.

If you need a deeper explanation or demonstration of what I am doing so you can improve this package, do let me know.

Thanks!

SetHeaderData

seemed to be working and now this command is not? not seeing a header is my PDFs

Readme Update Suggestion

A coworker took a crack at it and found a similar issue with your readme.

But he did find a good solution...

Please update your readme to include that you need to use in your controllers:

use PDF;

Hope this eliminates any confusion and trouble in the future...

Does your wrapper support overwriting the Header/Footer class?

I've tried printing headers and footers by extending your class and overwriting the Header() and Footer() functions. This does not work.

What is the correct way to use headers and footers with your wrapper?

use Elibyy\TCPDF\Facades\TCPdf;

class Pdf extends TCPdf
{

    //Page header
    public function Header() {
        // Set font
        $this->SetFont('helvetica', 'B', 20);
        // Title
        $this->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M');
    }

    // Page footer
    public function Footer() {
        // Position at 15 mm from bottom
        $this->SetY(-15);
        // Set font
        $this->SetFont('helvetica', 'I', 8);
        // Page number
        $this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
    }



}

Does this wrapper has UTF8 support

my code to load the pdf
` $html = view('sample_pdf');

    PDF::SetTitle('My Test Page');

    PDF::AddPage();

    PDF::writeHTML($html);

    PDF::Output('sample.pdf');

`
html code

screen shot 2015-09-09 at 10 11 39 am

the chinese words are being replace with "?"

PDF output
screen shot 2015-09-09 at 10 12 27 am

Error when triggering the generation of multiple PDF's one after another.

I have a Laravel command that syncs items (including generated pdf's) to a third party service via API. If there is only one PDF to generate, it runs fine, but if I have 2 items to sync, the command fails on the second PDF generation.

[ErrorException]
Undefined property: Elibyy\TCPDF\TCPdf::$h

I can't post my PDF generation code because I have secure business logic intertwined to generate the PDF. Do I need to have something at the end of the generation that resets TCPDF?

how to load blade view ?

Is there a way to load view and passing data to the view?

something like
$pdf = new TCPDF()
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
$pdf ->loadView('pdf.invoice', $data);
$pdf->Output(storage_path().'/pdf/file.pdf', 'I');

thanks.

Help guide needs an update...

Dug into your code and saw some minor changes that are required in order for people to use your PDF tool.

Code is as follows:

use TCPDF;

$pdf = new TCPDF;
$pdf->SetTitle('Hello World');
$pdf->AddPage();
$pdf->Write(0, 'Hello World');
$pdf->Output('hello_world.pdf','D');

Custom header and footer

How can I use custom header or footer Using this package?

`use PDF;

PDF::SetTitle('Hello World');

PDF::AddPage();

PDF::Write(0, 'Hello World');

PDF::Output('hello_world.pdf');`

It work fine, but I can’t add custom header and footer!

Undefined property: Elibyy\TCPDF\Pdf::$inxobj

Getting this error in the following function:
ErrorException in tcpdf.php line 3103:
Undefined property: Elibyy\TCPDF\Pdf::$inxobj

public function pdf_order($data, $order_id) {
ob_start();
//$this->getGenerateAffair($order_id);
$pdf = new PDF($orientation = 'P', $unit = 'in', $format = 'A4', $unicode = true, $encoding = 'UTF-8', $diskcache = false, $pdfa = false);
$pdf::SetPrintHeader(false);
$pdf::SetPrintFooter(false);
$pdf::AddPage();
$pdf::setHtmlVSpace(array('p' => array(array('n' => 0.01), array('n' => 0.01))));
$html = view('app.pdf.order/en_p1', $data)->render();
$pdf::writeHTML($html, true, false, true, false, '');

    $pdf::AddPage();
    $html = view('app.pdf.order/en_p2', $data)->render();
    $pdf::writeHTML($html, true, false, true, false, '');
    $pdf::lastPage();
    $path = "./pdf/affairs/" . $order_id;
    if (file_exists($path) == false) {
        File::makeDirectory($path, $mode = 0777);
    }
    $pdf::Output(__DIR__ . '\..\..\..\public\pdf\affairs\\' . $order_id . '\\' . $order_id . '_affar.pdf', 'F');
    ob_end_clean();
    return;
}

5.2 support

Would it be possible to have a branch for 5.2 support?

As far as I can tell, the changes required would be:

  • illuminate/support @ 5.2.*
  • tcpdf @ 6.2.12

And changing ServiceProvider.php#L30 from
$this->app->bindShared
to
$this->app->singleton

Still testing in my app. I can try to fix up a PR if you want.

Set Font and Images Folder

How do I set font and Images folder in the config file after publishing.....can I refer to the assests folder on use the default paths......I think you should include one by default and add to the documentation.

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.