PDF Signer User Manual

Digitally sign PDF documents with your certificate, create eIDAS electronic signatures and seals (including qualified ones, with a qualified certificate on a smart card or token), add qualified time stamps, and sign a whole folder at once. No technical knowledge needed; developers find PowerShell, C# and VB.NET examples at the end.

1. What is PDF Signer?

A PDF document (an invoice, a contract, a report) can be changed by anyone who has it. A digital signature solves two problems:

PDF Signer adds one or more digital signatures to PDF documents. You can sign a single document, several documents selected together, or select an input folder and an output folder and sign all the PDF documents of the folder at once (bulk signing). The signature can be visible on the page (with your name, the date, the reason and the place of the signing, even with your own image) or invisible.

PDF Signer creates PAdES signatures (PDF Advanced Electronic Signatures, ETSI EN 319 142-1), the format of the advanced and qualified electronic signatures of the eIDAS Regulation (EU) No 910/2014, and the older PKCS#7 signatures, for the PDF readers that do not know PAdES. When the document is signed with a qualified certificate on a QSCD (a qualified signature creation device, such as a smart card or a USB token), the result is a qualified electronic signature, with the legal effect of a handwritten signature in the whole European Union. The same applies to electronic seals (the signatures of a company or of an institution) and to qualified time stamps. Section 7 explains this in detail.

Your document is never changed

The signed result is a new file, for example invoice-001[signed].pdf. Your original document is never touched.

Qualified certificates, seals and time stamps

PDF Signer works with qualified certificates, qualified seals and qualified time stamps. If you need eIDAS Qualified Timestamps with full legal effect across the EU, visit https://qtsa.eu; section 7.5 explains how to use them.

What you can do with PDF Signer

Who is this manual for?

PDF Signer and PDF Signer Server

PDF Signer is the program with a window, for people who sign documents. PDF Signer Server is a separate product, for companies that need a signing service: it watches a folder and signs the new documents automatically, sends the signed files by e-mail, uploads them to an FTP server, archives the originals, writes logs and also works with devices that use the PKCS#11 interface (smart cards, tokens and HSMs). If you need these functions, see the product page of PDF Signer Server.

Useful links

