PHP code example of ambersive / pdfprinter

1. Go to this page and download the library: Download ambersive/pdfprinter 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/ */

    

ambersive / pdfprinter example snippets


// Setup the pdf printer
$printer  = new PdfPrinter($settings);
$printer->create("http://localhost:8080/pdf")->save("folder");

// Setup the pdf printer
$settings = new PdfPrinterSetting("http://localhost", 3000);
$printer  = new PdfPrinter($settings);
$options  = new PdfPrinterOption(
    $filename, 
    $postBackUrl,
    [], //$postBackBody 
    "" // $token
);

// Set auth header for basic authentication
$username = "test";
$password = "asdf";
$printer->authBasic($username, $password);

// Set auth header for basic authentication
$printer->authBearer("CUSTOM OR JWT TOKEN");

$printer->create("http://127.0.0.1:8000", null, function($instance, $result, $options, $successful) {
    // Will be executed after print execution
})->save('test', null, function($instance, $result, $filename, $path, $successful){
    // Do stuff after storing (even called if store was not successful)
});