Giter Club home page Giter Club logo

whiteoctobertcpdfbundle's Introduction

This project is not actively maintained. For Symfony 3.4 and above, you may wish to use this fork.

WhiteOctoberTCPDFBundle

This bundle facilitates easy use of the TCPDF PDF generation library in Symfony2 applications.

Installation

Step 1: Setup Bundle and dependencies

composer require whiteoctober/tcpdf-bundle

Version constraining (optional)

By default, this bundle does not constrain the version of TCPDF that composer installs. (An explanation of this unusual decision is here). This means that a composer update could update to a new major version of TCPDF. Since this bundle is only a thin wrapper around TCPDF, you can normally do such an upgrade without issue.

However, if you do wish to constrain the TCPDF version, find out what version you currently have installed with:

composer show tecnickcom/tcpdf

And amend your project's composer.json to add a TCPDF version constraint in the requires section. For example, if TCPDF version 6.2.17 was installed, "tecnickcom/tcpdf": "^6.2.17" will allow anything < 7 when upgrading.

Step 2: Enable the bundle in the kernel

Add the bundle to the registerBundles() method in your kernel:

In Symfony < 4:

// app/AppKernel.php
<?php

public function registerBundles()
{
    $bundles = array(
        // ...
        new WhiteOctober\TCPDFBundle\WhiteOctoberTCPDFBundle(),
    );
}

In Symfony 4:

// config/bundles.php
return [
    // ...
    WhiteOctober\TCPDFBundle\WhiteOctoberTCPDFBundle::class => ['all' => true],
    // ...
];

