PDFGate's PHP SDK

PdfGateClient
in package

PDFGate API client.

Tags
phpstan-import-type

GeneratePdfRequestPayload from \PdfGate\Type\Types

UploadFileRequestPayload from \PdfGate\Type\Types

FlattenPdfRequestPayload from \PdfGate\Type\Types

CompressPdfRequestPayload from \PdfGate\Type\Types

ProtectPdfRequestPayload from \PdfGate\Type\Types

WatermarkPdfRequestPayload from \PdfGate\Type\Types

ExtractPdfFormDataRequestPayload from \PdfGate\Type\Types

GetDocumentQueryPayload from \PdfGate\Type\Types

CreateEnvelopeRequestPayload from \PdfGate\Type\Types

CreateEmbedLinkRequestPayload from \PdfGate\Type\Types

CreateRecipientRequestPayload from \PdfGate\Type\Types

UpdateRecipientRequestPayload from \PdfGate\Type\Types

AddFormFieldsRequestPayload from \PdfGate\Type\Types

CreateWebhookRequestPayload from \PdfGate\Type\Types

Table of Contents

Constants

PROD_BASE_URL  : mixed = 'https://api.pdfgate.com'
SANDBOX_BASE_URL  : mixed = 'https://api-sandbox.pdfgate.com'

Properties

$requestHandler  : ApiRequestHandler

Methods

__construct()  : mixed
addFormFields()  : PdfGateDocumentMetadata
Adds interactive form fields to an existing PDF document.
compressPdf()  : PdfGateDocumentMetadata
Compresses an existing PDF document.
createEmbedLink()  : EmbedLinkResponse
Creates a short-lived signing link for an embedded recipient.
createEnvelope()  : PdfGateEnvelope
Creates a signing envelope from existing source documents.
createRecipient()  : PdfGateRecipient
Stores a recipient so envelopes can reference them by recipientId.
createWebhook()  : WebhookResponse
Registers a webhook endpoint to receive PDFGate event notifications.
deleteDocument()  : void
Permanently deletes a stored document.
deleteEnvelope()  : void
Permanently deletes an envelope and the files it produced.
deleteRecipient()  : void
Deletes a stored recipient.
deleteWebhook()  : void
Deletes a registered webhook.
extractPdfFormData()  : array<string, mixed>
Extracts PDF form fields and values for an existing document.
flattenPdf()  : PdfGateDocumentMetadata
Flattens an existing PDF document.
generatePdf()  : PdfGateDocumentMetadata
Generates a PDF from HTML or URL.
getDocument()  : PdfGateDocumentMetadata
Retrieves metadata and file details for an existing document.
getEnvelope()  : PdfGateEnvelope
Retrieves the current state of an existing envelope.
getFile()  : resource
Retrieves a generated PDF file as a readable stream resource.
getRecipient()  : PdfGateRecipient
Retrieves a stored recipient by ID.
getWebhook()  : WebhookResponse
Retrieves a registered webhook by ID.
listRecipients()  : array<int, PdfGateRecipient>
Lists stored recipients with the given email, oldest first.
protectPdf()  : PdfGateDocumentMetadata
Protects an existing PDF document with encryption and permission restrictions.
removeRecipientSignature()  : PdfGateRecipient
Automatic signing: removes the stored signature of a recipient, or cancels a pending enrolment.
requestRecipientSignature()  : PdfGateRecipient
Automatic signing: emails the recipient a link to store a reusable signature.
sendEnvelope()  : PdfGateEnvelope
Sends an existing envelope to all configured recipients.
updateRecipient()  : PdfGateRecipient
Updates a stored recipient's name or metadata.
uploadFile()  : PdfGateDocumentMetadata
Uploads a raw PDF file or URL source.
voidEnvelope()  : PdfGateEnvelope
Voids (cancels) an envelope in created or in_progress status.
watermarkPdf()  : PdfGateDocumentMetadata
Adds a text or image watermark to an existing PDF document.
buildEnvelopeResponse()  : PdfGateEnvelope
createRequestHandler()  : ApiRequestHandler
resolveBaseUrl()  : string

Constants

PROD_BASE_URL

private mixed PROD_BASE_URL = 'https://api.pdfgate.com'

