TCPDF - PHP PDF Library - https://tcpdf.org

Related tags

PDF tc-lib-pdf
Overview

tc-lib-pdf

PHP PDF Library

UNDER DEVELOPMENT (NOT READY)

UPDATE: CURRENTLY ALL THE DEPENDENCY LIBRARIES ARE ALMOST COMPLETE BUT THE CORE LIBRARY STILL REQUIRES A SIGNIFICANT AMOUNT OF WORK TO BE COMPLETED.

Latest Stable Version Master Build Status Master Coverage Status License Total Downloads

Donate via PayPal Please consider supporting this project by making a donation via PayPal

Description

PHP library for generating PDF documents on-the-fly.

Main Features:

  • no external libraries are required for the basic functions;
  • all standard page formats, custom page formats, custom margins and units of measure;
  • UTF-8 Unicode and Right-To-Left languages;
  • TrueTypeUnicode, OpenTypeUnicode v1, TrueType, OpenType v1, Type1 and CID-0 fonts;
  • font subsetting;
  • methods to publish some XHTML + CSS code, Javascript and Forms;
  • images, graphic (geometric figures) and transformation methods;
  • supports JPEG, PNG and SVG images natively, all images supported by GD (GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM) and all images supported via ImagMagick (http://www.imagemagick.org/script/formats.php)
  • 1D and 2D barcodes: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extension, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS, Datamatrix, QR-Code, PDF417;
  • JPEG and PNG ICC profiles, Grayscale, RGB, CMYK, Spot Pdfs and Transparencies;
  • automatic page header and footer management;
  • document encryption up to 256 bit and digital signature certifications;
  • transactions to UNDO commands;
  • PDF annotations, including links, text and file attachments;
  • text rendering modes (fill, stroke and clipping);
  • multiple columns mode;
  • no-write page regions;
  • bookmarks, named destinations and table of content;
  • text hyphenation;
  • text stretching and spacing (tracking);
  • automatic page break, line break and text alignments including justification;
  • automatic page numbering and page groups;
  • move and delete pages;
  • page compression (requires php-zlib extension);
  • XOBject Templates;
  • Layers and object visibility.
  • PDF/A-1b support.

Third party fonts:

This library may include third party font files released with different licenses.

All the PHP files on the fonts directory are subject to the general TCPDF license (GNU-LGPLv3), they do not contain any binary data but just a description of the general properties of a particular font. These files can be also generated on the fly using the font utilities and TCPDF methods.

All the original binary TTF font files have been renamed for compatibility with TCPDF and compressed using the gzcompress PHP function that uses the ZLIB data format (.z files).

The binary files (.z) that begins with the prefix "free" have been extracted from the GNU FreeFont collection (GNU-GPLv3). The binary files (.z) that begins with the prefix "pdfa" have been derived from the GNU FreeFont, so they are subject to the same license. For the details of Copyright, License and other information, please check the files inside the directory fonts/freefont-20120503 Link : http://www.gnu.org/software/freefont/

The binary files (.z) that begins with the prefix "dejavu" have been extracted from the DejaVu fonts 2.33 (Bitstream) collection. For the details of Copyright, License and other information, please check the files inside the directory fonts/dejavu-fonts-ttf-2.33 Link : http://dejavu-fonts.org

The binary files (.z) that begins with the prefix "ae" have been extracted from the Arabeyes.org collection (GNU-GPLv2). Link : http://projects.arabeyes.org/

ICC profile:

TCPDF includes the sRGB.icc profile from the icc-profiles-free Debian package: https://packages.debian.org/source/stable/icc-profiles-free

Getting started

First, you need to install all development dependencies using Composer:

$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer

This project include a Makefile that allows you to test and build the project with simple commands. To see all available options:

make help

To install all the development dependencies:

make deps

Running all tests

Before committing the code, please check if it passes all tests using

make qa

All artifacts are generated in the target directory.

Example

Examples are located in the example directory.

Start a development server (requires PHP 5.4) using the command:

make server

and point your browser to http://localhost:8000/index.php

Installation

Create a composer.json in your projects root-directory:

{
    "require": {
        "tecnickcom/tc-lib-pdf": "dev-main"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "[email protected]:tecnickcom/tc-lib-pdf.git"
        }
    ]
}

