Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

DynaPDF Manual - Page 183

Previous Page 182   Index   Next Page 184

Function Reference
Page 183 of 750
Possible function errors
When trying to sign a PDF file the function must first parse the certificate file before a signature can
be created. This process can fail, due to an invalid file path or due to an unsupported certificate file
format that was passed to the function. The PDF file will be closed and signed if the certificate file
was valid and no other error occurred during the parsing process of the certificate file.
If an error occurred during the parsing process, e.g. invalid certificate file, invalid file path and so on,
the function returns zero and passes an error message to the error callback function if any. All errors
during the parsing process of the certificate file are non-fatal so that the PDF file is still in memory
when the function returns. It is then possible to change the certificate file and trying to sign the PDF
file again.
To determine whether the PDF was already deleted or of it is still in memory call the function
HaveOpenDoc(). The function returns true if the PDF file is in memory. If the function returns false,
the last error was fatal and the PDF file has already been deleted.
The buffer of a memory based PDF file can be returned by GetBuffer() after this function was called.
Note that GetBuffer() does not free the used resources because it returns a pointer to the original
buffer. After the buffer was processed by your application call FreePDF() to free the uses resources.
See also CreateSigFieldAP(), CreateNewPDF(), GetBuffer(), FreePDF().
Remarks:
Further information about digital signatures can be found under Digital Signatures. The appearance
of a signature field can be user defined. See CreateSigFieldAP() for further information.
Return values:
If the function succeeds the return value is 1. If the function fails the return value is 0.
CloseAndSignFileExt
Syntax:
LBOOL pdfCloseAndSignFileExt(
const PPDF* IPDF,
// Instance pointer
struct TPDFSigParms* SigParms) // Important parameters
typedef enum
{
htDetached, // Byte ranges of the finish PDF file will be returned
htSHA1
// The SHA1 hash to be signed will be returned
}THashType;
struct TPDFSigParms
{
UI32
StructSize;
// Must be set to sizeof(TSignParms)
UI32
PKCS7ObjLen;
// Max length of the signed PKCS#7 object
THashType
HashType;
// See description
const BYTE*
Range1;
// Out -> Hash or byte range
UI32
Range1Len;
// Out -> Length of the buffer
 

Previous topic: Importing signed PDF files

Next topic: Hardware Certificates