PHP code example of risscsolutions / printformer-php-sdk

1. Go to this page and download the library: Download risscsolutions/printformer-php-sdk 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/ */

    

risscsolutions / printformer-php-sdk example snippets


use Rissc\Printformer;

$config = [
    'base_uri' => 'YOUR printformer URL',
    'identifier' => 'YOUR TENANT IDENTIFIER',
    'api_key' => 'YOUR TENANT API KEY',
];

$printformer = new Printformer($config);

$pfUser = $this->printformer->clientFactory()->user()->create([
    'first_name' => 'John',
    'last_name' => 'Doe',
    'locale' => 'en',
    'email' => '[email protected]', 
]);

$draftClient = $printformer->clientFactory()->draft();
$draft = $draftClient
    ->create([
        'templateIdentifier' => 'YOUR MASTER TEMPLATE IDENTIFIER',
        'user_identifier' => $pfUser->getIdentifier(),
        'intent' => 'customize'
    ]);

$draftBuilder = $printformer->builderFactory()->draft();
$draft = $draftBuilder
    ->template('YOUR MASTER TEMPLATE IDENTIFIER')
    ->user($pfUser->getIdentifier())
    ->intent('customize')
    ->create();

$url = (string)$printformer->urlGenerator()->editor()
        ->draft($draft->getIdentifier())
        ->callback('https://YOUR-CALLBACK-URL-HERE')
        ->callbackCancel('https://YOUR-CANCEL-CALLBACK-URL-HERE') // Optional, if omitted the callback URL is used
        ->callbackHalt('https://YOUR-HALT-CALLBACK-URL-HERE') // Optional, if omitted the callbackCancel URL is used
        ->user($pfUser->getIdentifier())
        ->step('preview') // Optional, if omitted the editor jumps to the last visited step

$printformer->clientFactory()->processing()->create(
    [$draft->getIdentifier(), $otherDraft->getIdentifier()],
    'https://YOUR-CALLBACK-URL-HERE'
);

(string)$printformer->urlGenerator()
->draftFiles()
->printFile($draft->getIdentifier())
->expiresAt((new \DateTimeImmutable())->modify('+1 hour'))

$draftClient = $printformer->clientFactory()->draft();
$draft = $draftClient
    ->replicate($draft, []);
bash
composer