(This project is not yet configured with Symfony Flex, so this change to config/bundles.php won't be done automatically.)

If you want to do service autowiring, you'll need to add an alias for the service:

# app/config/services.yml (Symfony 3)
# config/services.yaml (Symfony 4)
services:
    # ...

    # the `white_october.tcpdf` service will be injected when a
    # `WhiteOctober\TCPDFBundle\Controller\TCPDFController` type-hint is detected
    WhiteOctober\TCPDFBundle\Controller\TCPDFController: '@white_october.tcpdf'

Using TCPDF

You can obtain the white_october.tcpdf service from the container, and then create a new TCPDF object via the service:

$pdfObj = $container->get("white_october.tcpdf")->create();

From hereon in, you are using a TCPDF object to work with as normal.

Configuration

Configuration values

You can pass parameters to TCPDF like this:

# app/config/config.yml (Symfony < 4)
# config/packages/white_october_tcpdf.yaml (Symfony 4)
white_october_tcpdf:
    tcpdf:
        k_title_magnification: 2

You can see the default parameter values in WhiteOctober\TCPDFBundle\DependencyInjection\Configuration::addTCPDFConfig.

If you want, you can use TCPDF's own defaults instead:

white_october_tcpdf:
    tcpdf:
        k_tcpdf_external_config: false  # the values set by this bundle will be ignored

Using a custom class

If you want to use your own custom TCPDF-based class, you can use the class parameter in your configuration:

# app/config/config.yml (Symfony < 4)
# config/packages/white_october_tcpdf.yaml (Symfony 4)
white_october_tcpdf:
    class: 'Acme\MyBundle\MyTCPDFClass'

The class must extend from the TCPDF class; an exception will be thrown if this is not the case.

License

This bundle is under the MIT license. See the complete license in the bundle:

Resources/meta/LICENSE

This project was originally located at https://github.com/whiteoctober/WhiteOctoberTCPDFBundle

whiteoctobertcpdfbundle's People

Contributors

djangofr avatar jacobmaster avatar kaspervrind avatar osukaru avatar piotrantosik avatar raziel057 avatar richsage avatar samnela avatar sampart avatar senuphtyz avatar svetlinstaevworldstores avatar thomaslandauer avatar tvlooy avatar yarbu avatar zerrvox avatar zhil 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

Watchers

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

whiteoctobertcpdfbundle's Issues

Error tempnam when insertint image inside twig

Hello, when I try to create a PDF with an image in it, I get this

Notice: tempnam(): file created in the system's temporary directory

The image inside the twig is added as

<img src="{{ asset('img/image.png') }}">

Please help

Problem when clearing the cache

When clearing the cache in prod mode I get the following error (Symfony 2.0.15, WhiteOctoberTCPDFBundle commit 673d9ac) :

[InvalidArgumentException]
The parameter "white_october_tcpdf.tcpdf" must be defined.

I didn't manage to tweak WhiteOctoberTCPDFBundle.php and parameters to make it work. I installed the bundle following the installation process, nothing more.

Images are no longer included

After upgrading to Symfony 2.3 and the current WhiteOctoberTCPDFBundle release (0e82ad1) my PDF throw the following error during the rendering in Symfony:

TCPDF ERROR: [Image] Unable to get image: /usr/local/symfony/2.3/enetz/app/../vendor/tecnick.com/tcpdf/examples/images/bundles/enetzresource/images/allgaeuer-kraftwerke_logo.png

The source code which causes this is:

$pdf->SetHeaderData("bundles/enetzresource/images/allgaeuer-kraftwerke_logo.png", '', 'RSS Reader Report', $title_page);

That code worked fine until the updated. Can't find any hints on config changes or sth like that.

Thank for any help!

Regards,

Michl

Support for symfony 2.1 ?

Hello
I really like your bundle but since I upgrade my project in symfony 2.1 I can't use anymore your bundle. I saw on packagist that the bundle support symfony 2.0.x, Is it just a problem with the composer.json or you have to change a lot of thing to support the 2.1.x version ? If yes may I help ?
Thanks for your times guys...

Create table with editable cells

Hi,
I have a question, is it possible to create a table with tcpdf, the cells of which are fillable (editable).
I try but styles doesn't work. So please say are there any other way todo it.
And why many styles doesn't work?

services.yaml

Can you tell me how shoudl be make services.yaml,

i put : "WhiteOctober\TCPDFBundle\Controller\TCPDFController: '@white_october.tcpdf'"
but its not enough becouse all the time I get

Cannot autowire service "App\Controller\BarCodeController": argument "$contener" of method "__construct()" references class "WhiteOctober\TCPDFBundle\WhiteOctoberTCPDFBundle" but no such service exists.

for
` protected $contener;

public function __construct(WhiteOctoberTCPDFBundle $contener)
{
    $this->contener = $contener;
}`

phpStorm custom class auto completion

Hi,

does anyone know how PhpStorm can detect, that I've included a custom class for this bundle?

My custom methods aren't detected automatically, which is quite annoying.
The create method from the bundle returns explicit a TCPDF object, which is in fact correct, but it doesn't get the inheritance relation ;-(

Any hints are very appreciated!

Symfony env variable

Hello!

Symfony 5.* has no longer have %kernel.root_dir%.

When I change this

->scalarNode('file')->defaultValue('%kernel.root_dir%/../vendor/tecnickcom/tcpdf/tcpdf.php')->end()

in this

->scalarNode('file')->defaultValue('%kernel.project_dir%/vendor/tecnickcom/tcpdf/tcpdf.php')->end()

and others "%kernel.root_dir%" variables, works perfectly.

Thanks!

Undefined constant K_PATH_MAIN

I fixed adding define('K_PATH_MAIN', '%kernel.root_dir%/../vendor/tcpdf/'); in TCPDFController.php but I don't think this is the best way to solve it...

[ErrorException]                                                                                                                       
    Notice: Use of undefined constant K_PATH_MAIN - assumed 'K_PATH_MAIN' in /vendor/tcpdf/tcpdf.php line 23500

Problem with the bundle

Hi,

I don't understand why I have a problem with this bundle. On my local workstation based on Wamp, all functionnality are ok, but when I pass all files on my production's server I obtain an Error like this :
TCPDF ERROR: Could not include font definition file: helvetica

Can you quickly help me for fixing this problem, because I must render my work this week and I don't create a little PDF. Thanks by advance for a little help from your part !

๐ŸŽฑ

I cant use the Fork

Hi all,

Im trying to config the fork Qipsius but it's not possible. I've done all step in doc:

  1. Install and register the bundle
  2. Create service Qipsius\TCPDFBundle\Controller\TCPDFController: '@qipsius.tcpdf'
  3. And the last: $pdfObj = $container->get("qipsius.tcpdf")->create();

I get the following error: "Service "qipsius.tcpdf" not found: even though it exists in the app's container"

I'm using Symfony 5 version.

Thanks for help!

Unable to get the size of the image

Hello, I'm rendering and html template via writeHTML() method. I get this error:

TCPDF ERROR: [Image] Unable to get the size of the image: https://example.com/image.jpg

(The image is accesible and visible if I paste the adress in the browser)

Curl and allow_url_fopen are enabled so I read a possible issue may be write permissions on temporal folder, could this be the case? Which is this folder then?

Any other ideas?

Thank you

Package tecnick.com/tcpdf is abandoned / new version needed

I see you have already changed tecnick.com/tcpdf to tecnick/tcpdf in master branch, but this change did not get it's own version tag, so it cannot yet be pulled via composer, and thus composer complains:

Package tecnick.com/tcpdf is abandoned, you should avoid using it. Use tecnickcom/tcpdf instead.

Could you please tag the latest version with a number

custom config parameters not loaded

Your WhiteOctoberTCPDFBundle class defines only "k_" prefixed constants like "k_path_cache" and "pdf_font_name_main" constant.
Any other common parameter like "pdf_author" or "pdf_creator", while it's defined in Configuration, is not defined as a constant.
Maybe logic should be changed in WhiteOctoberTCPDFBundle rows 27 - 42.

Best regards
Matteo Rossi

Add version constraint for tecnickcom/tcpdf

It is very bad practice to just include any version from another package. This will cause updates when running composer update while your package isn't update but the required dependency is.

Looking for maintainers

Hi,

Sam here, one of the current maintainers of this project.

Given that we no longer use PHP in any of our active projects, it's becoming harder to give this plugin the time it needs.

Therefore, we're looking for new maintainer(s) for this project.

We'd like any new prospective maintainer to fork this project, and then once that fork has moved forward enough to give us confidence in your ownership, we would link to your fork prominently from the top of the README here, encouraging others to use it instead.

If you're interested, please go ahead and fork (if you haven't already) and start work! If you've forked and would like others to help you, feel free to reply in this issue with details of your fork.

