Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.
/ php-sdk Public archive

pfgapi.io PHP SDK library. Easy way to integrate phpapi.io into your project

Notifications You must be signed in to change notification settings

pdfapi/php-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status

pdfapi.io SDK for PHP

Installation

pdfapi.io PHP SDK can be installed with Composer. Run this command:

composer require pdfapi/php-sdk

Usage

Usage of pdfapi.io PHP SDK is very simple. The easyest way to get started is:

use PdfApi\PdfApi;

$template = <<<HTML
<!DOCTYPE html>
<html>
    <body>
        <h1>pdfapi.io makes PDF generation so easy.</h1>
        <p>And it can do complicated stuff.</p>
    </body>
</html>
HTML;

$pdfApi = new PdfApi('YOUR_API_KEY');
$pdfApi->setHtml($template);

$rawPdf = $pdfApi->generate();

Full example of the usage: Note: Be aware that header and footer are separate HTML documents (with styles and everything) that are copied to each page.

use PdfApi\PdfApi;
use PdfApi\Parameter\Enum\Orientation;
use PdfApi\Parameter\Enum\Size;

$template = <<<HTML
<!DOCTYPE html>
<html>
    <body>
        <h1>pdfapi.io makes PDF generation so easy.</h1>
        <p>And it can do complicated stuff.</p>
    </body>
</html>
HTML;

$header = <<<HTML
<!DOCTYPE html>
<html>
  <body>
      <p>pdfapi.io</p>
  </body>
</html>
HTML;

$footer = <<<HTML
<!DOCTYPE html>
<html>
  <body>
      <p>pdfapi.io</p>
  </body>
</html>
HTML;


$pdfApi = new PdfApi('YOUR_API_KEY');
$pdfApi->setHtml($template);
$pdfApi->setHeader($header);
$pdfApi->setFooter($footer);
$pdfApi->setSize(Size::A4);
$pdfApi->setOrientation(Orientation::Landscape);

$rawPdf = $pdfApi->generate();

//or optionally you can save PDF directly to file
$pdfApi->save('/path/to/file.pdf');

For getting API KEY you need to register account at https://pdfapi.io. Generating API KEY will take you 10 seconds. And it is free. Really.

About

pfgapi.io PHP SDK library. Easy way to integrate phpapi.io into your project

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages