Download the PHP package viavario/pdfgenerator without Composer

On this page you can find all versions of the php package viavario/pdfgenerator. 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 pdfgenerator

PDFGenerator

PDFGenerator allows you to easily generate PDF documents or PNG screenshots of any webpage using PHP.

In the past we have used PhantomJS, wkhtmltopdf and TCPDF to generate PDF's from a given URL or HTML. However, these libraries are no longer actively developed or maintained and lack support for newer features in HTML and CSS. Google Chrome has a built in feature to take a screenshot of a webpage as PDF or PNG format with better support for new features.

Using Amazon Lambda and Amazon API Gateway you can minimize running costs, have scalable performance and flexible security controls. Lambda is used to run a headless Chrome as an on-demand service to take screenshots from any website or submitted HTML content without having to set up a server. You can configure security controls on the API Gateway like API keys, rate limiting, and quota to protect your screenshot service against third parties or inappropriate use.

Puppeteer is used to communicate with Chrome to load content and take screenshots programmatically.

Requirements

To deploy Chrome on Amazon Lambda you will need:

  1. An Amazon AWS account to deploy the Lambda function
  2. Node.js installed on your local machine
  3. Serverless installed on your local machine

To use this library in PHP:

  1. Composer
  2. PHP 7+

Deploying Chrome on Amazon Lambda

  1. Go to the official Node.js website, download and follow the installation instructions to install Node.js on your local machine.

  2. Install the Serverless Framework via npm which was already installed when you installed Node.js.
    Open up a terminal and run the following command to install Serverless:

Next, you'll have to set up your credentials so that Serverless is able to connect to your Amazon AWS account to deploy the Lambda function and API Gateway. The easiest way is to create a new IAM user and attach a custom JSON policy to limit the Serverless Framework's access to your AWS account. This way you don't have to sign up for an account on https://serverless.com either.
To limit the Serverless Framework’s access your AWS account, follow these steps to create an IAM User and attach a custom JSON file policy to your new IAM User. This IAM User will have its own set of AWS Access Keys.

  1. Login to your AWS Account and go to the Identity & Access Management (IAM) page.
  2. Click on Users and then Add user. Enter a name in the first field to remind you this User is related to the Service you are deploying with the Serverless Framework, like serverless-servicename-agent1. Enable Programmatic access by clicking the checkbox. Click Next to go through to the Permissions page. Click on Create policy. Select the JSON tab, and add a JSON file. You can use this gist as a guide.
  3. When you are finished, select Review policy. You can assign this policy a Name and Description, then choose Create Policy. Check to make sure everything looks good and click Create user. Later, you can create different IAM Users for different apps and different stages of those apps. That is, if you don't use separate AWS accounts for stages/apps, which is most common.
  4. View and copy the API Key & Secret and replace <your-key-here> and <your-secret-key-here> in the command below and run the command:

  5. Navigate to the directory screenshot-service in this repository in your terminal window and install the required packages by running:

  6. Open screenshot-service/serverless.yml and change the region on line 10 to the region you wish to deploy to on Amazon AWS as well as the corresponding reference to the required Lambda layer on line 27. See https://github.com/shelfio/chrome-aws-lambda-layer and [https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints]{https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints} for more information about the available regions and corresponding references for the Lambda layer.

  7. Next, deploy the screenshot service to Amazon AWS:

  8. In the output of the command about you can find the endpoints for the GET and POST request.

If you haven't configured any API keys yet in the API Gateway for the screenshot service, you can simply copy the endpoint URL of the GET request, append ?filename=screenshot.png&url=[URL of your website] to the endpoint URL and open it in your browser.

Note that you have to set API Key Required to false for the /capture - GET -Method Request in the API to test this without API Keys:

  1. Go to Amazon API Gateway
  2. Open the API for the screenshot service
  3. Click on GET under /capture in the Resources panel
  4. Click on Method Request
  5. Click on the pencil icon next to API Key Required, change the setting from true to false, and click the check mark icon to save the setting.
  6. Click on the Actions button, and choose Deploy API from the menu to redeploy the API to test the GET-request without API Keys.