Please do reply here if you have questions. Thanks in anticipation.

Configuration ignored

Hi,

I noticed that the configuration is totally ignored by tcpdf as explained here:
http://stackoverflow.com/questions/13235808/change-whiteoctober-tcpdf-bundle-configuration-values

I think it's due to a change in the 6.0.017 version (as now the configuration is managed in tcpdf_autoconfig.php file)

6.0.017 (2013-05-16)
- The command line tool tcpdf_addfont.php was improved.
- The php logic was removed from configuration files that now contains only constant defines.
- The tcpdf_autoconfig.php file was added to automatically set missing configuration values.

Fatal error!!

Hello, I use this bundle and a lot of thanks for it. Today I updated composer and got an error!!

PHP Fatal error:  Can't use function return value in write context in /somepath/vendor/tecnick.com/tcpdf/tcpdf.php on line 22082

how this can be fixed?

thanks

Constants from tcpdf_autoconfig cannot be override in boot()

In my not-small project I have in composer.json:

    "require": {
        "whiteoctober/tcpdf-bundle": "dev-master",

and in AppKernel.php only:

    $bundles = array(
        new WhiteOctober\TCPDFBundle\WhiteOctoberTCPDFBundle(),
        // ...

but unfortunately the tcPDF defined constants BEFORE the WhiteOctoberTCPDFBundle
so the WhiteOctober can't overwrite them.
(in boot() function in WhiteOctoberTCPDFBundle.php)

I don't know where is my falut? How to boot WhiteOctober BEFORE tcPDF tcpdf/tcpdf_autoconfig.php ?

(problem is in line 35: if (!defined($constKey)) .... )

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.