PHP code example of machinateur / the-printer

1. Go to this page and download the library: Download machinateur/the-printer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

machinateur / the-printer example snippets


$configuration = new \Machinateur\ThePrinter\Configuration\DocumentConfiguration();
$configuration->setPageFormat('A5');

$content = '<!-- The HTML document content goes here. -->';

$outputBuffer = \fopen('php://output', 'w', false, null);

$client = new \Machinateur\ThePrinter\Client('http://127.0.0.1:3000/', 10);

\header(\sprintf('%s: %s', 'Content-Type', 'application/pdf'), true, 200);

$client->document($configuration, $content, $outputBuffer);

$configuration = new \Machinateur\ThePrinter\Configuration\ImageConfiguration();
$configuration->setCapturePage(true);

$content = '<!-- The HTML document content goes here. -->';

$outputBuffer = \fopen('php://output', 'w', false, null);

$client = new \Machinateur\ThePrinter\Client('http://127.0.0.1:3000/', 10);

\header(\sprintf('%s: %s', 'Content-Type', 'image/png'), true, 200);

$client->image($configuration, $content, $outputBuffer);