SANDBOX_BASE_URL

private mixed SANDBOX_BASE_URL = 'https://api-sandbox.pdfgate.com'

Properties

Methods

__construct()

public __construct(string $apiKey) : mixed
Parameters
$apiKey : string

PDFGate API key.

Creates a short-lived signing link for an embedded recipient.

public createEmbedLink(string $envelopeId, CreateEmbedLinkRequestPayload $request) : EmbedLinkResponse

Render the returned URL in an iframe inside your application. The envelope must be in in_progress status and the link expires after 10 minutes, so create it when the signer is ready (one link per signing session). When the session ends the iframe redirects to returnUrl with event (signing_complete, voided, expired or not_found), envelopeId, documentId and recipientId appended as query parameters; existing returnUrl query parameters are preserved. On documents with a signingOrder the link can only be created once it is the recipient's turn (the API returns an error before that); the envelope.recipient.activated webhook signals that moment.

Parameters
$envelopeId : string

Existing envelope ID.

$request : CreateEmbedLinkRequestPayload

Create embed link request payload.

Return values
EmbedLinkResponse

createEnvelope()

Creates a signing envelope from existing source documents.

public createEnvelope(CreateEnvelopeRequestPayload $request) : PdfGateEnvelope

Each recipient is given either as email and name or as the recipientId of a stored recipient. Recipients marked embedded sign inside your own application via createEmbedLink() and receive no emails from PDFGate.

signingOrder is the signing order of the recipient, starting from 1. Recipients sign one after another in this order and a recipient is activated once everyone with a lower value has signed. Recipients with the same value can sign in parallel. Provide it for every recipient of a document or for none. Omitted, all recipients can sign immediately.

autoSign applies the stored signature of the referenced recipient on their behalf when their turn to sign comes, with no signing session or email. Requires recipientId pointing to a recipient with an active stored signature (see requestRecipientSignature()) and cannot be combined with embedded. Every required field of the recipient must already have a value before the document is sent, except signature and auto-filled date fields. If the stored signature is removed before the turn comes, a signing link is emailed instead. The audit log records the automatic signature with the enrolment details.

sendSignedCopy controls whether the recipient is emailed the signed document when the document completes. Defaults to true for recipients who sign through the emailed signing link and false for embedded and automatic signing recipients.

Parameters
$request : CreateEnvelopeRequestPayload

Create envelope request payload.

Return values
PdfGateEnvelope

createRecipient()

Stores a recipient so envelopes can reference them by recipientId.

public createRecipient(CreateRecipientRequestPayload $request) : PdfGateRecipient

The email is stored lowercased and cannot be changed later. Emails are not unique; every call creates a new recipient, so list existing recipients first when reuse is intended.

Parameters
$request : CreateRecipientRequestPayload

Create recipient request payload.

Return values
PdfGateRecipient

createWebhook()

Registers a webhook endpoint to receive PDFGate event notifications.

public createWebhook(CreateWebhookRequestPayload $request) : WebhookResponse

The response includes a secret (returned only once, at creation time) used to verify webhook payloads via the webhook signature verifier.

Parameters
$request : CreateWebhookRequestPayload

Create webhook request payload.

Return values
WebhookResponse

deleteDocument()

Permanently deletes a stored document.

public deleteDocument(string $documentId) : void

A document referenced by a draft or in-progress envelope cannot be deleted until those envelopes are completed or expired.

Parameters
$documentId : string

Existing document ID.

deleteEnvelope()

Permanently deletes an envelope and the files it produced.

public deleteEnvelope(string $envelopeId) : void

The signed documents and audit logs are removed from storage, recipient data is anonymized, and recipients lose access. Source documents are not deleted. Only envelopes in draft, completed, expired, or voided status can be deleted; void an active envelope first. This action cannot be undone.

Parameters
$envelopeId : string

Existing envelope ID.

deleteRecipient()

Deletes a stored recipient.

public deleteRecipient(string $recipientId) : void

The record is kept with its personal data removed, so later reads return 404 and a new envelope to the same address creates a fresh recipient. Envelopes already sent are not affected. A recipient with an active stored signature or a pending enrolment cannot be deleted: call removeRecipientSignature() first.

