wyzen-packages/htmltopdf

HTML to PDF API caller

v2.0.0 2022-09-28 15:48 UTC

This package is auto-updated.

Last update: 2024-10-28 20:34:36 UTC


README

Librairie pour l'utilisation du service HTMLtoPDF Wyzen

 Required

Nécessite le service htmlToPdf Wyzen

Import

composer require wyzen-packages/htmltopdf

Options

from URL or HTML

  • depuis une source HTML ou HTML64
      $options = [
              "html" => "<h2>PDF from html code inline</h2>",
              //"html64" => "html encoded base64"
      ]
    
  • depuis une source URL
      $options = [
              "url" => "https://www.google.com",
      ]
    

common

    $options = [
            "options" => [
                "common" => [
                    "javascript-delay" => 1000,
                    "no-stop-slow-scripts" => true
                ],
            ],
        ];

pdf

    $options = [
            "options" => [
                "pdf" => [
                    "orientation" => "Portrait",
                    "header-center" => "My header",
                    "footer-center" => "My footer",
                ],
            ],
        ];

image

    $options = [
            "options" => [
                "image" => [
                    "format" => "png",
                    "width" => 800,
                    "height" => 600,
                ],
            ],
        ];

usage

use Wyzen\HtmlToPdf;

// Set URL
$htmlToPdf = new HtmlToPdf($_ENV['HTMLTOPDF_URL']);

// Set Auth
$htmlToPdf->setAuth($_ENV['HTMLTOPDF_ACCOUNT'], $_ENV['HTMLTOPDF_KEY']);

// Get HTML Help
$html = $htmlToPdf->getHelp();

// Get PDF response
$response = $htmlToPdf->toPdf($options)->getResponse();

// Get PDF content
$response = $htmlToPdf->toPdf($options)->getContent();

// Get Image response
$response = $htmlToPdf->toImage($options)->getResponse();

// Get Image content
$response = $htmlToPdf->toImage($options)->getContent();