1. Go to this page and download the library: Download pdfgate/pdfgate-sdk-php 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/ */
use PdfGate\Enum\EnvelopeStatus;
$sentEnvelope = $client->sendEnvelope('69c0fa44f83ca6a7015f1c8c');
if ($sentEnvelope->getStatus() === EnvelopeStatus::IN_PROGRESS) {
echo 'Envelope emails have been sent.';
}
use PdfGate\Enum\EnvelopeStatus;
$envelope = $client->getEnvelope('69c0fa44f83ca6a7015f1c8c');
if ($envelope->getStatus() === EnvelopeStatus::IN_PROGRESS) {
echo 'Envelope is still awaiting signatures.';
}
use PdfGate\Enum\EnvelopeStatus;
$voided = $client->voidEnvelope('69c0fa44f83ca6a7015f1c8c', 'Contract terms changed');
if ($voided->getStatus() === EnvelopeStatus::VOIDED) {
echo 'Envelope has been voided.';
}
// Email is stored lowercased and cannot be changed later.
$recipient = $client->createRecipient([
'email' => '[email protected]',
'name' => 'Anna Smith',
'metadata' => ['customerId' => 'cus_123'],
]);
// Case-insensitive lookup, oldest first.
$recipients = $client->listRecipients('[email protected]');
$fetched = $client->getRecipient($recipient->getId());
// Updates do not affect existing envelopes; they keep the recipient
// name they were created with.
$updated = $client->updateRecipient($recipient->getId(), [
'name' => 'Anna Jones',
]);
// Removes the recipient's personal data from the directory; envelopes
// already sent are not affected. A recipient with an active stored
// signature or a pending enrolment cannot be deleted until the signature
// is removed (see Automatic Signing).
$client->deleteRecipient($recipient->getId());
use PdfGate\Enum\StoredSignatureStatus;
$pending = $client->requestRecipientSignature($recipient->getId());
echo $pending->getSignature()->getStatus(); // "pending"
// Once the recipient completes the enrolment (webhook event
// `recipient.signature.enrolled`), the signature is active.
$enrolled = $client->getRecipient($recipient->getId());
$signature = $enrolled->getSignature();
if ($signature !== null && $signature->getStatus() === StoredSignatureStatus::ACTIVE) {
echo $signature->getImage(); // PNG data URL
}
// Sign automatically: the recipient is signed at send, or when their turn
// in the signing order comes. No signing email is sent.
$envelope = $client->createEnvelope([
'requesterName' => 'HR',
'documents' => [
[
'sourceDocumentId' => '6642381c5c61',
'name' => 'Employment Agreement',
'recipients' => [
[
'email' => '[email protected]',
'name' => 'Anna Smith',
'role' => 'employee',
'signingOrder' => 1,
],
[
'recipientId' => $recipient->getId(),
'role' => 'ceo',
'signingOrder' => 2,
'autoSign' => true,
],
],
],
],
]);
// Remove the stored signature or cancel a pending enrolment.
$client->removeRecipientSignature($recipient->getId());
use PdfGate\Enum\DocumentFieldType;
$doc = $client->addFormFields([
'documentId' => $documentId,
// Customize placeholder fields detected in the PDF, keyed by field name.
'fieldOverrides' => [
'signature' => ['role' => 'signer', 'optional' => false],
],
// Or place fields at explicit positions on a given page.
'fields' => [
[
'name' => 'signed_on',
'type' => DocumentFieldType::DATE,
'page' => 1,
'x' => 100,
'y' => 650,
'width' => 160,
'height' => 24,
],
],
]);
$flattened = $client->flattenPdf([
'documentId' => $documentId,
// Omit fieldNames to flatten the whole document.
'fieldNames' => ['signature', 'date'],
]);
$client->deleteDocument($documentId);
use PdfGate\Enum\WebhookEventType;
// The returned secret is shown only once — store it to verify payloads.
$webhook = $client->createWebhook([
'url' => 'https://example.com/pdfgate-callback',
'eventTypes' => [
WebhookEventType::ENVELOPE_COMPLETED,
WebhookEventType::ENVELOPE_SENT,
],
'description' => 'Production signing events',
]);
$fetched = $client->getWebhook($webhook->getId());
$client->deleteWebhook($webhook->getId());