DynaPDF Manual - Page 231

Previous Page 230   Index   Next Page 232

Function Reference
Page 231 of 874
Importing signed PDF files
Signed PDF files can only be changed, without invalidating existing signatures, when changes are
stored with an incremental update. An incremental update is a special way to modify a PDF file;
changes are appended to the end of the file, leaving its original contents intact. This technique is
required since altering any existing bytes in the file invalidates existing signatures.
How incremental updates can be applied is described in detail at Incremental Updates.
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 only be closed and signed if the certificate
file was valid and if no other error occurred during the parsing process.
If an error occurred due to an 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 use the function
HaveOpenDoc(). The function returns true if the PDF file is still 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 CreateNewPDF(), GetBuffer(), FreePDF().
Remarks:
Further information about digital signatures can be found under Digital Signatures. To encrypt and
sign a PDF file use the function CloseAndSingFileEx(). 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.
CloseAndSignFileEx
Syntax:
SI32 pdfCloseAndSignFileEx(
const PPDF* IPDF,
// Instance pointer
const char* OpenPwd,
// Optional Open password
const char* OwnerPwd,
// Optional Owner password
TKeyLen KeyLen,
// Key length (40 or 128 bit)
TRestrictions Restrict, // Restrictions
 

Previous topic: CloseAndSignFile

Next topic: Importing signed PDF files, Possible function errors