Download the PHP package jeydotc/pdf-service without Composer

On this page you can find all versions of the php package jeydotc/pdf-service. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package pdf-service

PDF Renderer Service

Introduction

This library is intended to provide a simple and configurable pipeline for rendering PDFs.

The main idea is to render a PDF using this process:

  1. Receive some data.
  2. Get a template.
  3. Render the template feeding it with the received data.
  4. Generate the PDF from the rendered data.
  5. Store the PDF somewhere.

Those are the 5 key aspects of rendering a PDF and they're all managed by this class:

PDFService\Core\PDFRenderService

The magic comes with the fact that, you can just configure all of these aspects with whatever suites your needs:

  1. Get a template.
    • Get it from file system (only implementation so far, and also the default).
    • Or get from a database.
    • Or get it from an external service.
    • Or just implement ITemplatesRepository and call ->setTemplatesRepository()
  2. Render the template feeding it with the received data.
    • Using Raw PHP (default).
    • Or just implement ITemplateEngine and call ->setTemplateEngine() to adapt your favorite template engine.
  3. Generate the PDF from the rendered data.
    • Using wkhtmltopdf (only implementation so far, and also the default).
    • Or DOMPdf
    • Or whatever thing that can convert HTML to PDF, just implement IPDFRenderer and call ->setPdfRenderer().
  4. Store the PDF somewhere.
    • Just return the data (default).
    • Or store it in the file system (also implemented).
    • Or send it to an external service (db, storage, etc.).
    • Just implement IBinStorage and call ->setBinStorage().

How to install

Setup the wkhtmltopdf binary required by SnappyPDFRenderer

The default SnappyPDFRenderer requires a wkhtmltopdf binary to work, there are several options to configure it:

Option 1: Download it yourself

Just download an adequate binary for your system and copy it to your ./vendor/bin folder. Or put it anywhere and give the absolute path to the constructor.

Option 2: Use the post-install-cmd

In your composer.json file, add this snipped under the "scripts" section:

Then run composer install. This will attempt to download the appropriate binary depending on your system. Currently, the only supported ones are:

If your system is not in the above list, you can still run your composer install like this:

PDF_SERVICE_URL=<url-to-wkhtmltopdf-binary> composer install

Where <url-to-wkhtmltopdf-binary> can be either a URL to download the binary or an absolute path to a wkhtmltopdf file in your local machine.

How to use

Create and save a template somewhere:

My-Raw-Template.php

Create and configure an instance of PDFREndererService:

Call the renderPDF method and get the results:

In this case, the results will be the PDF data returned as a string, which you can either store somewhere or return to the user.

To make the service generate a file, all you need to do is to set a bin storage, to do so, before calling the render method, just call setBinStorage:

This will save the PDF in the given directory and return the file name.

The name will be generated by joining the template name, the md5 hash of the resulting pdf and the time, like this:

{templateName}-{dataMD5}-{time()}.pdf

Example:

My-Raw-Template.php-2de85b56ded9694eb5100349480d980b-1550007643.pdf

To change that behavior, just send a callable as the second parameter of the storage constructor:

TODO: Send some extra info in the $request class?


All versions of pdf-service with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
knplabs/knp-snappy Version ^1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jeydotc/pdf-service contains the following files

Loading the files please wait ....