Parameters
$recipientId : string

Existing recipient ID.

deleteWebhook()

Deletes a registered webhook.

public deleteWebhook(string $webhookId) : void
Parameters
$webhookId : string

Existing webhook ID.

extractPdfFormData()

Extracts PDF form fields and values for an existing document.

public extractPdfFormData(ExtractPdfFormDataRequestPayload $request) : array<string, mixed>
Parameters
$request : ExtractPdfFormDataRequestPayload

Extract PDF form data request payload.

Return values
array<string, mixed>

getDocument()

Retrieves metadata and file details for an existing document.

public getDocument(string $documentId[, GetDocumentQueryPayload $query = array() ]) : PdfGateDocumentMetadata
Parameters
$documentId : string

Existing document ID.

$query : GetDocumentQueryPayload = array()

Optional get-document query options.

Return values
PdfGateDocumentMetadata

getFile()

Retrieves a generated PDF file as a readable stream resource.

public getFile(string $documentId) : resource
Parameters
$documentId : string

Generated document identifier.

Return values
resource

getWebhook()

Retrieves a registered webhook by ID.

public getWebhook(string $webhookId) : WebhookResponse

The secret is not returned by this endpoint (only at creation time).

Parameters
$webhookId : string

Existing webhook ID.

Return values
WebhookResponse

listRecipients()

Lists stored recipients with the given email, oldest first.

public listRecipients(string $email) : array<int, PdfGateRecipient>
Parameters
$email : string

Email to look up (case-insensitive).

Return values
array<int, PdfGateRecipient>

removeRecipientSignature()

Automatic signing: removes the stored signature of a recipient, or cancels a pending enrolment.

public removeRecipientSignature(string $recipientId) : PdfGateRecipient

Envelopes already waiting on an automatic signature fall back to a signing link emailed to the recipient. Removing an active signature fires the recipient.signature.revoked webhook. Idempotent: a recipient without a stored signature is returned unchanged.

Parameters
$recipientId : string

Existing recipient ID.

Return values
PdfGateRecipient

requestRecipientSignature()

Automatic signing: emails the recipient a link to store a reusable signature.

public requestRecipientSignature(string $recipientId) : PdfGateRecipient

The recipient verifies their email with a one-time code, accepts the authorization text and types, draws or uploads their signature. The link is valid for 7 days; calling this again replaces a pending request. Once the enrolment is complete the recipient.signature.enrolled webhook fires and envelopes can set autoSign on this recipient. Rejected when the recipient has no email or already has an active stored signature.

Parameters
$recipientId : string

Existing recipient ID.

Return values
PdfGateRecipient —

The recipient with signature status pending.

sendEnvelope()

Sends an existing envelope to all configured recipients.

public sendEnvelope(string $envelopeId) : PdfGateEnvelope

Embedded recipients receive no email; create their signing links with createEmbedLink() after sending. On documents with a signingOrder only the first recipients are emailed; later recipients are activated as earlier ones sign.

Parameters
$envelopeId : string

Existing envelope ID.

Return values
PdfGateEnvelope

updateRecipient()

Updates a stored recipient's name or metadata.

public updateRecipient(string $recipientId, UpdateRecipientRequestPayload $request) : PdfGateRecipient

The email cannot be changed. Existing envelopes are not affected; they keep the recipient name they were created with.

Parameters
$recipientId : string

Existing recipient ID.

$request : UpdateRecipientRequestPayload

Update recipient request payload.

Return values
PdfGateRecipient

voidEnvelope()

Voids (cancels) an envelope in created or in_progress status.

public voidEnvelope(string $envelopeId[, string|null $reason = null ]) : PdfGateEnvelope

Recipients who have not signed yet are notified by email and their signing links stop working; documents already signed by all recipients are not affected. The optional reason (max 500 characters) is visible to recipients: it is included in the cancellation email. This action cannot be undone.

Parameters
$envelopeId : string

Existing envelope ID.

$reason : string|null = null

Optional reason, visible to recipients.

Return values
PdfGateEnvelope

resolveBaseUrl()

private resolveBaseUrl(string $apiKey) : string
Parameters
$apiKey : string
Return values
string
On this page

Search results