DAOpenFileWithEncryptionKeyA
Document management, Direct access functionality, Security
Description
The trailing A denotes the ANSI (char) DLL entry point; the ActiveX/COM surface exposes only the Unicode form. Behaviour is identical to DAOpenFileWithEncryptionKey and string arguments are interpreted using the current SetAnsiMode code pageOpens an encrypted PDF for authorised recovery or investigation by accepting the hexadecimal file-encryption key directly instead of deriving it from a password. The file is opened through a source-read-only handle and cannot be appended to in place
Syntax
Delphi
Function DLDAOpenFileWithEncryptionKeyA(InstanceID: Integer; InputFileName, EncryptionKeyHex: PAnsiChar; Options: Integer): Integer; Stdcall;DLL
int DLDAOpenFileWithEncryptionKeyA(int InstanceID, const char * InputFileName, const char * EncryptionKeyHex, int Options);Parameters
| InputFileName | The path and name of the encrypted PDF |
|---|---|
| EncryptionKeyHex | An even-length ASCII hexadecimal key with no prefix or whitespace; revisions 2 through 4 require the exact key length declared by the encryption dictionary and revisions 5 through 7 require 32 bytes |
| Options | Zero requires an available verifier; PDF_RAW_KEY_ALLOW_UNVERIFIED permits an otherwise valid key only when the document has no usable verifier |
Return values
| Non-zero | A Direct Access file handle |
|---|---|
| 0 | The input could not be opened; inspect LastErrorCode, including PDFLIB_ERROR_RAW_ENCRYPTION_KEY_INVALID for invalid syntax, length, options or verification |
Remarks
Available revision 2 through 4 /U values and revision 5 through 7 /Perms values are always checked; PDF_RAW_KEY_ALLOW_UNVERIFIED never accepts a mismatchCall
DAGetEncryptionKeyValidation after opening to distinguish verified and explicitly unverified handles. The ANSI strings are widened with the current
SetAnsiMode code page before the request is processed. The key is sensitive credential material and should be obtained, transported and stored under the same controls as a document password