Download the PHP package statikbe/laravel-puppeteer-pdf-converter without Composer

On this page you can find all versions of the php package statikbe/laravel-puppeteer-pdf-converter. 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 laravel-puppeteer-pdf-converter

Laravel Puppeteer PDF Converter

Latest Version on Packagist Total Downloads

This is a convenience wrapper for a service that converts an HTML page to PDF. The service uses Puppeteer.js and is developed in-house at Statik. The code for the service is not yet open-sourced, but can be shared upon request.

Installation

You can install the package via composer:

You can publish the config file with:

This is the contents of the published config file:

Configuration

Required: You need to set the url to the API in the .env with key PDF_CONVERSION_API.

Optional: The other configuration is optional. You can set default Puppeteer configuration, such as paper margins, scaling and paper width and height. The paper width and height defaults to A4. More information on possible Puppeteer configuration is available in the Puppeteer docs.

You can also manually set the PDF configuration when you create the PDF, see below. However, it is important to note that the default configuration set in the config file, is always taken as the basis and is overridden by the manual options in code. If a value is set to null in the config file or manual options, the option will not be send to the service (i.e. the option is disabled).

Usage

The library allows to convert an HTML page to a PDF for a route name (use convertRoute()) or for a URL (use convertUrl()).

If you want to override the PDF options that are set in the configuration file, you can create a PdfOptions object.

The following exceptions can occur:

Temporary URLs

The library can generate temporary signed URLs. This is handy if you need to generate PDFs from routes that require authorisation. The PDF service cannot login to your application. But by using temporarily signed URLs, we can validate that the application has generated the URL and no one has tempered with it.

You need to check in the controller of the HTML page whether the signature of the URL is valid. See section Local development for an example.

Local development

The PDF conversion service runs in the cloud. For local development, you can run it locally or use a tunneling service to expose your local web server. Examples of such tunneling software is Ngrok or Expose. Or if you use Valet, there is a sharing command

If you use Ngrok, you can start the service (replace APP_URL with the value of the APP_URL key in your .env file):

You can then configure the tunneled URL in the .env file with key NGROK_APP_URL. You can also set URLs of Valet or Expose in this variable. For example:

In case you use temporary signed URLs, there is a convenience function to check if a local tunnel is configured (i.e. whether the NGROK_APP_URL is set and the environment is set to local).

This can be used to bypass the valid signature check in your controller. Because the NGROK_APP_URL will be replaced in the generated URL, the signature will not be valid, hence we need to bypass the $request->hasValidSignature() check.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

You can use the Github issue tracker and pull requests are welcome!

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-puppeteer-pdf-converter with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0|^8.1|^8.2
spatie/laravel-package-tools Version ^1.9.2
illuminate/contracts Version ^8.0|^9.0|^10.0|^11.0
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 statikbe/laravel-puppeteer-pdf-converter contains the following files

Loading the files please wait ....