CosSignPdfThe CosSignPdf dll (cossignpdf.dll) allows you to sign PDF documents from Cosmos using a digital certificate. This certificate must be installed in the system, either in the Windows certificate store or in a certificate store (file).

CosSignPdf uses JSignPDF software, which is freeware software developed in Java. For this reason, it is necessary that a 32-bit Java virtual machine is installed in the system, and that the directory where the JVM.DLL file is located is included in the search path.

This utility is available as of version 7.0 of Cosmos.

Functions of the CosSignPdf DLLIr al principio de la página

The steps to sign a PDF document from Cosmos are the following:

  1. Execute the CosSignPDFCreateSigner function to obtain a driver that allows us to execute the functions necessary to carry out the signature process.
  2. Assignment of properties (name of the PDF file to be signed, extension of the PDF file of signed output, certificate to be used, visibility of the signature, etc.). This assignment will be made by making calls to the CosSignPDFSetProperty function (one call for each property to assign).
  3. Execution of the signature process with the call to the CosSignPDFDoSign function.
  4. Liberación de los recursos utilizados durante el proceso de firma con la ejecución de la función Cos-SignPDFFreeSigner.


This function returns a unique numerical identifier that will be necessary for the execution of the signature property assignment functions and for the signature process itself.


This function assigns a value to a property of the signature.


This function allows you to make the signature of the PDF document.


This function allows you to define the name of the file where the error messages will be stored in case you want these messages not to be displayed in a window (default option, MessageBox).


In this function it will be indicated that the resources of the signature handler passed as a parameter are re-leased.

After executing this function, the identifier passed as a parameter can not be used again to sign a document. A new identifier must be created by executing the CosSignPDFCreateSigner function.

List of signature properties in the CosSignPDFSetProperty functionIr al principio de la página

a) Properties related to the definition of the certificate store, certificate and passwords:

Property Description
CERTTYPE Indicates the type of certificates store.
KEYSTOREFILE If the certificate store is a file, with this parameter we will indicate its absolute path.
KEYSTOREPASSWD Password of the certificate store.
KEYALIAS Name of certificate in the certificate store that you want to use. If no certificate is indicated, the first certificate from the certificate store will be used.
KEYPASSWD Password of the certificate that you want to use.
KEYINDEX If it is not possible to indicate the name of the certificate that you want to use, with this parameter we can choose it by indicating its position within the certificate store. Thus, the first certificate will be the number 0, the second the number 1, etc.

b) Properties related to the name of the source PDF, the name of the destination PDF and the folder where the signed PDF will be stored:

Property Description
OUTFILESUFFIX Suffix of the name of the signed PDF file. If this parameter is not indicated, the signed PDF file will have the suffix "_signed".
PDFFILENAME Absolute path of the PDF file that you want to sign. It is possible to indicate more than one file using wildcards, for example: "C: \documents\*. Pdf" indicates that all files with PDF extension that are in the folder "c:\documents" are signed.
OUTPUTFOLDER Absolute path of the directory where you want to save the signed PDF.

c) Properties referring to the visibility / invisibility of the signature, page where it is positioned and positioning coordinates. These properties will take effect only if the VISIBLESIGNATURE property has a TRUE value.

Property Description
VISIBLESIGNATURE TRUE if you want the signature to be visible in the PDF document.
SIGNATURETEXT Text that you want to show in the signature. If no value is assigned to this property, the name of the owner of the signature will be displayed.
IMAGEPATH If you want the PDF file to show an image (digital signature, logo, etc.) in the place where the signature will be embedded, you must indicate its absolute path assigning value to this property.
UPPERRIGHTX X coordinate of the upper right corner of the rectangle where the signature will be positioned.
UPPERRIGHTY Y coordinate of the upper right vertex of the rectangle where the signature will be positioned.
LOWERLEFTX X coordinate of the lower left corner of the rectangle where the signature will be positioned.
LOWERLEFTY Y coordinate of the lower left corner of the rectangle where the signature will be positioned.
PAGENUMBER Number of the page where you want to embed the signature. If no value is indicated, it will be embedded in the last page of the document.

Coordinate system in PDF documentsIr al principio de la página

When indicating the coordinates of the rectangle where you want to position the signature in a PDF document, the following must be taken into account:

ExamplesIr al principio de la página

In the PDF document you can consult the following digital signature examples: