Sign PDF
Audience:
Low-code EngineersSkill Prerequisites:
Actions,Forms,JavaScript,Tokens
Signs a PDF with the user's electronic signature token, using the PDF AutoSigner app on the user's computer. The signed PDF is put in a file upload field on the form, which uploads it back to the site.
The signing happens on the user's computer, not on the server. The server only prepares the request. The user's browser downloads the PDF, sends it to the PDF AutoSigner app at http://localhost:7521, and receives the signed file. The certificate never leaves the user's computer.
The action is available in forms.
The action comes from the PDF AutoSigner integration package (PlantAnApp.Integrations.PdfAutoSigner). If you don't see it, the package isn't installed. Each user who signs also needs the PDF AutoSigner app installed and running on their own computer, with their signing token connected.
Typical Use Cases
- Let an employee sign a generated contract or report with their signature token
- Sign a document and keep the signed copy in a file upload field, then save it with the rest of the form
Don't use it to
- Sign files on the server or in a workflow. The action runs in the user's browser and needs the user's computer.
- Check whether a file is signed. Use Check PDF Signature instead.
- Run more actions right after signing. The action ends execution, and the signing finishes later in the browser. Use
On Signing Resultinstead.
Related Actions
| Action Name | Description |
|---|---|
| Check if PDF Auto Signer is running | Checks whether the PDF AutoSigner app is reachable from the user's browser. |
| Check PDF Signature | Checks whether a PDF has an electronic signature. |
| Generate PDF | Creates the PDF to sign from an HTML template. |
| Merge PDF | Combines several PDFs into one before signing. |
What you need on the form
| Field | Purpose |
|---|---|
| AutoSigner Signature Dropdown | Lets the user pick a signature. When the form loads, the field asks the PDF AutoSigner app for the signatures available on the computer. If the app can't be reached, the list shows one entry starting with error:. |
| Text or Password field | The PIN of the signing token. A Password field is the better choice. |
| Single File Upload or Multi File Upload | Receives the signed file. It's uploaded using the field's own settings, such as its upload folder. |
| A button | Runs the Sign PDF action. |
Input Parameter Reference
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| Signature Field | The AutoSigner Signature Dropdown field that holds the selected signature. Its value is sent to the app as the signature name. | No | none selected | Yes |
| Pin Field | The Text or Password field that holds the token's PIN. | No | none selected | Yes |
| File to sign | The PDF to sign. It can be a file ID, a path relative to the site's home folder, such as Contracts/contract-1001.pdf, or a physical path inside the site's home folder. URLs aren't supported. | Yes | empty string | Yes |
| Signed PDF file name | The name of the signed file, for example contract-[OrderId]-signed.pdf. If it's empty, the name is signed.pdf. If it doesn't end in .pdf, .pdf is added. | Yes | empty string | No |
| Upload Field | The Single File Upload or Multi File Upload field that receives the signed file. | No | none selected | Yes |
| On Signing Result | Optional JavaScript that runs in the browser when signing finishes or fails. It gets a result object, described below. Tokens are replaced on the server before the code is sent. In a form, fields are available as form.fields.<FieldName>.value. | Yes | empty string | No |
The result object
On Signing Result receives a result object. Check result.success first.
| Property | Description |
|---|---|
success | true if the file was signed and added to the upload field, otherwise false. |
errorCode | 0 on success. See the table below for errors. |
signedFileName | On success, the name of the signed file. |
errorDetail | On error, a short description. |
rawError | On error, the original error from the browser or the app. |
errorCode | errorDetail | Meaning |
|---|---|---|
1 | Failed to retrieve PDF file from site to be signed. | The browser couldn't download the PDF, for example because the user doesn't have access to it. |
2 | The AutoSigner application failed to sign the PDF. | The app isn't running, or it refused to sign, for example because of a wrong PIN or a missing token. |
3 | Failed to process signed file for upload back to the site. | The signed file couldn't be added to the upload field, for example because Upload Field is wrong. |
How it works
- The server finds the file and turns it into a URL. If the file doesn't exist, the action fails with an error such as
File with id 123 does not exist.orFile with path ... does not exist on portal #0.A path outside the site's home folder fails withInvalid file path provided. - The action ends execution and sends code to the browser. No actions after it run.
- The browser downloads the PDF and posts it to
http://localhost:7521/api/sign, together with the PIN and the signature name. - The PDF AutoSigner app signs the file and returns it.
- The browser adds the signed file to the upload field, which uploads it to the site.
On Signing Resultruns with the result.
The app decides how the signature looks and where it goes. The action has no settings for placement, reason, or location.
Considerations
- Handle the result. Without
On Signing Result, the user gets no message when signing fails. Errors are only written to the browser console. - Submit afterwards. The signed file is only uploaded to the field. To save it or process it on the server, the form still has to be submitted, either by the user or from
On Signing Result. - The PIN goes through the server. The PIN field's value is sent to the server with the button click and returned to the browser for the app. Don't save the PIN field in reports, and use HTTPS.
- Signing is asynchronous. The action returns before the signing is done. Code in
On Signing Resultis the only place that knows the outcome. - Errors in your code aren't caught.
On Signing Resultisn't wrapped in atry/catch. If it throws after a successful signing, it can run a second time with error code3. - Visible to users. Tokens in
On Signing Resultare replaced as plain text and can be seen in the browser. Put them inside quotes, and don't include secrets.
Examples
To understand how to use the below examples, please see Running Examples.
1. Sign a contract and show the outcome
This action signs the file with ID [ContractFileId] using the signature picked in Signature and the PIN in Pin. The signed file goes to the SignedContract upload field. The code shows a message with the result.
{
"Title": "Sign PDF",
"ActionType": "PlantAnApp.PdfAutoSigner.SignPdf",
"Description": "Sign the contract with the user's token",
"Parameters": {
"SignatureField": "Signature",
"PinField": "Pin",
"FileToSign": "[ContractFileId]",
"SignedFileName": "contract-[OrderId]-signed.pdf",
"UploadField": "SignedContract",
"OnSigningResultJsCode": "if (result.success) {\n alert('Signed: ' + result.signedFileName);\n} else {\n alert('Signing failed: ' + result.errorDetail);\n}"
}
}
2. Sign a file from a folder
This action signs a file stored in the Contracts folder of the site. The file name comes from the [OrderId] token.
{
"Title": "Sign PDF",
"ActionType": "PlantAnApp.PdfAutoSigner.SignPdf",
"Description": "Sign the order confirmation",
"Parameters": {
"SignatureField": "Signature",
"PinField": "Pin",
"FileToSign": "Contracts/order-[OrderId].pdf",
"SignedFileName": "order-[OrderId]-signed",
"UploadField": "SignedContract",
"OnSigningResultJsCode": "if (!result.success) {\n console.log(result.errorCode, result.rawError);\n alert('The document could not be signed. Check that PDF AutoSigner is running and your token is connected.');\n}"
}
}
Revised 09/26/2026