WhatAddress
PDF Signer product page (information, purchase, download)https://www.signfiles.com/pdf-signer/
Download PDF Signer (free trial)https://www.signfiles.com/apps/PDFSigner.msi
PDF Signer Server (watch folder, e-mail, FTP, PKCS#11)https://www.signfiles.com/pdf-signer-server/
Qualified eIDAS time stampshttps://qtsa.eu
EU Trusted Lists (the qualified trust service providers)https://eidas.ec.europa.eu/efda/tl-browser/
European Commission validation tool (DSS)ec.europa.eu/digital-building-blocks/DSS/webapp-demo/validation
Validating digital signatures in Adobe Reader (guide)ValidatingDigitalSignaturesInAdobe.pdf
Signature Library (SignLib) used by PDF Signerhttps://www.signfiles.com/signature-library/
Code samples: sign a PDF, automatic signature, PowerShellpdf-digital-signature, automatic-pdf-signature, pdf-digital-signature-powershell
Support and contacthttps://www.signfiles.com/contact/

2. Product installation

We recommend installing the product with an Administrator account. After the setup file is verified, the operating system might ask for your permission to install the program: click Yes.

What you need

Installation steps

  1. Download the setup file. Get PDFSigner.msi from the product page (direct link: https://www.signfiles.com/apps/PDFSigner.msi) and run it.
  2. If Windows SmartScreen appears, allow the program to run. You may see the window Windows protected your PC. Click More info and then Run anyway. See the explanation below.
  3. Read the license agreement. Read the EULA (End-User License Agreement). If you want to continue, select I Agree and click Next.
  4. Select the installation folder. Keep the proposed folder, or click Browse... to choose another one. Choose Everyone to install the program for all the users of the computer, or Just me for your account only. Click Next.
  5. Wait for the setup to finish. When Installation Complete appears, click Close. The program is now installed.
The license agreement page of the setup. Select I Agree to enable the Next button. (The picture comes from an earlier version of the setup, which has the same pages.)
The license agreement page of the setup. Select I Agree to enable the Next button. (The picture comes from an earlier version of the setup, which has the same pages.)

By default the program is installed in the folder Secure Soft\PDF Signer of Program Files (on a 64-bit Windows: C:\Program Files (x86)\Secure Soft\PDF Signer), and the program is PDF Signer.exe.

Where to find the program

After the installation, the icon of PDF Signer appears on the desktop and in the Windows Start menu. Double-click it to start the program.

What is Windows SmartScreen?

SmartScreen is a protection built into Windows. When you run a program you downloaded, Windows compares it with a list of programs that are known and were already downloaded by many people. A program that Windows does not know yet, for example a new version that was published recently, is shown as an unrecognized app, and the window below appears.

The SmartScreen message. The text and the colors change a little between Windows versions, but the two steps are the same: More info, then Run anyway.
The SmartScreen message. The text and the colors change a little between Windows versions, but the two steps are the same: More info, then Run anyway.

This message does not mean that the file contains a virus. It only means that Windows has no reputation data about it yet. To continue:

  1. Click More info. The name of the file and of the publisher are displayed.
  2. Click Run anyway and the setup starts.
Do it only for files you trust

Run the setup only if you downloaded it from www.signfiles.com. If you prefer, you can also right-click the downloaded PDFSigner.msi, choose Properties, tick Unblock (at the bottom of the General tab) and click OK. The setup then starts without the SmartScreen message.

3. Trial period and product registration

A new, unregistered installation works for a trial period of 31 days. The title of the window shows how much is left, for example PDF Signer - Expires in 30 days, and the buttons Register Now and Buy Now! are visible.

The trial version: the title shows the remaining days, and the Buy Now! and Register Now buttons are visible.
The trial version: the title shows the remaining days, and the Buy Now! and Register Now buttons are visible.
What the trial version adds to your documents

During the trial, PDF Signer writes the text PDF SIGNER DEMO VERSION in the lower left corner of the first page of the documents it signs. The registered version does not write it.

The bottom of the first page of a document signed during the trial: the demonstration text on the left and the signature on the right.
The bottom of the first page of a document signed during the trial: the demonstration text on the left and the signature on the right.

How to register the product

  1. Get a serial number. To register the product you need a serial number (also called license code). You can buy it online directly from the product page, https://www.signfiles.com/pdf-signer/. You can also click Buy Now! in the program, which opens the same page.
  2. Open the registration window. Open PDF Signer and click the Register Now button (or Help → Register Now...).
  3. Type the license code. Enter the received serial in the first box. The second box, Licensed to (optional), is for a name: if you type one, it is shown in the title of the window.
  4. Click Register. If the serial number is correct, the product is successfully registered.
The Registration window. The code in this picture is only an example.
The Registration window. The code in this picture is only an example.
The message you see after a successful registration.
The message you see after a successful registration.
If the code is mistyped, you see this message. Check the code and type it again.
If the code is mistyped, you see this message. Check the code and type it again.
After the registration the title changes to Registered to and your name (or Registered version if you did not type a name), and the buy buttons disappear.
After the registration the title changes to Registered to and your name (or Registered version if you did not type a name), and the buy buttons disappear.
Good to know
  • The license code has 20 characters (letters and digits). Type it exactly as you received it. The messages License code cannot be empty. and Invalid license code. mean that the box is empty, or that the code was mistyped.
  • The registration is saved for the Windows user account that registered the program and for this version of the program. If another person uses the same computer with a different account, the registration is done once more with the same code.
  • The license of PDF Signer is a lifetime license: there are no monthly or yearly fees. Technical support and updates are free for 12 months after the purchase, and you can keep using the purchased version when a new version is released. The details are on the product page.
  • Help → About... shows the version of the program and the registration status.
The About window: the version of the program, the registered name and the license agreement.
The About window: the version of the program, the registered name and the license agreement.
After the trial ends

When the trial has expired, the title shows Expired on and a date, and the program no longer signs documents until you register.

4. Sign your first document

This is the whole process. It takes less than a minute once you have a certificate.

The main window when you start the program for the first time: no certificate is selected yet.
The main window when you start the program for the first time: no certificate is selected yet.
  1. Choose the document. Keep One or more PDF documents selected. Click the ... button under Source and select the PDF document you want to sign. The Destination file is filled in for you: the same name with [signed] added.
  2. Check where to save the signed document. If you want another place or name, click the ... button under Destination file. The destination must be a different file from the source.
  3. Select your digital certificate. Click Select the Digital Certificate.... Choose the certificate from the Windows store (the certificates of a smart card or of a token are there too) or a .pfx file, and click OK (details in section 6).
  4. Leave the format on the recommended value. Standard signature (recommended) is already selected and is the right choice for most documents: invoices, contracts, reports (see section 7.3).
  5. Click Apply Digital Signature. After a moment you see the message The document was digitally signed successfully, with the place of the signed document. Click Yes to open it in your PDF reader.
Ready to sign: source, destination and certificate are set. The text under Select the Digital Certificate... shows which certificate will be used. Here the signing reason and the location were also filled in.
Ready to sign: source, destination and certificate are set. The text under Select the Digital Certificate... shows which certificate will be used. Here the signing reason and the location were also filled in.
The confirmation message. Yes opens the signed document, No closes the message.
The confirmation message. Yes opens the signed document, No closes the message.
The signed document. The visible signature is in the lower right corner of the last page (the default position): the name of the signer, the reason, the place and the date.
The signed document. The visible signature is in the lower right corner of the last page (the default position): the name of the signer, the reason, the place and the date.
Tip: drag documents onto the window

Drag one or more PDF documents, or a folder, from Windows Explorer and drop them on the PDF Signer window. They are selected as the source automatically, and the destination is proposed.

Is the document really signed?

Open the signed document in a PDF reader. Adobe Reader shows the signature and a Signatures panel. A message such as Validity unknown is normal when the reader does not know the authority that issued your certificate; it does not mean that the signature is wrong. Section 13 explains how to check the signature, in PDF Signer and in Adobe Reader.

5. The main window

ItemWhat it does
Digitally signChoose One or more PDF documents (one document, or several documents selected together) or A folder with PDF documents (all the PDF documents of the folder are signed).
SourceThe document (or the folder) you want to sign. Use the ... button to browse: in the file window you can select several documents, with Ctrl + click or Shift + click. When several documents are selected, the box lists their names.
Destination file / Destination folderWhere the signed document (or the signed documents) will be saved. The name of the box changes: it is a file for a single document and a folder for a folder or for several documents.
Owner password of encrypted PDFsOnly for PDF documents that are protected with a password. See section 11.
Select the Digital Certificate...Opens the certificate window (section 6). Below this button you always see which certificate is currently selected, who issued it, until when it is valid, where its key is (on this computer, on a token or smart card, in a PFX file) and, for the signature formats that use a time stamp, the name of the time stamp server. When the certificate is not meant to sign documents, a short Warning line says so (section 6.3).
Time Stamping Settings...Available only for the signature formats that use a time stamp: the Long-term signature and the Archive signature. See section 8.
Signature FormatThe kind of signature to create, with four choices: Standard signature, Long-term signature, Archive signature and Compatibility signature. The default, Standard signature (recommended), is the right choice for normal use. A short explanation of the selected format is shown under the list, and the technical name of the format appears when you rest the mouse on the list. See section 7.3.
Signing reason, Signing locationThe reason of the signature (choose one from the list or type your own) and the place where you sign. They are saved in the signature and can be shown in the signature box. Both are optional.
Visible signature box and Signature Appearance...When it is ticked, the signature is drawn on the page. The button opens the window where you choose the page, the position, the text, the font and the image of the signature (section 9). When it is not ticked, the signature is invisible: it appears only in the signature panel of the PDF reader.
CertifyMakes the signature a certifying signature (the signature of the author of the document) and sets what can still be changed. See section 10.
Encrypt document and Encryption Settings...Protects the signed document with passwords and sets what the recipients can do with it (print, copy). See section 10.
Apply Digital SignatureSigns the document, the documents or the folder. While several documents are signed you can stop the operation with the Cancel button in the bottom bar; the bar also shows the progress.
ExitCloses the program. The settings are saved automatically.
Status barAt the bottom of the window: hints (for instance, Drag one or more PDF documents or a folder onto this window), the progress of the signing and the version of the program.
Buy Now!, Register NowVisible only while the program is not registered (section 3).

The hash algorithm of the signature (SHA256 by default) is set in the certificate window, in the Advanced group (section 6.3). The validation data that the long-term signatures store in the document is chosen by the program, in the recommended way (section 7.3).

Menus

MenuCommands
FileOpen (choose the documents to sign; Ctrl+O), Document Properties... (shows the signatures of a document, section 13), Apply Digital Signature..., Save Configuration (Ctrl+S), Save Configuration As..., Load Configuration..., Exit.
ToolsSelect the Digital Certificate..., Create a self-signed Digital Certificate..., Signature Appearance..., Time Stamping Settings... (available when the format uses a time stamp), Encryption Settings..., Restore Defaults.
HelpUser Guide (online) (F1), About... (the version of the program and the registration status) and Register Now... (only while the program is not registered).
The File menu.
The File menu.
The Tools menu.
The Tools menu.
The Help menu.
The Help menu.

6. Digital certificates

A digital certificate is your electronic identity card, issued by a certification authority. To sign with PDF Signer you need one. This section explains where certificates are kept and how to select the one you want to sign with.

6.1 Where the certificates are stored

A certificate that can sign documents has two parts: a public key (the part other people see, inside the certificate) and a private key (the secret part, which only you have). The digital signature is created with the private key. PDF Signer can use certificates from:

(Directly through the PKCS#11 interface of a device, without the Windows store: this is available in PDF Signer Server.)

The Windows Certificate Store

The Windows Certificate Store is the place where Windows keeps the certificates of the computer and of each user. PDF Signer shows its certificates in the window Digital Certificates, in the group Windows certificates.

Not the Microsoft Store of applications

The certificate store has nothing to do with the Microsoft Store where you download applications. It is only the traditional name of the list of certificates of Windows.

To see the certificates of your account, open the Windows Run window (press Win + R), type certmgr.msc and press Enter:

Type certmgr.msc in the Run window.
Type certmgr.msc in the Run window.

Then open Personal → Certificates.

The Personal store of the current user. A certificate of a token (here Test eToken Certificate) appears in the same list as the other certificates. The names in this picture are only an example.
The Personal store of the current user. A certificate of a token (here Test eToken Certificate) appears in the same list as the other certificates. The names in this picture are only an example.

To create digital signatures, the certificates of the Personal store are used. They must have a public and a private key. You can check this by opening a certificate: in the General tab Windows writes You have a private key that corresponds to this certificate.

A certificate opened with Windows. The line at the bottom shows that the private key is available on this computer. The Details buttons of PDF Signer open this same window.
A certificate opened with Windows. The line at the bottom shows that the private key is available on this computer. The Details buttons of PDF Signer open this same window.

The private key itself can be stored:

The certificates are listed per store location: Current User (your own certificates, the usual case) or Local Machine (certificates installed for all the users of the computer).

PFX and P12 files

Another way to keep a digital certificate is a PFX (or P12) file. The file contains the public and the private key of the certificate, and it is protected by a password, to keep the key pair safe.

Importing a PFX into the Windows store

A PFX/P12 file can be imported into the Windows Certificate Store: just open the file (double-click it) and follow the Certificate Import Wizard. After that, the certificate is available in the Personal list and you can select it from the Windows store without the file.

6.2 Certificates stored on smart cards or USB tokens

If your certificate is stored on a smart card or on a USB token (like Aladdin eToken or SafeNet), the private key never leaves the device: it signs inside the device. This is the kind of device used for qualified certificates (QSCD, see section 7).

PDF Signer uses such a certificate through the Windows Certificate Store. When the token is inserted in the USB port, its driver or middleware (the software delivered with the token) usually imports the certificate in the store automatically. If the certificate does not appear in the store, it cannot be used: ask your vendor how to add it, and look at the options of the middleware (for example, an option that copies the certificates of the token to the local Windows store).

When you sign, the token asks for its PIN. The window belongs to the middleware of the token, for example:

The Token Logon window of the middleware, where you type the PIN (token password). Its look depends on the vendor of your token.
The Token Logon window of the middleware, where you type the PIN (token password). Its look depends on the vendor of your token.

If the token is not connected, its certificate is not in the Windows store and PDF Signer tells you so, with the name of the certificate:

The certificate of the configuration is on a token that is not inserted: the main window explains it under the certificate button.
The certificate of the configuration is on a token that is not inserted: the main window explains it under the certificate button.
The same explanation is shown when you try to sign. Insert the token and click Apply Digital Signature again.
The same explanation is shown when you try to sign. Insert the token and click Apply Digital Signature again.
The smart card PIN

Normally the PIN is requested every time you sign. If you do not want the PIN window (for example when the documents are signed automatically, from the command line, section 16), tick Save the PIN (no PIN prompt) in the certificate window and type the PIN. The box is available only when the selected certificate is on a token or a smart card (a certificate of your computer has no PIN), and it is emptied when you select another certificate. The PIN is saved in the configuration file of your Windows account, in encrypted form, and it is not shown again. Do not give your configuration files to other people. This function does not work with all the tokens (it depends on their drivers): when it does not work, the PIN window of the middleware is shown, or the signing stops with a message; in this case untick the option. If the card rejects the PIN, PDF Signer stops using it (so your card does not get locked by repeated wrong attempts): correct it in the certificate window and try again.

Be careful with the PIN of your token

Most tokens are blocked after a few wrong PIN attempts (usually three). Do not try the PIN again and again: if the PIN is rejected, stop and check it first, for example by signing a document with another program that uses the token.

6.3 Select the digital certificate for creating signatures

To digitally sign a document, a digital certificate must be selected first. Click Select the Digital Certificate... (or Tools → Select the Digital Certificate...). The certificate can be in the Windows store or in a PFX file.

Option A: a certificate installed in Windows

Certificates installed on the computer, or stored on a USB token or smart card that Windows knows, appear in Windows Certificate Store.

The Digital Certificates window with a certificate of the Windows store selected. Refresh reads the list again, for example after you insert a token.
The Digital Certificates window with a certificate of the Windows store selected. Refresh reads the list again, for example after you insert a token.
  1. Select Windows Certificate Store.
  2. In Certificate Store choose Current User (your own certificates, the usual case) or Local Machine (certificates installed for the whole computer).
  3. Pick your certificate from the list. Each line shows the name of the owner and the expiry date; a certificate that declares itself qualified is marked (qualified certificate), and an expired one is marked EXPIRED. The issuer is written in Certificate Information, under the list. Details... displays the full certificate.
  4. If your token was inserted after the window was opened, click Refresh: the list is read again from Windows and your selection is kept.
  5. If the certificate is on a smart card and you want to avoid the PIN window, tick Save the PIN (no PIN prompt) and type the PIN. This is possible only for a certificate on a token or a smart card (section 6.2).
  6. Click OK.

The list shows only the certificates that can create signatures: they have a private key and are not meant only for encrypting or for web servers. The most suitable certificate is the first one of the list: a valid one, a qualified one, one with the non-repudiation usage of the signature certificates (a token often has also a certificate used to log in), the one that expires last. When no certificate was selected before, this one is selected for you. The expired certificates (and those that are not valid yet) are at the end of the list, so that you see why they cannot be used: when you select one, PDF Signer warns you, and OK does not accept it.

A certificate that is not meant to sign documents

Some certificates are issued for another purpose, for example only for time stamping. They are still in the list, because they have a private key, but PDF Signer adds a Warning line to Certificate Information and a short one under the certificate button of the main window. The warning appears when the usage of the certificate allows neither the digital signature nor the non-repudiation, or when its extended key usage lists only other purposes (here, Time Stamping).

A certificate issued only for time stamping: the Certificate Information box shows the warning that it is not intended to sign documents.
A certificate issued only for time stamping: Certificate Information shows the warning.

The warning does not stop the signing: you can use the certificate and the document is signed. But the programs that validate the signature, such as Adobe Reader or the European validator, can report it, so use a certificate issued for signing documents for your real documents. When you sign from the command line (section 16), the same warning is written in the command window and in the log.

Option B: a PFX file

Some certificates are delivered as a file with the extension .pfx (or .p12), protected by a password.

The Digital Certificates window with a PFX file selected. The Certificate Information box confirms that the file and the password are correct.
The Digital Certificates window with a PFX file selected. The Certificate Information box confirms that the file and the password are correct.
  1. Select PFX digital certificate file.
  2. Click ... and pick your .pfx file (or type its path).
  3. Type the PFX file password. The Details... button next to it displays the certificate so you can check you picked the right one; the Certificate Information box summarizes it.
  4. Click OK.

Certificate Information

In the middle of the window, Certificate Information summarizes the selected certificate: to whom and by whom it was issued, until when it is valid, and where its private key is stored. The same summary is shown under the certificate button of the main window.

StoredWhere the private key is
on this computerIn your Windows account, on the computer (for example an imported PFX file). The name of the provider is shown, for example Microsoft Enhanced Cryptographic Provider.
on a token or smart cardOn a smart card or USB token. A PIN is needed to sign. The provider has the name of the token vendor (for example SafeNet Smart Card Key Storage Provider).
in a PFX fileIn the PFX file you selected.

Both RSA and ECDSA (elliptic curve) certificates are supported.

Advanced

SettingMeaning
Signature hash algorithmThe mathematical fingerprint used to detect changes: SHA256 (default), SHA384 or SHA512. Keep SHA256 unless the party receiving your documents asks for another one. SHA1 is still in the list for old systems, but it is considered weak: the program warns you when you select it.

This is the only setting of the group, because the others have only one good value. For instance, the validation data of the long-term signatures (the proofs that the certificate was valid) is always collected in the recommended way, and a list of cancelled certificates larger than 1 MB is not stored. The advanced users can change these two values in the configuration file (section 16).

Expired certificates cannot sign

If the certificate is expired or not valid yet, or its private key is missing, PDF Signer refuses to sign and explains why. Renew the certificate or choose another one.

7. eIDAS electronic signatures, seals, time stamps and signature formats

PDF Signer creates the signatures that the European Union uses for electronic signatures on PDF documents: PAdES signatures (ETSI EN 319 142-1). This section explains how they relate to the eIDAS Regulation (EU) No 910/2014, what you need to obtain a qualified electronic signature or a qualified electronic seal, why a qualified time stamp is useful, which format to choose, and how to check the result with the tools of the European Union.

7.1 The levels of electronic signatures in the eIDAS Regulation

LevelWhat it means
Electronic signatureAny data in electronic form that the signer uses to sign. It has no special requirements.
Advanced electronic signature (AdES)A signature that is uniquely linked to the signer, identifies the signer, is created with data that the signer keeps under the signer's sole control, and detects any later change of the document (Article 26). PAdES is one of the formats of the advanced signatures.
Qualified electronic signature (QES)An advanced signature that is created by a qualified signature creation device (QSCD) and is based on a qualified certificate issued by a qualified trust service provider. A qualified electronic signature has the equivalent legal effect of a handwritten signature and is recognised in all the Member States (Article 25).

The same rules apply to electronic seals. A seal is the signature of a legal entity (a company, an institution), created with a certificate for electronic seals. A qualified electronic seal enjoys the presumption of integrity of the data and of correctness of the origin of the data (Article 35). PDF Signer signs with a seal certificate in the same way as with a signature certificate.

A qualified electronic time stamp, issued by a qualified time stamping service, enjoys the presumption of the accuracy of the date and the time it indicates and of the integrity of the data to which they are bound (Article 41). Section 7.5 explains how to use it.

7.2 What you need for a qualified signature or seal

The level of a signature is given by the certificate and by the device that holds its private key, not by the software. PDF Signer creates the signature in the PAdES format that the validators expect, and it works with all the kinds of certificates:

Certificate and private keyResult
A qualified certificate for electronic signatures whose private key is on a QSCD (a smart card or a USB token, used through the Windows store, section 6.2)A qualified electronic signature (QES).
A qualified certificate for electronic seals whose private key is on a QSCD (a smart card or a token, used through the Windows store)A qualified electronic seal.
A certificate issued by a certification authority, kept in the Windows store or in a PFX fileAn advanced electronic signature (or seal), if the certificate identifies the signer and the key is under the signer's sole control.
A self-signed certificate (section 14)A technically correct signature that nobody else trusts. Use it only for tests.

When the selected certificate declares itself as a qualified certificate, PDF Signer writes (qualified certificate) after its name, in the main window and in the certificate window. This mark is only an indication that is read from the certificate: the qualified status itself is given by the EU Trusted Lists (see section 7.4).

Where do I get a qualified certificate?

Qualified certificates are issued by qualified trust service providers, which are listed in the EU Trusted Lists. The provider gives you the certificate on a QSCD, usually a smart card or a USB token. Install the driver of the device, and select the certificate in PDF Signer as explained in section 6.

7.3 Signature formats

The format decides how much information is stored inside the signature, and for how long the signature can be verified. You do not need to know the technical terms: the list Signature Format of the main window has four choices, in plain words, and it explains the selected one. If you are not sure, keep the first one.

The list of the four signature formats of the main window.
The four signature formats of the main window.
Format in the listWhat it gives youWhen to use it
Standard signature recommendedThe signature, the certificate of the signer and the signing time (from the clock of your computer). It is valid as long as the certificate is valid.Everyday use: invoices, contracts, reports and the documents that you exchange. It works offline and needs no extra settings.
Long-term signatureThe Standard signature, plus a trusted time stamp from an independent server that proves when the document was signed, plus the proofs that your certificate was valid at that moment, stored in the document. The signature can be verified also after the certificate expires.Documents that must stay verifiable for years. It needs an Internet connection while you sign, and the time stamp settings (section 8).
Archive signature (10+ years)Everything from the Long-term signature, plus a document time stamp that protects the proofs themselves.Documents that are archived for many years, for instance the accounting documents. It needs the same Internet connection and settings as the Long-term signature.
Compatibility signature (older programs)The older PKCS#7 (adbe.pkcs7.detached) signature, without time stamp.Only when the program that receives your document is old and does not accept the standard signatures.
With the Long-term signature, the Time Stamping Settings... button becomes available and the time stamp server appears under the certificate.
With the Long-term signature (and with the Archive signature) the Time Stamping Settings... button becomes available and the time stamp server appears under the certificate.

The technical names

Rest the mouse on the list to see the technical name of the selected format. The first three are the baseline profiles of PAdES (ETSI EN 319 142-1), the formats recognised for the advanced and qualified signatures of the eIDAS Regulation; the validators use these names in their reports.

Format in the listTechnical name
Standard signaturePAdES-B-B (Basic)
Long-term signaturePAdES-B-LT (Long Term)
Archive signaturePAdES-B-LTA (Long Term Archival)
Compatibility signaturePKCS#7

A signature with a time stamp only (PAdES-B-T) is not a separate choice: the Long-term signature already includes the time stamp, and it adds the proofs that make it verifiable in the long term.

Certificates and validation data

The Long-term signature and the Archive signature store in the document the certificates and the proofs of validity that are available when you sign: the answers of the certification authority about your certificate (OCSP) and, where they are not available, the lists of cancelled certificates (CRL). PDF Signer does this in the recommended way, without any setting to choose. A certificate issued by a certification authority normally has these proofs. A self-signed test certificate has none, so the document contains only the certificate itself.

Encrypted documents and the long-term signatures

The Long-term signature and the Archive signature add the validation data to the document after the signature, and an encrypted document cannot be changed anymore. PDF Signer does not allow Encrypt document together with them, and tells you to select the Standard signature or to leave the document unencrypted (section 10).

7.4 The EU Trusted Lists and the validation of the signature

The EU Trusted Lists are the lists published by the Member States with the qualified trust service providers and their services (browse them here). The programs that validate signatures read them to decide whether a certificate is qualified and whether its key was on a QSCD.

Adobe Reader uses the European Union Trusted Lists too: a signature made with a certificate of a provider that is listed there is shown as valid, without any setting, and a qualified signature is marked as such:

A signature made with a qualified certificate, in Adobe Reader: the source of trust is the European Union Trusted Lists and the signature is a qualified electronic signature according to EU Regulation 910/2014. (The picture comes from an earlier version of Adobe Reader and can differ slightly on your computer.)
A signature made with a qualified certificate, in Adobe Reader: the source of trust is the European Union Trusted Lists and the signature is a qualified electronic signature according to EU Regulation 910/2014. (The picture comes from an earlier version of Adobe Reader and can differ slightly on your computer.)

For a certificate that is not in the Trusted Lists (for instance a certificate of your company, or a test certificate) Adobe Reader reports the validity as unknown, until its user trusts the certificate (section 13).

Validate the signature with the European validator

The European Commission publishes an open validation tool, DSS (Digital Signature Service, part of the eSignature building block), that checks signatures according to the eIDAS rules. You can use it to confirm that a document signed with PDF Signer carries a correct PAdES signature and to see its level:

  1. Open the validation page. Go to ec.europa.eu/digital-building-blocks/DSS/webapp-demo/validation.
  2. Select the signed document. Choose the signed PDF document.
  3. Validate. Keep the default validation policy and start the validation. Read the Simple Report; the Detailed Report and the Diagnostic data explain every check.

The report shows, for each signature:

How to read the result

The result depends on the certificate you used. With a qualified certificate on a QSCD, from a provider listed in the EU Trusted Lists, the validator can report a qualified signature. With a self-signed test certificate, the validator cannot build a trusted chain, so it reports the signature as not trusted (indeterminate), even if the document is correct. Use the Long-term signature or the Archive signature for documents that will be checked years later, because they keep the certificates and the revocation data inside the document.

Do not upload documents with private content to a public service. For confidential documents use a validation tool installed on your own computer, or the Adobe Reader.

7.5 Qualified time stamps: qtsa.eu

eIDAS Qualified Timestamps — qtsa.eu

We provide eIDAS Qualified Timestamps issued by a Qualified Trust Service Provider (QTSP) listed in the European Union Trusted Lists (EUTL) under the eIDAS Regulation. If you need eIDAS Qualified Timestamps with full legal effect across the EU, visit our dedicated website: https://qtsa.eu

A time stamp proves that the document existed at a given moment and was not changed since. A qualified time stamp is issued by a qualified trust service provider that is listed in the EU Trusted Lists, and it enjoys, in all the Member States, the presumption of the accuracy of the date and the time (Article 41 of the eIDAS Regulation). Together with a qualified signature or seal it proves both who signed the document and when, with the legal effects described in section 7.1.

PDF Signer can use any time stamp server that follows the RFC 3161 standard, so the product works with certificates, seals and time stamps that are qualified. To add a qualified time stamp to your signatures:

  1. Get the access data. The provider of the qualified time stamps gives you the address of the server and, usually, a user name and a password.
  2. Open the time stamp settings. Select a format that uses a time stamp (the Long-term signature or the Archive signature) and click Time Stamping Settings... (section 8).
  3. Type the address and the access data. Write the address in Time Stamp Server URL; tick Time Stamp Server requires authentication and type the user name and the password.
  4. Test the server. Click Test the Server. The program asks for a time stamp and shows who issued it. If the time stamp declares itself as a qualified one, the message says (qualified time stamp).
  5. Sign. Click OK and sign as usual. Every signature gets a time stamp from the server you set.
The default time stamp server is for tests

The address that PDF Signer starts with is a free server, good to try the product. It does not issue qualified time stamps. For documents that need the legal effect of a qualified time stamp, use the address of a qualified provider.

8. Time stamp settings

A time stamp is issued by a Time Stamp Authority (TSA), an independent service. It proves that your signature existed at a given moment and cannot be back-dated. It is used by the Long-term signature and by the Archive signature. Open the window with Time Stamping Settings... (also in the Tools menu).

The Time Stamping window.
The Time Stamping window.
SettingMeaning
Time Stamp Server URLThe web address of the TSA service. Type the address given by your provider (section 7.5). The list contains some public servers, for tests.
Time Stamp Server requires authenticationTick it and type the Username and Password if your provider requires them.
Time Stamp Server PolicyTick it only if your provider asked you to send a policy identifier, and type it (it must be a number sequence like 1.2.3.4.5).
Use NONCEA random number that protects the request from being replayed. It is ticked by default; keep it unless your provider asks otherwise.
Hash algorithm used for requestSHA256 by default.
Test the ServerRequests a time stamp with the values of the window (they do not have to be saved) and shows the result. Use it before you sign.
Restore DefaultsPuts all these values back to the original ones.
The result of the test: the server works, and it tells who issued the time stamp.
The result of the test: the server works, and it tells who issued the time stamp.
Internet required

The computer must be able to reach the time stamp server while signing. If the address is not valid, PDF Signer tells you to set it before signing, and if the server cannot be reached, it explains that you must check the Internet connection and the settings. The Standard signature and the Compatibility signature have no time stamp and work without any server.

The address is not shown in full

Under the certificate, the main window shows only the name of the time stamp server (not the whole address), because some providers put the user name and the password in the address.

9. The appearance of the signature

When Visible signature box is ticked, the signature is drawn on the page: by default in the lower right corner of the last page, with the name of the signer, the reason, the place and the date. Click Signature Appearance... to change it.

The Configure Signature Appearance window.
The Configure Signature Appearance window.
SettingMeaning
Signature PageFirst Page, Second Page, Last Page (default), All Pages (a signature on every page) or Custom Pages. For Custom Pages type the pages in the box next to the list, separated by commas, for example 1, 3, last (last is the last page). When a document has fewer pages than the choice needs, PDF Signer adjusts the choice: Second Page on a document with one page signs the page 1, and the pages of the list that do not exist are skipped (the last page is used when none of them exists), so a whole folder of documents with different lengths can be signed with the same settings.
Include Adobe signature status imagesDraws in the signature box the older image of the status of the signature (a question mark, a green tick) that Adobe Reader changes after the validation.
PositionOne of six places of the page: Top Right, Top Middle, Top Left, Bottom Right (default), Bottom Middle, Bottom Left. Large signature box makes the box bigger.
Custom positionTick it to place the box exactly: X-axis and Y-axis (the place of its lower left corner), Width and Height. The numbers are in points (1 point is 1/72 of an inch; an A4 page is about 595 by 842 points) measured from the lower left corner of the page, where X and Y are 0.
Font sizeWhen it is not ticked, the size of the text is calculated so that the text fits in the box. Tick it to set a fixed size.
Right to Left textWrites the text from right to left (for example for Hebrew or Arabic).
Standard fonts, Use a custom fontThe text uses a standard PDF font (Helvetica by default). If your text needs letters that the standard fonts do not have (for example Cyrillic, Greek or Chinese), tick Use a custom font and select a font file (.ttf or .fon).
Configure Signature BoxWhat the box contains: Name from digital certificate, Entire certificate subject, Reason, Location and Signing Date (with the Date format). Tick Labels to write a label before each item (Signed By:, Location:, Reason:, Signing Date:); you can change the labels. Tick Custom text to add your own text at the end.
Place an image on the signature boxAdds an image (for example a scan of your handwritten signature or a logo): Image and text, Image as background or Image with no text. The image can be a BMP, GIF, JPG, PNG, TIFF or WMF file.
Restore DefaultsPuts the settings of this window back to the original values (it asks you to confirm first).
The reason, the location and the date

The reason and the location come from the main window (Signing reason, Signing location). They are saved in the signature, and they appear in the box only when Reason and Location are ticked here. The date is the time of your computer; for a time proved by an independent server use a format with a time stamp (section 7.3).

An invisible signature

If you do not want any drawing on the page, untick Visible signature box in the main window. The document is signed all the same, and the signature appears in the signature panel of the PDF reader.

10. Reason, certification and encryption

Signing reason and location

In the main window, Signing reason offers five usual reasons: I am the author of this document, I have reviewed this document, I am approving this document, I attest to the accuracy and authenticity of this document and I agree to specified portions of this document. You can also type your own reason. Signing location is the place where you sign, for example the name of your city. Both are optional. They are saved in the signature and appear in the signature properties of the PDF reader; they appear in the signature box too, if the options Reason and Location are ticked in the appearance window (section 9).

Certify the document

When you certify a document, you indicate that you are its author and that you approve of its content. You also set which changes are still allowed for the document to remain certified. According to the PDF standard, a certifying signature must be the first signature of a document, and a document can have only one: use Certify only for documents that are not signed yet. PDF readers show a certifying signature with a blue ribbon in the signature panel.

Tick Certify in the main window and choose the level:

LevelWhat the recipients can still do
No changes allowedNothing: any change, also another signature, makes the certification invalid.
Permit annotations and form fillingThey can fill in the form fields, add comments and sign.
Permit form fillingThey can fill in the form fields and sign.
Do you need it?

Certification is for the author of a document that others will complete or sign. For invoices, contracts and other documents that you simply sign, leave Certify unticked.

Encrypt the signed document

If you want to protect the signed document, for instance to prevent the copying of its content, you can encrypt it. Tick Encrypt document: the encryption window opens (it opens by itself when no password is set yet), and the document is signed and encrypted in the same operation, so the signature stays valid.

The Encryption window.
The Encryption window.
SettingMeaning
No changes are permittedThe recipients cannot modify the document.
Allow printingThe recipients can print the document. It is ticked by default, so that an invoice can be printed.
Allow content copyingThe recipients can copy the text and the images of the document.
Allow content copying for accessibilityThe programs that read the document aloud for people with a visual impairment can read it. It is ticked by default.
Open password (optional)The password that the recipients must type to open the document. If you leave it empty, everybody can open the document.
Permissions passwordThe password that you keep, to change the restrictions later. The recipients do not need it. It is also the password with which PDF Signer or another program can modify or sign the document again (section 11).
Encryption level128-bit AES (high) is the default and the recommended one. The two RC4 levels are weaker; use them only if the recipients have very old PDF readers.

At least one of the two passwords is required, and they must be different (with the same password, the recipients could remove the restrictions). The open password is asked by the PDF reader when the document is opened; the restrictions are shown in the security settings of the document.

Good to know
  • The restrictions (print, copy) are respected by the PDF readers, but they are not a strong protection: only the open password really prevents the opening of a document.
  • Encrypt document cannot be combined with the Long-term signature or the Archive signature (section 7.3): select the Standard signature or do not encrypt.
  • A document that already has signatures cannot be encrypted by PDF Signer, because encrypting it would invalidate them. Encrypt it when you sign it the first time.
  • Write the passwords down in a safe place. A document encrypted with a password that is lost cannot be recovered.

11. Protected, damaged and already signed documents

Documents protected with a password

Some PDF documents are protected with a password. To sign such a document, tick Owner password of encrypted PDFs in the main window and type the password. It must be the owner password (the permissions password): signing changes the document, and only the owner password allows it. The password that only opens the document is not enough. The signed document keeps the protection of the original: the same passwords, the same restrictions and the same encryption.

If the password is missing or wrong, PDF Signer does not sign the document and explains why:

The password of the main window is used for all the documents you sign in the same operation. When you sign a folder of documents that have different passwords, the documents with another password are not signed and are listed at the end (section 12); sign them separately.

Documents that are already signed

You can sign a document that already has signatures. The new signature is added after the existing ones, which remain valid. Do not use Certify for such a document: a certifying signature must be the first one (section 10).

Documents with a damaged structure

Some PDF documents have a damaged internal structure (a wrong table of the positions of the objects, for example after a faulty export or download). The PDF readers repair such a document silently when they open it, and you do not notice anything. A document like this cannot be signed by simply adding a signature at the end, so PDF Signer rebuilds it before signing:

The question for a damaged document that is already signed. Click No if the existing signature must remain valid.
The question for a damaged document that is already signed. Click No if the existing signature must remain valid.
If you click No, the document is not signed, and the message tells you why.
If you click No, the document is not signed, and the message tells you why.

When a folder is signed, the question is asked for each such document, and a document for which you answer No is listed among the errors at the end. When the signing is made from the command line (section 16), nobody can answer the question, so these documents are not signed and the result code is 1.

12. Signing several documents or a whole folder

Several documents selected together

Click ... next to Source and select several documents in the file window (Ctrl + click, or Shift + click for a range). You can also drag the documents from Windows Explorer onto the window. The box lists the selected documents, and Destination becomes a folder: by default the folder of the first document. Each document is saved in the destination folder with the same name plus [signed], for example invoice-001.pdf becomes invoice-001[signed].pdf; the originals are not touched.

Three documents selected together. The destination is a folder (here the folder of the first document) and the signed documents are named <name>[signed].pdf.
Three documents selected together. The destination is a folder and the signed documents are named <name>[signed].pdf.

All the documents of a folder

To sign all the PDF documents of a folder at once, select A folder with PDF documents.

Folder mode: Source and Destination are now folders.
Folder mode: Source and Destination are now folders.
  1. Under Source choose the folder with your documents (or drag the folder onto the window).
  2. Under Destination choose another folder. Every PDF document of the source folder is signed and saved in the destination folder with the same name: invoice-001.pdf remains invoice-001.pdf. The source and the destination must be different folders, otherwise the originals would be overwritten. Only the documents of the folder itself are signed, not those of its subfolders.
  3. Click Apply Digital Signature. While it works, the bottom bar shows the progress and a Cancel button. When it finishes you see how many documents were signed.
All three documents of the folder were signed. You can open the destination folder from the message.
All three documents of the folder were signed. You can open the destination folder from the message.

A problem with one document does not stop the others. At the end the message lists the documents that failed and why (the first ten). If the PIN of your smart card is rejected, the operation stops at once, so the card is not locked by repeated wrong attempts.

Nothing is overwritten by surprise

If documents with the same names already exist in the destination, the program asks you first. When you pick a destination folder that already contains PDF documents, you are asked whether to use it anyway. If the folder you select contains no PDF documents, you are told: The selected folder does not contain PDF documents.

The question when the destination file already exists.
The question when the destination file already exists.

13. Checking a signed document

In PDF Signer: Document Properties

Open File → Document Properties.... If a document is selected in the Source box, it is shown; otherwise the program asks you to select one. The window shows the number of pages, the size of the page and, for each signature of the document (choose it from the list; the ... button next to the list shows the certificate of the signer): the reason and the place of the signature, the hash algorithm, the integrity of the signature, the date and the time stamp server.

The properties of a document signed with a time stamp.
The properties of a document signed with a time stamp.
LineMeaning
Signature IntegrityThe most important line. Valid - the document was not changed after this signature means the document is exactly as it was when signed. NOT VALID means it was changed after signing, or the signature is damaged.
Signature DateWhen the document was signed. Certified by the time stamp server means that an independent server proves the time. Time of the signer's computer, not certified means that the time comes from the clock of the computer of the signer.
Time Stamp ServerThe authority that issued the time stamp, or no time stamp.
Valid does not always mean trusted

This window checks only that the document was not changed. Whether you trust the signer (and whether the signature is a qualified one) is decided by checking the certificate: do it in Adobe Reader or with the European validator (section 7.4).

For a document that is protected with a password, tick Owner password of encrypted PDFs in the main window and type the password before you open the properties.

In Adobe Reader

Open the signed document in Adobe Reader and look at the bar above the document and at the Signatures panel. For a certificate that is not in the lists that Adobe trusts, for example the certificate of your company or a test certificate, Adobe says that the validity is unknown:

Adobe Reader: Signature validity is unknown. The document was not modified since the signature was applied, but Adobe does not know the authority that issued the certificate. (The picture comes from an earlier version of Adobe Reader and can differ slightly on your computer.)
Adobe Reader: Signature validity is unknown. The document was not modified since the signature was applied, but Adobe does not know the authority that issued the certificate. (The picture comes from an earlier version of Adobe Reader and can differ slightly on your computer.)

This is not an error of the signature or of PDF Signer: Adobe uses its own lists of trusted authorities. A signature made with a qualified certificate, or with a certificate of an authority that Adobe trusts, is shown as valid without any setting. For the other certificates, the person who receives the document can tell Adobe that it trusts the certificate:

  1. Open the Signature Properties and click Show Certificate....
  2. Select the topmost certificate of the chain, open the Trust tab and click Add to Trusted Identities....
  3. Tick all the boxes, click OK, and open the document again.
After the certificate is trusted, the same signature is shown as valid. (Earlier version of Adobe Reader.)
After the certificate is trusted, the same signature is shown as valid. (Earlier version of Adobe Reader.)

The steps for the different versions of Adobe Reader, the time stamps and the revocation checks are described in the guide Validating Digital Signatures in Adobe.

With the European validator

To check the level of the signature (advanced or qualified), use the validation tool of the European Commission, described in section 7.4.

14. Creating a test certificate

If you do not have a certificate yet and only want to try the program, PDF Signer can create a self-signed one. Open Tools → Create a self-signed Digital Certificate...

Filling in the details of a new self-signed certificate.
Filling in the details of a new self-signed certificate.
  1. Choose where to save it: On Microsoft Certificate Store (the certificate is installed for your Windows account) or On a password protected PKCS#12 PFX file (you will be asked for the file name and a password).
  2. Type Issued to (your name, required) and, if you wish, the organization, the unit, the title, the e-mail address and the country code (two letters, for example US).
  3. Choose the Validity period (3, 5 or 10 years, default 3 years), the Key Algorithm (RSA 2048, 3072 or 4096 bits, or ECDSA with the curves P-256, P-384 or P-521; default RSA 2048) and the Hash Algorithm (SHA256, SHA384 or SHA512; default SHA256). The defaults are fine.
  4. Keep Set as current digital certificate ticked to use it right away, then click OK and confirm the question that explains what a self-signed certificate is.
For tests only

Nobody except you trusts a self-signed certificate. Other people's programs will show that the signer is unknown. For real documents, use a certificate issued by a recognised certification authority (section 7.2).

15. Saving your settings

The program remembers your choices (certificate, signature format, appearance, time stamp server, encryption...) the next time you start it. You can also keep several sets of settings in files — for example one for invoices and one for contracts:

The settings are kept in the file configuration.xml, in the folder %APPDATA%\Secure Soft\PDF Signer\12.0 of your Windows account. A saved configuration file is also what the command line uses to sign documents automatically.

Protect your configuration files

A configuration file can contain the PIN of your token, the password of your PFX file and the other passwords you typed, in encrypted form. Do not send your configuration files to other people.

Old and damaged configuration files

A configuration file made by an earlier version of the program is converted automatically. If a file contains a value that is not valid, the program tells you which one and uses the default value instead. A file that is damaged, or that is not a PDF Signer configuration file, is never used: a damaged current configuration is kept as configuration.xml.bad and the default one is created, and when you load a file that is not valid, your current configuration is not changed.

16. Automatic signatures from the command line

PDF Signer can also sign without showing its window, for example from a scheduled task, from a script or from another program. Nobody has to click anything: the program reads the settings from a configuration file, signs and closes.

By default, PDF Signer is installed in the folder C:\Program Files (x86)\Secure Soft\PDF Signer (on a 32-bit Windows: C:\Program Files\Secure Soft\PDF Signer) and the program is PDF Signer.exe.

Need more than this?

If you need to sign the new documents of a folder automatically as soon as they arrive, to send the signed documents by e-mail, to upload them to an FTP server, to archive the originals or to use a device through its PKCS#11 interface, see PDF Signer Server.

Command line parameters

"PDF Signer.exe" <source file> <destination file> [<configuration file>]
"PDF Signer.exe" <source folder> <destination folder> [<configuration file>]

Sign one document

c:\Program Files (x86)\Secure Soft\PDF Signer>"PDF Signer.exe" C:\Demo\Invoices\invoice-001.pdf C:\Demo\Signed\invoice-001.pdf
The file was digitally signed successfully.

Sign a folder

c:\Program Files (x86)\Secure Soft\PDF Signer>"PDF Signer.exe" C:\Demo\Invoices C:\Demo\Signed
The PDF documents of the source folder were digitally signed successfully. Number of signed documents: 3

Custom configuration

In some cases you need a different signature configuration (for example a different certificate, signature format or appearance) for different documents or folders. To save a specific configuration, open the window, set everything you want, and go to File → Save Configuration As... Save the configuration in a file. Later you can use that file in the command line to apply a different signature configuration:

"PDF Signer.exe" C:\Demo\Invoices C:\Demo\Signed C:\Demo\invoices.config
No window means no questions

Because nobody is there to answer, choose a certificate that does not need any interaction: a PFX file (its password is saved in the configuration, encrypted), or a smart card certificate with the PIN saved (section 6.2); the smart card must be connected. The certificate must be valid: an expired certificate stops the signing, with the result code 2. A document that is protected with a password is signed if its owner password is saved in the configuration (section 11), and a damaged document that is already signed is not signed (it needs your answer to a question).

Advanced values of the configuration file

The configuration file is a text file (XML) that you can also read and change with a text editor. Most of its values are the choices of the window. These ones are written in the file with technical names, and two of them have no place in the window:

ValueMeaning
SignatureFormatThe signature format: PAdES-B (Standard signature), PAdES-LT (Long-term signature), PAdES-LTA (Archive signature) or PKCS7 (Compatibility signature). The names of the baseline levels, PAdES-B-B, PAdES-B-LT and PAdES-B-LTA, are accepted too. The values of the earlier versions that are not offered anymore are converted: PAdES-T and PAdES-B-T become PAdES-LT; PKCS7-T and PKCS7-LTV become PKCS7.
RevocationDataTypeThe validation data stored by the Long-term and Archive signatures: IncludeOcspOnly (the default: the OCSP responses, and the CRL where OCSP is not available), IncludeCrl (CRLs) or IncludeCrlAndOcsp (both). Keep the default value unless a validator or a recipient asks for another one.
RevocationDataSizeThe largest CRL that is stored in the signature, in kilobytes (1024 by default; from 10 to 1000000). A larger CRL is not stored.

Result codes

CodeMeaning
0Success.
1The signing failed (for a folder: at least one document failed).
2The signing could not start: invalid parameters, the source does not exist, the destination is the same as the source, the configuration file is damaged or has values that are not valid, the certificate is not valid, or PDF Signer is not registered (the trial has expired).

The messages are written in the command window. Examples:

The destination folder does not exist.                          (code 2)
The destination cannot be the same as the source.               (code 2)
The source file or folder does not exist.                       (code 2)
The configuration file does not exist.                          (code 2)
The configuration file contains values that are not valid (C:\Demo\invalid.config):
SignatureFormat: 'PAdES-BB' is not valid (valid values: PAdES-B, PAdES-LT, PAdES-LTA, PKCS7).    (code 2)
Operation finished with errors. Signed files: 1 of 2. Last error: ...    (code 1)

When the certificate is not meant to sign documents (section 6.3), the program writes a warning before the signing starts, and it writes it in the log too. The warning does not change the result: the documents are signed and the code is 0.

Warning: the certificate is not intended to sign documents (its extended key usage is only Time Stamping). The validators can report the signatures created with it.

PDF Signer is a Windows application, so the command prompt does not wait for it. To wait and read the result code:

cmd:         start "" /wait "PDF Signer.exe" C:\Demo\Invoices C:\Demo\Signed C:\Demo\invoices.config
             echo %errorlevel%

PowerShell:  (Start-Process "PDF Signer.exe" -ArgumentList '"C:\Demo\Invoices" "C:\Demo\Signed" "C:\Demo\invoices.config"' -Wait -PassThru).ExitCode

Every signed document, and every error, is also written in the log files log.txt and errorlog.txt of the folder %APPDATA%\Secure Soft\PDF Signer\12.0.

Run it every night

Set up everything once in the window, use Save Configuration As..., and then create a task in the Windows Task Scheduler that starts PDF Signer.exe with the source folder, the destination folder and the configuration file. Use the same Windows account for the task that you used to set up the certificate and the registration.

17. The Signature Library behind PDF Signer

PDF Signer is an application built on the Signature Library (SignLib), a library for .NET that creates and verifies digital signatures: PDF (PAdES), CAdES / PKCS#7, XML (XAdES), Office and more. Everything PDF Signer does is available to your own programs and scripts through the library:

The library works with Windows PowerShell, C#, VB.NET and ASP.NET, and it supports certificates from PFX files, from the Windows store and from smart cards, USB tokens and HSMs.

One of the purposes of PDF Signer

PDF Signer is also a demonstration of the library. Before you write any code, use the window to try a signature format, a hash algorithm, a time stamp server or a certificate, and save the result of your test. Every choice you make in the window is one property of the library (see the table below), and the signed document you get is what your code will produce.

From the window to the code

PDF signatures are created with the class SignLib.Pdf.PdfSignature. The table shows what each setting of PDF Signer is in the library.

In PDF SignerIn the library
Signature Format (section 7.3)ps.SignatureStandard = PdfSignatureStandard.Pades (Standard signature, PAdES-B-B), PadesLT (Long-term signature, PAdES-B-LT), PadesLTA (Archive signature, PAdES-B-LTA), Default (Compatibility signature, the older PKCS#7). The time stamp is added when TimeStamping.ServerUrl is set. The library can also create a PAdES-B-T signature (Pades with a time stamp server) and a PKCS#7 signature with a time stamp or with revocation data; PDF Signer offers the Long-term signature instead.
Signature hash algorithmps.HashAlgorithm = HashAlgorithm.SHA256 (or SHA384, SHA512)
Digital certificate from a PFX fileDigitalCertificate.LoadCertificate(pfxFile, password)
Digital certificate from the Windows store or a smart cardDigitalCertificate.LoadCertificate(...) with a search criterion, or without parameters to show the selection window
Save the PINDigitalCertificate.SmartCardPin = "..."
Time Stamp Server URL, user name, password, policy, NONCE, hash (section 8)ps.TimeStamping.ServerUrl, .UserName, .Password, .PolicyOid, .UseNonce, .HashAlgorithm
Signing reason, Signing locationps.SigningReason, ps.SigningLocation
Visible signature box, the page, the position (section 9)ps.VisibleSignature, ps.SignaturePage (int.MaxValue is the last page), ps.SignaturePages, ps.SignatureAppearsOnAllPages, ps.SignaturePosition, ps.SignatureAdvancedPosition
Font, text and image of the signatureps.FontName, ps.FontFile, ps.FontSize, ps.TextDirection, ps.SignatureText, ps.SignatureImage, ps.SignatureImageType
Certifyps.CertifySignature = CertifyMethod.NoChangesAllowed (or AnnotationsAndFormFilling, FormFilling)
Encrypt documentps.Encryption (EncryptionMethod, EncryptionAlgorithm, OwnerPassword, UserPassword, DocumentRestrictions)
Owner password of encrypted PDFsps.DocumentProperties.Password (set it before LoadPdfDocument)
Validation data of the long-term signatures (only in the configuration file: RevocationDataType, RevocationDataSize, section 16)ps.PadesLtvLevel (PadesLtvLevel.IncludeOcspOnly, IncludeCrl, IncludeCrlAndOcsp) and ps.MaxCrlSize (in bytes)
Apply Digital Signatureps.ApplyDigitalSignature(), which returns the bytes of the signed document
Document Properties (section 13)ps.DocumentProperties (NumberOfPages, DigitalSignatures, IsDamaged) and PdfSignatureInfo
Create a self-signed certificate (section 14)the class X509CertificateGenerator

The library can do more than the window: an explicit signature policy, the signing of an existing empty signature field, a document time stamp without a signature, and the deferred signing with an external signer (HSM, cloud). Section 19 shows the main cases.

18. Digitally sign PDF documents using Windows PowerShell

The main functions of PDF Signer are available in the SignLib library, which you can download from this link: https://www.signfiles.com/sdk/SignatureLibrary.zip

To digitally sign a PDF document using Windows PowerShell, simply download the library above and inspect the Signature Library\PowerShell Scripts folder. The script below creates a test PFX certificate on the fly, signs the document in the PAdES-B-B format (SHA256) and verifies the result.

The script

Save it as signPdf.ps1, in the same folder with SignLib.dll and iTextSharp-4.1.6.dll.

#digitally sign a PDF document with a PFX certificate created on the fly (PAdES-B-B, SHA256) and verify the result
#the script can be configured to use an existing PFX file or a certificate loaded from the Windows certificate store (smart card certificate)

if ($args.Length -eq 0)
{
    echo "Usage: signPdf.ps1 <unsigned file> <signed file>"
}
else
{
    #SignLib.dll and iTextSharp-4.1.6.dll must be in the same folder as the script
    $DllPath = Join-Path $PSScriptRoot 'SignLib.dll'
    [System.Reflection.Assembly]::LoadFrom($DllPath) | Out-Null

    #create a PFX digital certificate
    $generator = new-object -typeName SignLib.Certificates.X509CertificateGenerator("serial number")
    $pFXFilePassword = "tempP@ssword"
    $generator.Subject = "CN=Your Certificate, E=useremail@email.com, O=Organization"
    $generator.Extensions.AddKeyUsage([SignLib.Certificates.CertificateKeyUsage]::DigitalSignature)
    $generator.Extensions.AddEnhancedKeyUsage([SignLib.Certificates.CertificateEnhancedKeyUsage]::DocumentSigning)

    echo "Create the certificate..."
    $certificate = $generator.GenerateCertificate($pFXFilePassword)

    #digitally sign the PDF document (PAdES-B-B, SHA256)
    $sign = new-object -typeName SignLib.Pdf.PdfSignature("serial number")
    $sign.LoadPdfDocument($args[0])
    $sign.DigitalSignatureCertificate = [SignLib.Certificates.DigitalCertificate]::LoadCertificate($certificate, $pFXFilePassword)
    $sign.SignatureStandard = [SignLib.Pdf.PdfSignatureStandard]::Pades

    $sign.SigningReason = "I approve this document"
    $sign.SigningLocation = "Accounting department"
    $sign.SignaturePage = 1
    $sign.SignaturePosition = [SignLib.Pdf.SignaturePosition]::TopRight

    echo "Perform the digital signature..."
    [System.IO.File]::WriteAllBytes($args[1], $sign.ApplyDigitalSignature())

    #verify the signature
    $verify = new-object -typeName SignLib.Pdf.PdfSignature("serial number")
    $verify.LoadPdfDocument($args[1])
    echo ("Signatures: " + $verify.DocumentProperties.DigitalSignatures.Count)
    echo ("Valid: " + $verify.DocumentProperties.DigitalSignatures[0].SignatureIsValid)
}

How to run it

How to run the Windows PowerShell script from the command line:

powershell -executionPolicy bypass -file d:\signPdf.ps1 d:\invoice.pdf d:\invoice-signed.pdf

The result in the window:

Create the certificate...
Perform the digital signature...
Signatures: 1
Valid: True
Good to know
  • Replace "serial number" with the serial number you received for the library. Without it the library works in demonstration mode: it writes This is a demo version of SignLib.dll. and adds the text SignLib.dll DEMO VERSION on the first page of the documents.
  • -executionPolicy bypass allows this one script to run without changing the security settings of the computer.
  • To sign with an existing PFX file, remove the certificate generator and use [SignLib.Certificates.DigitalCertificate]::LoadCertificate("d:\certificate.pfx", "password"). For a smart card certificate from the Windows store use the methods described in section 19.3.
  • For a time stamp (PAdES-B-T), add $sign.TimeStamping.ServerUrl = [Uri]"https://your-time-stamp-server" before ApplyDigitalSignature. For a qualified signature use the qualified certificate of your device, and for a qualified time stamp the server of a qualified provider (section 7).

19. Digitally sign PDF documents using C# or VB.NET

The main functions of PDF Signer are available in the SignLib library (download). To digitally sign a PDF document using C# or VB.NET, download the library, add a reference to SignLib.dll in your project, make sure that iTextSharp-4.1.6.dll, delivered with it, is in the same folder as your program, and inspect the sample projects of the package and the code samples: sign a PDF document, automatic signature, PowerShell.

PDF documents are signed with the class PdfSignature (namespace SignLib.Pdf). It creates PAdES and PKCS#7 signatures, with or without a time stamp and long-term validation data, visible or invisible, and it reads the signatures of a document (DocumentProperties.DigitalSignatures). All the examples below use these namespaces. Every example was run with the library to check the result.

using System;
using System.Collections.Generic;   // List<int>
using System.IO;
using System.Security.Cryptography.X509Certificates;
using SignLib;                 // HashAlgorithm
using SignLib.Certificates;    // DigitalCertificate
using SignLib.Pdf;             // PdfSignature, SignaturePosition, PdfSignatureStandard...

19.1 Sign a document and verify the signature

The smallest program: load a certificate from a PFX file, sign, save the signed document and verify it. The signature format is PAdES-B-B (PdfSignatureStandard.Pades) and the hash is SHA256, like the defaults of PDF Signer. ApplyDigitalSignature returns the bytes of the signed document: you choose where to save it. The PdfSignature object that verifies is a new one, loaded with the signed document.

// "serial number" is the serial number of the library
PdfSignature ps = new PdfSignature("serial number");
ps.LoadPdfDocument(@"C:\Demo\Invoices\invoice-001.pdf");
ps.DigitalSignatureCertificate = DigitalCertificate.LoadCertificate(@"C:\Demo\elaine.pfx", "123456");

ps.SignatureStandard = PdfSignatureStandard.Pades;      // PAdES-B-B
ps.HashAlgorithm = HashAlgorithm.SHA256;
ps.SigningReason = "I am approving this document";
ps.SigningLocation = "Springfield";
ps.SignaturePage = int.MaxValue;                        // the last page
ps.SignaturePosition = SignaturePosition.BottomRight;

// apply the digital signature: the original document is not changed
byte[] signed = ps.ApplyDigitalSignature();
File.WriteAllBytes(@"C:\Demo\Signed\invoice-001-code.pdf", signed);

// verify the signature
PdfSignature check = new PdfSignature("serial number");
check.LoadPdfDocument(@"C:\Demo\Signed\invoice-001-code.pdf");

Console.WriteLine("Pages: " + check.DocumentProperties.NumberOfPages + ", signatures: " + check.DocumentProperties.DigitalSignatures.Count);
foreach (PdfSignatureInfo info in check.DocumentProperties.DigitalSignatures)
{
    Console.WriteLine("Signer: " + info.SignatureCertificate.GetNameInfo(X509NameType.SimpleName, false));
    Console.WriteLine("Hash: " + info.HashAlgorithm);
    Console.WriteLine("Reason: " + info.SigningReason + ", location: " + info.SigningLocation);
    Console.WriteLine("Valid: " + info.SignatureIsValid);
    Console.WriteLine("Time: " + info.SignatureTime);
    Console.WriteLine("Time stamped: " + info.SignatureIsTimestamped);
}

The result:

Pages: 1, signatures: 1
Signer: Elaine Smith
Hash: SHA256
Reason: I am approving this document, location: Springfield
Valid: True
Time: 10/8/2026 7:04:42 PM
Time stamped: False

(X509NameType is in the namespace System.Security.Cryptography.X509Certificates.) The same example in VB.NET:

Imports System
Imports System.IO
Imports System.Security.Cryptography.X509Certificates
Imports SignLib
Imports SignLib.Certificates
Imports SignLib.Pdf

Module Module1
    Sub Main()
        ' "serial number" is the serial number of the library
        Dim ps As New PdfSignature("serial number")
        ps.LoadPdfDocument("C:\Demo\Invoices\invoice-001.pdf")
        ps.DigitalSignatureCertificate = DigitalCertificate.LoadCertificate("C:\Demo\elaine.pfx", "123456")
        ps.SignatureStandard = PdfSignatureStandard.Pades
        ps.HashAlgorithm = HashAlgorithm.SHA256
        ps.SigningReason = "I am approving this document"
        ps.SigningLocation = "Springfield"
        ps.SignaturePosition = SignaturePosition.BottomRight

        'apply the digital signature and save the signed file
        File.WriteAllBytes("C:\Demo\Signed\invoice-001-vb.pdf", ps.ApplyDigitalSignature())

        Dim check As New PdfSignature("serial number")
        check.LoadPdfDocument("C:\Demo\Signed\invoice-001-vb.pdf")
        Console.WriteLine("Signatures: " & check.DocumentProperties.DigitalSignatures.Count)
        For Each info As PdfSignatureInfo In check.DocumentProperties.DigitalSignatures
            Console.WriteLine("Valid: " & info.SignatureIsValid)
        Next
    End Sub
End Module

19.2 Signature formats, time stamp and long term validation

The format is chosen with SignatureStandard, and the signature is time stamped (PAdES-B-T) when you set the address of a time stamp server (section 8):

Format in PDF SignerIn the library
Standard signature (PAdES-B-B)PdfSignatureStandard.Pades, without a time stamp server
Long-term signature (PAdES-B-LT)PdfSignatureStandard.PadesLT and TimeStamping.ServerUrl
Archive signature (PAdES-B-LTA)PdfSignatureStandard.PadesLTA and TimeStamping.ServerUrl
Compatibility signature (PKCS#7)PdfSignatureStandard.Default (with TimeStamping.ServerUrl for a time stamp)
PAdES-B-T (not a choice of PDF Signer)PdfSignatureStandard.Pades and TimeStamping.ServerUrl

A signature with time stamp (PAdES-B-T), and its verification:

PdfSignature ps = new PdfSignature("serial number");
ps.LoadPdfDocument(@"C:\Demo\Invoices\invoice-002.pdf");
ps.DigitalSignatureCertificate = DigitalCertificate.LoadCertificate(@"C:\Demo\elaine.pfx", "123456");

ps.SignatureStandard = PdfSignatureStandard.Pades;      // PAdES-B-T: PAdES-B-B plus a time stamp
ps.TimeStamping.ServerUrl = new Uri("https://ca.signfiles.com/TSAServer.aspx");
ps.TimeStamping.UseNonce = true;                        // a random number that protects the request
ps.TimeStamping.HashAlgorithm = HashAlgorithm.SHA256;   // the hash of the time stamp request
// ps.TimeStamping.UserName = "user"; ps.TimeStamping.Password = "password";   // only if the server requires them

File.WriteAllBytes(@"C:\Demo\Signed\invoice-002-code-t.pdf", ps.ApplyDigitalSignature());

PdfSignature check = new PdfSignature("serial number");
check.LoadPdfDocument(@"C:\Demo\Signed\invoice-002-code-t.pdf");
PdfSignatureInfo info = check.DocumentProperties.DigitalSignatures[0];
Console.WriteLine("Time stamped: " + info.SignatureIsTimestamped);
Console.WriteLine("Time stamp authority: " + info.TimestampInfo.TsaCertificate.GetNameInfo(X509NameType.SimpleName, false));
Console.WriteLine("Time stamp altered: " + info.TimestampInfo.IsTimestampAltered);

The result:

Time stamped: True
Time stamp authority: Free TSA Server
Time stamp altered: False

For long term validation, set SignatureStandard to PdfSignatureStandard.PadesLT; the signing adds the certificates and the revocation data of the signer to the document. PdfSignatureStandard.PadesLTA adds, in addition, the document time stamp. The time stamp server can be the server of a qualified time stamp authority (section 7.5).

PdfSignature ps = new PdfSignature("serial number");
ps.LoadPdfDocument(@"C:\Demo\Invoices\invoice-003.pdf");
ps.DigitalSignatureCertificate = DigitalCertificate.LoadCertificate(@"C:\Demo\elaine.pfx", "123456");

ps.SignatureStandard = PdfSignatureStandard.PadesLT;    // PAdES-B-LT (PdfSignatureStandard.PadesLTA for PAdES-B-LTA)
ps.TimeStamping.ServerUrl = new Uri("https://ca.signfiles.com/TSAServer.aspx");

File.WriteAllBytes(@"C:\Demo\Signed\invoice-003-code-lt.pdf", ps.ApplyDigitalSignature());
Console.WriteLine("Signed: " + new FileInfo(@"C:\Demo\Signed\invoice-003-code-lt.pdf").Length + " bytes");

19.3 A certificate from the Windows store or a smart card

When the certificate is in the Windows store (for instance, a qualified certificate on a smart card, section 6.2), load it with a search criterion. No window is shown, so the code can run without a user.

PdfSignature ps = new PdfSignature("serial number");
ps.LoadPdfDocument(@"C:\Demo\Invoices\invoice-001.pdf");

// the first certificate of the current user whose common name (CN) is "Elaine Smith"
// true = only the valid certificates (issued by a trusted authority); false = any certificate, also a self-signed test one
ps.DigitalSignatureCertificate = DigitalCertificate.LoadCertificate(false, DigitalCertificateSearchCriteria.CommonNameCN, "Elaine Smith");

// only for a certificate on a smart card or on a token: the PIN, to avoid the PIN window. It applies to the next
// signature, made on this thread (a software certificate, like this one, does not use a PIN)
// DigitalCertificate.SmartCardPin = "1234";

File.WriteAllBytes(@"C:\Demo\Signed\invoice-001-code-store.pdf", ps.ApplyDigitalSignature());
Console.WriteLine("Signed with the certificate: " + ps.DigitalSignatureCertificate.Subject);
The PIN is used for one signature

SmartCardPin is cleared after every signature. When you sign several documents, set it again before each call of ApplyDigitalSignature, as in the next example. Use it only for certificates on a smart card or a token: for a software certificate it is an error. Some smart cards do not support this feature: in that case the PIN window of the middleware is shown.

Other search criteria are the other fields of the subject (OrganizationO, EmailE...), the thumbprint and the serial number of the certificate. To let the user choose the certificate in a Windows window, call DigitalCertificate.LoadCertificate() without parameters.

19.4 Sign all the documents of a folder

Create the PdfSignature object once, and load and sign each document of the folder. For a smart card, set the PIN before every signature. A document that fails must not stop the others.

PdfSignature ps = new PdfSignature("serial number");
ps.DigitalSignatureCertificate = DigitalCertificate.LoadCertificate(@"C:\Demo\elaine.pfx", "123456");
ps.SignatureStandard = PdfSignatureStandard.Pades;

foreach (string file in Directory.GetFiles(sourceFolder, "*.pdf"))
{
    try
    {
        // DigitalCertificate.SmartCardPin = "1234";      // for a smart card: before each signature
        ps.LoadPdfDocument(file);
        File.WriteAllBytes(Path.Combine(destinationFolder, Path.GetFileNameWithoutExtension(file) + "-code-folder.pdf"), ps.ApplyDigitalSignature());
        Console.WriteLine("Signed: " + Path.GetFileName(file));
    }
    catch (Exception ex)
    {
        // an error on a file does not stop the other files
        Console.WriteLine("Error: " + file + ": " + ex.Message);
    }
}

19.5 The appearance of the signature

PdfSignature ps = new PdfSignature("serial number");
ps.LoadPdfDocument(@"C:\Demo\Invoices\invoice-001.pdf");
ps.DigitalSignatureCertificate = DigitalCertificate.LoadCertificate(@"C:\Demo\elaine.pfx", "123456");

ps.VisibleSignature = true;                                               // false = invisible signature
ps.SignaturePages = new List<int> { 1, int.MaxValue };                    // the pages of the signature (int.MaxValue = the last page)
ps.SignatureAdvancedPosition = new System.Drawing.Rectangle(300, 40, 220, 70);   // x, y (from the bottom left corner), width, height
ps.FontName = "Helvetica";
ps.SignatureText = "Digitally signed by Elaine Smith";                      // your own text, instead of the default text

File.WriteAllBytes(@"C:\Demo\Signed\invoice-001-code-appearance.pdf", ps.ApplyDigitalSignature());
Console.WriteLine("Signed: appearance on the pages of the list");

The signature box can also contain an image (SignatureImage, SignatureImageType) and uses the font of your choice (FontName for the standard fonts, FontFile for a font file).

19.6 Certify and encrypt

A certifying signature (the first signature of a document) and the encryption of the signed document, with an open password and a permissions password:

PdfSignature ps = new PdfSignature("serial number");
ps.LoadPdfDocument(@"C:\Demo\Invoices\invoice-002.pdf");
ps.DigitalSignatureCertificate = DigitalCertificate.LoadCertificate(@"C:\Demo\elaine.pfx", "123456");

// a certifying signature: only the author, and only on a document that is not signed yet
ps.CertifySignature = CertifyMethod.NoChangesAllowed;

File.WriteAllBytes(@"C:\Demo\Signed\invoice-002-code-certified.pdf", ps.ApplyDigitalSignature());

PdfSignature check = new PdfSignature("serial number");
check.LoadPdfDocument(@"C:\Demo\Signed\invoice-002-code-certified.pdf");
Console.WriteLine("Certification level: " + check.DocumentProperties.CertificationLevel);
PdfSignature ps = new PdfSignature("serial number");
ps.LoadPdfDocument(@"C:\Demo\Invoices\invoice-001.pdf");
ps.DigitalSignatureCertificate = DigitalCertificate.LoadCertificate(@"C:\Demo\elaine.pfx", "123456");

ps.Encryption.EncryptionMethod = PdfEncryptionMethod.PasswordSecurity;
ps.Encryption.EncryptionAlgorithm = PdfEncryptionAlgorithm.EnhancedEncryption128BitAES;
ps.Encryption.OwnerPassword = "permissions-password";       // to change the restrictions
ps.Encryption.UserPassword = "open-password";              // to open the document (optional)
ps.Encryption.DocumentRestrictions = PdfDocumentRestrictions.AllowPrinting;     // what the recipients can do

File.WriteAllBytes(@"C:\Demo\Signed\invoice-001-code-encrypted.pdf", ps.ApplyDigitalSignature());
Console.WriteLine("Signed and encrypted");

The encrypted document cannot be signed with PadesLT or PadesLTA: the library stops with the error PdfReader not opened with owner password.

19.7 Protected and damaged documents

A document protected with a password is signed with its owner password, which must be set before the document is loaded:

PdfSignature ps = new PdfSignature("serial number");

// a protected document is signed with its owner password (the permissions password): set it before loading the document
ps.DocumentProperties.Password = "permissions-password";
ps.LoadPdfDocument(@"C:\Demo\Signed\invoice-001-code-encrypted.pdf");
ps.DigitalSignatureCertificate = DigitalCertificate.LoadCertificate(@"C:\Demo\elaine.pfx", "123456");

try
{
    File.WriteAllBytes(@"C:\Demo\Signed\invoice-001-code-encrypted-2.pdf", ps.ApplyDigitalSignature());
    Console.WriteLine("Signed a protected document");
}
catch (Exception ex)
{
    Console.WriteLine("Not signed: " + ex.Message);
}

A damaged document (its structure had to be repaired when it was loaded, DocumentProperties.IsDamaged) is rebuilt before signing. If it already has signatures, the rebuild makes them invalid, so the library signs it only when you allow it with RebuildDamagedSignedDocument:

PdfSignature ps = new PdfSignature("serial number");
ps.LoadPdfDocument(@"C:\Demo\Check\invoice-damaged.pdf");
ps.DigitalSignatureCertificate = DigitalCertificate.LoadCertificate(@"C:\Demo\elaine.pfx", "123456");

Console.WriteLine("Damaged: " + ps.DocumentProperties.IsDamaged + ", signatures: " + ps.DocumentProperties.DigitalSignatures.Count);

// a damaged document that is already signed is rebuilt only when you allow it: the existing signatures become invalid
try
{
    ps.ApplyDigitalSignature();
}
catch (InvalidOperationException ex)
{
    Console.WriteLine("Not signed: " + ex.Message);
    ps.RebuildDamagedSignedDocument = true;
    File.WriteAllBytes(@"C:\Demo\Check\invoice-damaged-rebuilt.pdf", ps.ApplyDigitalSignature());
    Console.WriteLine("Signed after the rebuild");
}

The result:

Damaged: True, signatures: 1
Not signed: The PDF document is damaged (its structure has errors that were repaired when it was loaded) and it is already signed. A damaged document cannot be signed incrementally: it must be rebuilt, which makes the existing signatures invalid. Set RebuildDamagedSignedDocument to true to sign it anyway.
Signed after the rebuild

19.8 Good to know

SituationWhat happens
No valid serial number in new PdfSignature("...")The library works in demonstration mode: it writes a message on the console and adds the text SignLib.dll DEMO VERSION on the first page of the documents.
DigitalSignatureCertificate not setA NullReferenceException is thrown (Digital certificate is not set.).
ApplyDigitalSignature before LoadPdfDocumentA NullReferenceException is thrown (Document is not loaded.).
The document does not existA FileNotFoundException is thrown.
The password of the PFX file is wrongA CryptographicException is thrown by DigitalCertificate.LoadCertificate.
A page of the signature that the document does not haveAn ArgumentOutOfRangeException is thrown (Invalid signature page number). Check DocumentProperties.NumberOfPages, or use SignaturePages with int.MaxValue for the last page.
The signature cannot be created (for example, a wrong PIN)An exception is thrown. Do not retry with the same PIN: repeated wrong PINs lock the card.
PadesLTA without TimeStamping.ServerUrlA NullReferenceException is thrown (Time Stamp Server URL must be set.).
PadesLT without TimeStamping.ServerUrlNo error, but the signature has no time stamp: it is not a complete PAdES-B-LT signature. Always set the address of the time stamp server for PAdES-B-T, -LT and -LTA.
The size of the CRLThe largest CRL that is included in the long term formats can be limited with ps.MaxCrlSize (in bytes; the default is 1 MB).
Qualified signatures from code

The code creates the same PAdES signature whatever the certificate is. A qualified electronic signature needs a qualified certificate on a QSCD (section 7): load the certificate of the smart card or of the token as in section 19.3, and check the result with the European validator (section 7.4).

20. Problems and solutions

What you seeWhat to do
Windows protected your PC when you start the setupWindows SmartScreen does not know the new setup file yet. Click More info and then Run anyway, if you downloaded the file from www.signfiles.com (section 2).
Invalid license code.The serial number has 20 characters. Retype it exactly as you received it, without extra characters (section 3).
PDF Signer has expired. Would you like to purchase the registered version...?The trial period ended. Register with your license code (section 3).
The digital certificate is not selected. To sign PDF documents, click 'Select the Digital Certificate...'.Click Select the Digital Certificate... and choose a certificate (section 6).
The digital certificate '...' was not found in the Windows certificate store. If it is on a token or smart card, insert it and try again.The certificate that you selected is on a token that is not connected, or it was removed from Windows. Insert the token and sign again, or select another certificate (section 6.2).
The certificate of the smart card or USB token is not in the listConnect the token and check that its middleware is installed. The certificate must be in the Windows Certificate Store: open certmgr.msc and look in Personal. If it is not there, use the options of the middleware that copy or register the certificates in the Windows store. Then open the certificate window again, or click Refresh in it.
The certificate is not in the list although it is in the storeThe list shows only the certificates that can sign: with a private key, and not only for encryption or for web servers. An expired certificate is at the end of the list, marked EXPIRED; it cannot be selected for signing.
The token or smart card of the digital certificate is not inserted, or it cannot be accessed. Insert it and try again.The token was removed during the signing, or it cannot be read. Connect it and sign again.
The PIN entry was cancelled, so the document was not signed.You closed the PIN window of the token. Sign again and type the PIN.
The PIN of the token or smart card is not correct. or The token or smart card is blocked...Stop and check the PIN before you try again: most tokens are blocked after a few wrong attempts. If the token is blocked, contact the provider of the certificate.
The smart card PIN was rejected and it is not used again until the application is restarted...Correct the PIN in the certificate window. The program will not keep trying with a wrong PIN, to protect the token.
The digital certificate ... expired on ... An expired certificate cannot be used to sign documents.Choose a valid certificate or renew yours with your provider.
The private key of the selected certificate cannot be found.The certificate on the computer has no key to sign with. Import the full certificate (including the private key), or connect your USB token.
The certificate cannot be read from the PFX file: the password is not correct, or the file is not a valid PFX file.Retype the password of the PFX file in the certificate window.
The time stamp server or the validation server of the certificate (OCSP, CRL) cannot be reached.Check the Internet connection and the time stamp settings, and use the Test the Server button (section 8).
The Long-term signature requires a time stamp server, but the Time Stamp Server URL is not valid.Open Time Stamping Settings... and type a valid address (section 8). (The text names the selected format: the Long-term signature or the Archive signature.)
An encrypted document cannot be signed with the Long-term signature (or the Archive signature)...Select the Standard signature, or untick Encrypt document (section 10).
Warning: the certificate is not intended to sign documents...The certificate was issued for another purpose, for example only for time stamping. The document is still signed, but the validators can report the signature. Use a certificate issued for signing documents (section 6.3).
Enter at least one password... or The open password and the permissions password must be different...In the encryption window, type the passwords as the message says (section 10).
The PDF document is protected with a password and it cannot be opened... or ... it can be signed only with its owner password...Tick Owner password of encrypted PDFs and type the owner (permissions) password of the document (section 11).
The PDF document is damaged ... and it already contains signatures...Click No to keep the existing signatures valid, or Yes to rebuild the document and sign it (the existing signatures become invalid) (section 11).
The selected folder does not contain PDF documents.Pick a folder that contains PDF documents.
The destination file already exists... Do you want to overwrite it?Click Yes to replace it, or No and choose another file name.
The destination folder cannot be the same as the source folder...Choose another destination folder: the originals must not be overwritten.
The configuration contains values that are not valid ...The program lists the values and uses the default ones. Check the settings, then save them again (section 15).
The command does nothing, or the result code is 2Read the message in the command window (section 16). The usual causes: a path that ends with a backslash inside quotes, a destination folder that does not exist, a configuration file that does not exist, an expired certificate, or a program that is not registered.
Adobe Reader says that the validity of the signature is unknownThe certificate is not issued by an authority that Adobe trusts. See section 13.
The European validator reports the signature as not trusted (indeterminate)The certificate is not issued by a trusted provider, for example a self-signed test certificate. Sign with a certificate issued by a certification authority, and with a qualified certificate on a QSCD for a qualified signature (section 7.4).
Library: the program writes This is a demo version of SignLib.dll.The serial number of the library is missing or not valid. Write the serial number in new PdfSignature("...") (section 19).
Need more help?

Visit www.signfiles.com or use the contact link shown in the registration window, www.signfiles.com/contact.

21. Glossary

TermIn plain words
Digital signatureAn electronic seal added to a document. It shows who signed and that the content was not changed.
eIDASThe Regulation (EU) No 910/2014 on electronic identification and trust services. It defines the electronic signatures, seals and time stamps recognised in the European Union.
AdESAdvanced electronic signature: a signature that identifies the signer, is under the sole control of the signer and detects any change of the document.
QESQualified electronic signature: an advanced signature created with a qualified certificate on a QSCD. It has the legal effect of a handwritten signature.
Electronic sealThe electronic signature of a legal entity (a company, an institution). It proves the origin and the integrity of a document.
QSCDQualified signature creation device: a certified device, usually a smart card or a USB token, that keeps the private key and signs inside it.
Qualified certificateA certificate issued by a qualified trust service provider, listed in the EU Trusted Lists.
Qualified time stampA time stamp issued by a qualified trust service provider. The date and the time that it shows are presumed accurate in all the Member States.
EU Trusted ListsThe lists published by the Member States with the qualified trust service providers and their services. Validators use them to decide whether a certificate is qualified.
DSSThe open validation tool of the European Commission (Digital Signature Service), which checks signatures according to the eIDAS rules.
PAdESThe European standard (ETSI EN 319 142-1) for the signatures of PDF documents. Its levels B-B, B-LT and B-LTA are the Standard signature, the Long-term signature and the Archive signature of PDF Signer.
Standard / Long-term / Archive signatureThe three PAdES choices of PDF Signer. The Standard signature is valid while the certificate is valid; the Long-term signature adds a time stamp and the proofs of validity, so it can be verified also after the certificate expires; the Archive signature adds a document time stamp for documents kept for many years.
Compatibility signatureThe older PKCS#7 signature, only for the programs that do not accept PAdES.
Digital certificateYour electronic identity card, issued by a certification authority. It contains your name and a key used to sign.
PFX fileA file (.pfx or .p12, the PKCS#12 format) that holds a certificate and its private key, protected by a password.
Windows Certificate StoreThe place where Windows keeps the certificates installed on the computer or available from tokens and smart cards. It is not the Microsoft Store of applications. Open it with certmgr.msc.
Private keyThe secret part of your certificate. Only you should have it. It is what makes a signature yours.
Smart card / USB tokenA small device that keeps your private key and signs inside it, so the key cannot be copied. It is protected by a PIN.
MiddlewareThe software delivered with a smart card or token (for example SafeNet Authentication Client). It lets Windows and the programs use the device, and usually adds its certificates to the Windows store.
HSMHardware Security Module: a device that keeps the keys of a company and signs on request.
PKCS#11The standard way for a program to use the keys of a token, smart card or hardware security module, through the library of the manufacturer. It is used by PDF Signer Server.
Windows SmartScreenA protection of Windows that warns you about programs it does not know yet. A warning does not mean that the program is infected.
Hash (SHA256)A short fingerprint of the document. If the document changes, the fingerprint changes.
Time stamp / TSAA proof of time issued by a trusted independent service (Time Stamp Authority).
OCSP / CRLWays to ask the certification authority whether a certificate was cancelled (revoked). The answers can be stored in the signature.
LTVLong Term Validation: the signature carries the proofs needed to validate it also after the certificate expires.
Certifying signatureThe first signature of the author of a document, which also sets which changes are allowed afterwards.
Owner passwordThe password that allows changes of a protected PDF document (also its signing). It is not the password that only opens the document.
Self-signed certificateA certificate you create yourself. It works technically but nobody else trusts it. Use it only for tests.
Serial number (license code)The code that registers PDF Signer, received after the purchase. The Signature Library has its own serial number.
SignLib (Signature Library)The .NET library on which PDF Signer is built. It lets programs and PowerShell scripts create and verify the same signatures.
Bulk signingSigning many documents in one operation, or automatically, without a user, from the command line.

Every effort has been made to make this manual as complete and accurate as possible, but no warranty or fitness is implied. The information provided is on an “as is” basis. The author shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this manual. The information about the eIDAS Regulation is a simplified explanation and it is not legal advice.

.NET, Windows, PowerShell, SmartScreen and Visual Studio are trademarks of Microsoft Corporation. Adobe and Adobe Reader are trademarks of Adobe Inc. All other trademarks are the property of their respective owners.