Make sure to set API Key Required to true after you have verified that the screenshot service works in order to prevent unauthorized use or access.

For example: https://##########.execute-api.eu-west-3.amazonaws.com/dev/capture?filename=screenshot.png&url=https://www.google.com/finance/quote/TSLA:NASDAQ?hl=en returns a screenshot of the Tesla stock on Google Finance:

Securing your screenshot service

To protect the screenshot service against unauthorized use or access you can set up API Keys for the API Gateway. If you do not set up API Keys for the screenshot service other people may be able to use your installation to create screenshots which will add to your bill. It is important that you secure your API Gateway.

Make sure to redeploy the API for the API Key requirement to take effect!

See https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-setup-api-key-with-console.html on how to set up API Keys.

Installation of this library

Usage

Methods

Name Description
__construct Class constructor.
displayHeaderFooter Display the footer and header template.
generate Generate a screenshot.
omitBackground Hides default white background and allows capturing screenshots with transparency. Defaults to false.
preferCSSPageSize Give any CSS @page size declared in the page priority over what is declared in width and height or format options. Defaults to false, which will scale the content to fit the paper size.
printBackground Set to true to print backgrounds.
setContent Sets the content.
setFilename Sets the filename.
setFooterTemplate Sets the Footer template.
setFormat Sets the format of the page.
setHeaderTemplate Sets the Header template.
setHttpAuthentication Sets the HTTPAuthentication username and password.
setMargins Sets the margins for the page.
setOrientation Set the page orientation.
setURL Set the URL.
setViewportSize Sets the viewport height and viewport width.

PDFGenerator::__construct

Description

Class constructor.

Parameters

Return Values

void


PDFGenerator::displayHeaderFooter

Description

Display the footer and header template.

Parameters

Return Values

PDFGenerator


PDFGenerator::generate

Description

Generate a screenshot.

Parameters

Return Values

mixed

If no filename is specified, then the generated file is returned as binary data.
If a filename is specified, then true is returned when the file was written
successfully, or false otherwise.


PDFGenerator::omitBackground

Description

Hides default white background and allows capturing screenshots with transparency. Defaults to false.

Parameters

Return Values

PDFGenerator


PDFGenerator::preferCSSPageSize

Description

Give any CSS @page size declared in the page priority over what is declared in width and height or format options. Defaults to false, which will scale the content to fit the paper size.

Parameters

Return Values

PDFGenerator


PDFGenerator::printBackground

Description

Set to true to print backgrounds.

Parameters

Return Values

PDFGenerator


PDFGenerator::setContent

Description

Sets the content.

Parameters

Return Values

PDFGenerator


PDFGenerator::setFilename

Description

Sets the filename.

Parameters

Return Values

PDFGenerator


PDFGenerator::setFooterTemplate

Description

Sets the Footer template.

Should be valid HTML markup with following classes used to inject printing values into them:

Parameters

Return Values

PDFGenerator


PDFGenerator::setFormat

Description

Sets the format of the page.

The format options are:

Parameters

This function has no parameters.

Return Values

PDFGenerator


PDFGenerator::setHeaderTemplate

Description

Sets the Header template.

Should be valid HTML markup with following classes used to inject printing values into them:

Parameters

Return Values

PDFGenerator


PDFGenerator::setHttpAuthentication

Description

Sets the HTTPAuthentication username and password.

Parameters

This function has no parameters.

Return Values

PDFGenerator


PDFGenerator::setMargins

Description

Sets the margins for the page.

Parameters

Return Values

PDFGenerator

return this instance


PDFGenerator::setOrientation

Description

Set the page orientation.

Parameters

Return Values

PDFGenerator


PDFGenerator::setURL

Description

Set the URL.

Parameters

Return Values

PDFGenerator


PDFGenerator::setViewportSize

Description

Sets the viewport height and viewport width.

Parameters

This function has no parameters.

Return Values

PDFGenerator



All versions of pdfgenerator with dependencies

PHP Build Version
Package Version
Requires guzzlehttp/guzzle Version 7.7.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 viavario/pdfgenerator contains the following files

Loading the files please wait ....