Packaging

This library is mainly intended to be used and included in other PHP projects using Composer. However, since some production environments dictates the installation of any application as RPM or DEB packages, this library includes make targets for building these packages (make rpm and make deb). The packages are generated under the target directory.

When this library is installed using an RPM or DEB package, you can use it your code by including the autoloader:

require_once ('/usr/share/php/Com/Tecnick/Barcode/autoload.php');

Developer(s) Contact

Comments
  • Automatic adjustment of cell width

    Automatic adjustment of cell width

    Hi there, Let say i have a document just for an example with a width of 100 I create 6 cells 1st cell = 10 width 2nd cell = ? 3rd cell = 20 width 4th cell = 20 width 5th cell = 20 width 6th cell = 20 width I just want to ask if is it possible that the 2nd cell can adjust its width given the width of other cells just to fit the whole width of a document? for example the above widths will have a total of 90 so the 2nd cell should automatically adjust to 10 since the total width of document is 100 Is it possible?

    opened by sscbc 6
  • Installation/usage issues with tc-lib-pdf

    Installation/usage issues with tc-lib-pdf

    Hi,

    First of all: thank you for your continuous efforts on TCPDF/tc-lib-pdf. I've been looking into what library I should be using and yours seems to be having quite some features.

    I've tried using tc-lib-pdf however I didn't got it to work and I'm unsure what I'm doing wrong. When trying TCPDF I had no issues and could rather quickly find my way into creating a basic PDF. However I wonder what's the use of learning the "old" TCPDF when you're building tc-lib-pdf as it's successor(I'd rather immediately go that way). I've been trying to find some basic example on how to use your code but that fails.

    IMHO I think the examples are great for TCPDF but the site is misleading in refering to the tc-lib-pdf repo by default (I only noticed after a while that that is why the examples didn't work). Also: the installation notes seem very limited(actually hit the API limiter on github with the instructions on the site). I understand you want to make use of some technologies like composer. However for someone who's not been working with PHP that much recently it's unclear on what steps are now needed to make actual use of your project(for example the site refers to creating a composer.json but not if you'd need to execute anything else like: composer install).

    My actual question is if you'd be so kind to make a basic project example using tc-lib-pdf. So for example: Get the git repository: git clone ... Get the dependencies; composer install Create a file: example.php Add the following to example.php to include tc-lib-pdf to your project (to make use of the namespaces, ...): ... You can create a basic PDF like this: ... To create and view the docs do; ...

    And maybe clearly differentiate on the website between TCPDF and tc-lib-pdf (with the different repo names).

    I think it'd help a lot of people in getting on the new tc-lib-pdf wagon.

    Thanks in advance for your continuous efforts!

    opened by th3penguinwhisperer 5
  • Emoji in text

    Emoji in text

    I'm generating PDF files on the fly with user content which could contain emoji-characters. Currently I'm using a custom font and emoji-characters don't get displayed in the PDF (some are totally hidden, some are printed in unknown characters).

    To be honest, I don't know exactly where to start looking. Should my custom font include the emoji-characters? Or can I do something else to include them? I've tried both MultiCell and writeHTMLCell.

    Thanks!

    opened by tim-brand 4
  • Raise PHP requirements

    Raise PHP requirements

    Please consider raising the minimum requirements for your project to for example PHP 7.2. You are creating a new library and there is no reason to support PHP versions, which haven't been supported for a year or in case of 5.6, several years. Whoever is using your library also is starting over and I don't see anyone running your code on something lower than PHP 7.2, maybe even just PHP 7.4, especially considering that you don't have a date for a release yourself yet.

    opened by Hackwar 3
  • tcpdf datauri in writehtml

    tcpdf datauri in writehtml

    Hi, does tcpdf support datauri in writehtml src tags?

    (i'm using elibyy/tcpdf-laravel)

    i don't want to store the signatures from my clients on my server so instead i've tried to store them as datauri's in my db.

    example code:

    $html .='<img src="'.$data_uri.'" width="300">';
    PDF::Writehtml($html);
    

    i get an empty space where the signature should come.

    i can achieve this with PDF::Image('a'.$datauri) however its not responsive to my pdf then..

    Thanks in advance

    opened by AskinSavascisi 3
  • Accept PRs on the old library to support PHP 7.3?

    Accept PRs on the old library to support PHP 7.3?

    I see that TCPDF is now considered obsolete but seeing as this library is still in development I'm wondering if you would accept PRs on the old library that update for PHP 7.3 compatibility?

    opened by briandotdev 3
  • What is the status of this library ?

    What is the status of this library ?

    Thanks for all the amazing work. I'm a big fan of TCPDF and use it in multiple projects, and I'd love to use an more up to date library. Is this library useable for simple needs ? Is there a roadmap or a backlog where we could pick tickets if we want to help ?

    opened by jmleroux 3
  • Images in the pdf results have some kind of transparency, instead of rendering fully opaque

    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.

    opened by arthur-v-abogadil 3
  • Border trasparent not transparent

    Border trasparent not transparent

    opened by ossarotte 3
  • outlines is not always countable

    outlines is not always countable

    In the example code, $this->outlines is not declared and throws a Exception:

    Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in ..../vendor/tecnickcom/tc-lib-pdf/src/Output.php:757

    opened by maehdros 2
  • Please

    Please

    Hi Guy!

    Really thank you for make PDF library. It is very useful.

    I have problem when make pdf with add timestamp and signature for pdf. Do you know any document relative with timestamp and signature function in PDF. Example

    Hope you reply to me. Thanks so much

    opened by ghost 2
  • Simple text example

    Simple text example

    Hi,

    Could you please add a simple example where you print some text onto a page?

    Should I set the font first? I get an empty page when I try something like this:

    $pdf = new Tcpdf('mm', true); $page01 = $pdf->page->add(); $pdf->page->setX(10); $pdf->page->setY(10); $pdf->page->addContent('This is simple text');

    What am I doing wrong? Your help would be much appreciated.

    opened by wvandenbergdpp 0
  • the project is not usable : Missing at least 2 properties

    the project is not usable : Missing at least 2 properties

    Hi I started to use your library today and I've encounter 3 issues :

    I'm using this to configure :

            foreach ($documents as $invoiceNumber => $document) {
    
                $pdf = new Tcpdf();
                $pdf->setCreator('client');
                $pdf->setAuthor('[email protected]');
                $pdf->setTitle($invoiceNumber);
                $pdf->setSubject('invoice');
                $pdf->setKeywords("facture, {$invoiceNumber}");
                $pdf->page->add();
                $pdf->page->addContent($document);
    
                file_put_contents("../var/invoices/{$invoiceNumber}.pdf", $pdf->getOutPDFString());
            }
    

    first error I encountered:

    Warning: Undefined property: Com\Tecnick\Pdf\Tcpdf::$outlines

    And yes of course the property is defined nowhere so I added it on MetaInfo.php#130 :

    protected $outlines = [];

    Then the second error kicked in :

    Warning: Undefined property: Com\Tecnick\Pdf\Tcpdf::$signature

    so I tried to add in Output#58 : it's weird that this array is not defined anywhere by the way

        protected $signature = [
            'appearance' => [
                'empty' => []
            ]
        ];
    

    But then I got :

    Warning: Undefined variable $out (in getOutSignatureFields)

    And of course the method here is completely messed up. $out not defined out of the foreach for a property that is not existing.

    I tried (without knowing if I was doing any good) to modify getOutSignatureFields in Output.php#876

        protected function getOutSignatureFields()
        {
            $out = '';
            foreach ($this->signature['appearance']['empty'] as $key => $esa) {
                $page = $this->page->getPage($esa['page']);
                $signame = $esa['name'].sprintf(' [%03d]', ($key + 1));
                $out .= $esa['objid'].' 0 obj'."\n"
                    .'<<'
                    .' /Type /Annot'
                    .' /Subtype /Widget'
                    .' /Rect ['.$esa['rect'].']'
                    .' /P '.$page['n'].' 0 R' // link to signature appearance page
                    .' /F 4'
                    .' /FT /Sig'
                    .' /T '.$this->getOutTextString($signame, $esa['objid'])
                    .' /Ff 0'
                    .' >>'
                    ."\n".'endobj';
            }
            return $out;
        }
    

    Now, I've got no error, but PDF is empty.

    Can you assist ?

    opened by jonathangreco 1
  • External images with presigned url from amazon s3 service fail to load.

    External images with presigned url from amazon s3 service fail to load.

    External images with presigned url from amazon s3 service fail to load. URL example.

    https://siiam-chpo-2.s3.us-east-2.amazonaws.com/control_patrimonial/parque_vehicular/test-image-624614388f78c060564166.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm= AWS4-HMAC-SHA256 & X-Amz-Credential = AKIAUKF63TAAV2JKSJR6% 2F20220402% 2Fus-east-2% 2Fs3% 2Faws4_request & X-Amz-Date = 20220402T024413Z & X-Amz-SignedHeaders = host & X-Amz-Expires = 3600 & X-Amz-Signature = 58fdf6462adce4d2837039a484bb7416b957f4b29e8541e9612c97af8bab3217

    The problem is the url_exists method of the tcpdf_static.php class, with this type of pre-signed url it always returns the http code 403. The images are displayed without problem in html templates in the img tags. If I intentionally return code 200 in that function, the image is displayed correctly in the pdf.

    The solution I found is to convert the images to base64 and then pass it to the Image function as in the example. https://tcpdf.org/examples/example_009/

    opened by jsr2609 0
  • tcpdf cyrillic letters displayed as question marks

    tcpdf cyrillic letters displayed as question marks "?"

    I had downloaded tcpdf and here you are - I have a problem.

    simple html code

    <p>Это тест</p>
    

    works all right [enter image description here]1

    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    
    $pdf->SetCreator(PDF_CREATOR);
    $pdf->SetAuthor('Nicola Asuni');
    $pdf->SetTitle('TCPDF Example 002');
    $pdf->SetSubject('TCPDF Tutorial');
    $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
    
    $pdf->setPrintHeader(false);
    $pdf->setPrintFooter(false);
    
    $pdf->SetDefaultMonospacedFont('freeserif');
    
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    
    $pdf->setFontSubsetting(true);
    
    $pdf->SetFont('freeserif', '', 12, '', true);
    
    $pdf->AddPage();
    
    //simple html being shown ok
    $pdf->writeHTML('<p>Это тест</p>');
    
    $pdf->Output('example_002.pdf', 'D');
    

    but when I try to convert my html page cyrillic symbols replaced by question marks "?"

    $pdf->writeHTML($html);
    

    [enter image description here]2

    Please help - I am googling for three days!

    here is a link to my page so you can look at the source code http://u1159833.cp.regruhosting.ru/co_constructor/page.php

    opened by egoriy33 0
Owner
Tecnick.com LTD
Open Source Software
Tecnick.com LTD
Magento 2 Invoice PDF Generator - helps you to customize the pdf templates for Magento 2

Magento 2 Invoice PDF Generator - helps you to customize the pdf templates for Magento 2. If you have an enabled template and a default template for the store you need your template the system will print the pdf template.

EAdesign 64 Oct 18, 2021
PHP library generating PDF files from UTF-8 encoded HTML

mPDF is a PHP library which generates PDF files from UTF-8 encoded HTML. It is based on FPDF and HTML2FPDF (see CREDITS), with a number of enhancement

null 3.8k Jan 2, 2023
PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage

Snappy Snappy is a PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. It uses the excellent webkit-based wkhtmltopd

KNP Labs 4.1k Dec 30, 2022
Official clone of PHP library to generate PDF documents and barcodes

TCPDF PHP PDF Library Please consider supporting this project by making a donation via PayPal category Library author Nicola Asuni [email protected] co

Tecnick.com LTD 3.6k Jan 6, 2023
Pdf and graphic files generator library written in php

Information Examples Sample documents are in the "examples" directory. "index.php" file is the web interface to browse examples, "cli.php" is a consol

Piotr Śliwa 335 Nov 26, 2022
PdfParser, a standalone PHP library, provides various tools to extract data from a PDF file.

PdfParser Pdf Parser, a standalone PHP library, provides various tools to extract data from a PDF file. Website : https://www.pdfparser.org Test the A

Sebastien MALOT 1.9k Jan 2, 2023
PHP library allowing PDF generation or snapshot from an URL or an HTML page. Wrapper for Kozea/WeasyPrint

PhpWeasyPrint PhpWeasyPrint is a PHP library allowing PDF generation from an URL or an HTML page. It's a wrapper for WeasyPrint, a smart solution help

Pontedilana 23 Oct 28, 2022
Official clone of PHP library to generate PDF documents and barcodes

TCPDF PHP PDF Library Please consider supporting this project by making a donation via PayPal category Library author Nicola Asuni [email protected] co

Tecnick.com LTD 3.6k Dec 26, 2022
PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page.

Snappy Snappy is a PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. It uses the excellent webkit-based wkhtmltopd

KNP Labs 4.1k Dec 30, 2022
HTML to PDF converter for PHP

Dompdf Dompdf is an HTML to PDF converter At its heart, dompdf is (mostly) a CSS 2.1 compliant HTML layout and rendering engine written in PHP. It is

null 9.3k Jan 1, 2023
A PHP tool that helps you write eBooks in markdown and convert to PDF.

Artwork by Eric L. Barnes and Caneco from Laravel News ❤️ . This PHP tool helps you write eBooks in markdown. Run ibis build and an eBook will be gene

Mohamed Said 1.6k Jan 2, 2023
Generate simple PDF invoices with PHP

InvoiScript Generate simple PDF invoices with PHP. Installation Run: composer require mzur/invoiscript Usage Example use Mzur\InvoiScript\Invoice; re

Martin Zurowietz 16 Aug 24, 2022
FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF.

FPDI - Free PDF Document Importer ❗ This document refers to FPDI 2. Version 1 is deprecated and development is discontinued. ❗ FPDI is a collection of

Setasign 821 Jan 4, 2023
Convert HTML to PDF using Webkit (QtWebKit)

wkhtmltopdf and wkhtmltoimage wkhtmltopdf and wkhtmltoimage are command line tools to render HTML into PDF and various image formats using the QT Webk

wkhtmltopdf 13k Jan 4, 2023
Convert html to an image, pdf or string

Convert a webpage to an image or pdf using headless Chrome The package can convert a webpage to an image or pdf. The conversion is done behind the sce

Spatie 4.1k Jan 1, 2023
Laravel Snappy PDF

Snappy PDF/Image Wrapper for Laravel 5 and Lumen 5.1 This package is a ServiceProvider for Snappy: https://github.com/KnpLabs/snappy. Wkhtmltopdf Inst

Barry vd. Heuvel 2.3k Jan 2, 2023
Sign PDF files with valid x509 certificate

Sign PDF files with valid x509 certificate Require this package in your composer.json and update composer. This will download the package and the depe

Lucas Nepomuceno 175 Jan 2, 2023
Convert a pdf to an image

Convert a pdf to an image This package provides an easy to work with class to convert PDF's to images. Spatie is a webdesign agency in Antwerp, Belgiu

Spatie 1.1k Dec 29, 2022
Generate pdf file with printable labels

printable_labels_pdf Generate pdf file with printable labels with PHP code. CREATE A PDF FILE WITH LABELS EASELY: You can get a pdf file with labels f

Rafael Martin Soto 5 Sep 22, 2022