<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
setasign / seta-pdf-signer-addon-global-sign-dss example snippets
$options = [
'http_errors' => false, // recommended for guzzle - because of PSR-18
'cert' => 'path/to/tls-cert.pem',
'ssl_key' => 'path/to/private/key.pem'
];
$apiKey = 'xxxxxxxxxxxxxxxx';
$apiSecret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$httpClient = new GuzzleHttp\Client($options);
// if you are using php 7.0 or 7.1
//$httpClient = new Mjelamanov\GuzzlePsr18\Client($httpClient);
$requestFactory = new Http\Factory\Guzzle\RequestFactory();
$streamFactory = new Http\Factory\Guzzle\StreamFactory();
$client = new Dss\Client($httpClient, $requestFactory, $streamFactory, $apiKey, $apiSecret);
$remainingSignatures = $client->getQuota(Dss\Client::TYPE_SIGNATURES);
// or
$signaturesCount = $client->getCount(Dss\Client::TYPE_SIGNATURES);
// set up the client and identity
$options = [
'http_errors' => false,
'cert' => 'path/to/tls-cert.pem',
'ssl_key' => 'path/to/private/key.pem'
];
$apiKey = 'xxxxxxxxxxxxxxxx';
$apiSecret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$httpClient = new GuzzleHttp\Client($options);
// if you are using php 7.0 or 7.1
//$httpClient = new Mjelamanov\GuzzlePsr18\Client($httpClient);
$requestFactory = new Http\Factory\Guzzle\RequestFactory();
$streamFactory = new Http\Factory\Guzzle\StreamFactory();
$client = new Dss\Client($httpClient, $requestFactory, $streamFactory, $apiKey, $apiSecret);
$identity = $client->getIdentity();
// now start the signature process
$writer = new \SetaPDF_Core_Writer_File('signed.pdf');
$document = \SetaPDF_Core_Document::loadByFilename('invoice.pdf', $writer);
$signer = new \SetaPDF_Signer($document);
$signer->setSignatureContentLength(15000);
$pades = new \SetaPDF_Signer_Signature_Module_Pades();
$module = new Dss\SignatureModule($signer, $client, $identity, $pades);
$signer->sign($module);