Skip to main content
Version: 1.28 (Current)

Sign PDF

Audience: Low-code Engineers

Skill 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.

note

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 Result instead.
Action NameDescription
Check if PDF Auto Signer is runningChecks whether the PDF AutoSigner app is reachable from the user's browser.
Check PDF SignatureChecks whether a PDF has an electronic signature.
Generate PDFCreates the PDF to sign from an HTML template.
Merge PDFCombines several PDFs into one before signing.

What you need on the form​

FieldPurpose
AutoSigner Signature DropdownLets 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 fieldThe PIN of the signing token. A Password field is the better choice.
Single File Upload or Multi File UploadReceives the signed file. It's uploaded using the field's own settings, such as its upload folder.
A buttonRuns the Sign PDF action.

Input Parameter Reference​

ParameterDescriptionSupports TokensDefaultRequired
Signature FieldThe AutoSigner Signature Dropdown field that holds the selected signature. Its value is sent to the app as the signature name.Nonone selectedYes
Pin FieldThe Text or Password field that holds the token's PIN.Nonone selectedYes
File to signThe 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.Yesempty stringYes
Signed PDF file nameThe 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.Yesempty stringNo
Upload FieldThe Single File Upload or Multi File Upload field that receives the signed file.Nonone selectedYes
On Signing ResultOptional 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.Yesempty stringNo

The result object​

On Signing Result receives a result object. Check result.success first.

PropertyDescription
successtrue if the file was signed and added to the upload field, otherwise false.
errorCode0 on success. See the table below for errors.
signedFileNameOn success, the name of the signed file.
errorDetailOn error, a short description.
rawErrorOn error, the original error from the browser or the app.
errorCodeerrorDetailMeaning
1Failed 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.
2The 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.
3Failed 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​

  1. 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. or File with path ... does not exist on portal #0. A path outside the site's home folder fails with Invalid file path provided.
  2. The action ends execution and sends code to the browser. No actions after it run.
  3. The browser downloads the PDF and posts it to http://localhost:7521/api/sign, together with the PIN and the signature name.
  4. The PDF AutoSigner app signs the file and returns it.
  5. The browser adds the signed file to the upload field, which uploads it to the site.
  6. On Signing Result runs 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 Result is the only place that knows the outcome.
  • Errors in your code aren't caught. On Signing Result isn't wrapped in a try/catch. If it throws after a successful signing, it can run a second time with error code 3.
  • Visible to users. Tokens in On Signing Result are replaced as plain text and can be seen in the browser. Put them inside quotes, and don't include secrets.

Examples​

tip

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