PDF SDK Documentation

Comprehensive Guide for Developers: Features, Integration, and API Reference

Loading...
Searching...
No Matches
security.h File Reference

Security API. More...

Go to the source code of this file.

Classes

struct  PDSecurityHandler
 
struct  PDStdSecurityParams
 

Typedefs

typedef enum PDPermReqObj PDPermReqObj
 Specifies the type of object to check permissions for.
 
typedef enum PDPermReqOp PDPermReqOp
 Specifies the operation to check permissions for.
 
typedef PDErrCode(PDFSDK_CALLCONV * PDCryptNewAuthDataProc) (void *clientData, void **pAuthData)
 
typedef PDErrCode(PDFSDK_CALLCONV * PDCryptFreeAuthDataProc) (void *authData)
 
typedef PDErrCode(PDFSDK_CALLCONV * PDCryptNewSecurityDataProc) (void *clientData, PDObject encryptDict, void **pSecurityData)
 
typedef PDErrCode(PDFSDK_CALLCONV * PDCryptCopySecurityDataProc) (void *securityData, void **pSecurityData)
 
typedef PDErrCode(PDFSDK_CALLCONV * PDCryptFreeSecurityDataProc) (void *securityData)
 
typedef PDErrCode(PDFSDK_CALLCONV * PDCryptGetKeyDataProc) (void *securityData, PDAtom cryptFilter, PDObject decodeParms, void *buffer, size_t bufsize, size_t *pSize, PDAtom *pMethod)
 
typedef PDErrCode(PDFSDK_CALLCONV * PDCryptEncryptProc) (void *securityData, const void *input, size_t inputSize, void *output, size_t outputSize, uint32_t objnum, uint16_t generation, PDAtom cryptFilter, PDObject decodeParms, size_t *pOutputSize)
 
typedef PDErrCode(PDFSDK_CALLCONV * PDCryptAuthorizeProc) (void *securityData, PDPermReqObj object, PDPermReqOp operation, const void *authData, bool *pGranted)
 
typedef PDErrCode(PDFSDK_CALLCONV * PDCryptFillEncryptDictProc) (void *securityData, PDDoc doc, PDObject encryptDict)
 
typedef PDErrCode(PDFSDK_CALLCONV * PDCryptEncryptMetadataProc) (void *securityData, bool *pEncrypt)
 
typedef PDErrCode(PDFSDK_CALLCONV * PDCryptFreeClientDataProc) (void *clientData)
 
typedef struct PDSecurityHandler PDSecurityHandler
 
typedef void * PDStdSecurityData
 
typedef uint32_t PDStdPerms
 
typedef wchar_t PDStdPassword[kPDStdPasswordMaxChars+1]
 
typedef uint32_t PDStdSecurityModifyFlags
 

Enumerations

enum  PDPermReqObj {
  kPDPermReqObjDoc , kPDPermReqObjPage , kPDPermReqObjContent , kPDPermReqObjAnnot ,
  kPDPermReqObjForm , kPDPermReqObjBookmark , kPDPermReqObjAttachment
}
 Specifies the type of object to check permissions for. More...
 
enum  PDPermReqOp {
  kPDPermReqOpInsert , kPDPermReqOpDelete , kPDPermReqOpMove , kPDPermReqOpRotate ,
  kPDPermReqOpModify , kPDPermReqOpExtract , kPDPermReqOpAccessible , kPDPermReqOpOpen ,
  kPDPermReqOpSecure , kPDPermReqOpPrint , kPDPermReqOpPrintHigh , kPDPermReqOpFillIn ,
  kPDPermReqOpFullSave , kPDPermReqOpCopy , kPDPermReqOpCopyForAccessibility , kPDPermReqOpCreationOfTemplatePages ,
  kPDPermReqOpAllowDocAssembly
}
 Specifies the operation to check permissions for. More...
 
enum  {
  kPDStdPermOpen = 0x01 , kPDStdPermSecure = 0x02 , kPDStdPermPrint = 0x04 , kPDStdPermEdit = 0x08 ,
  kPDStdPermCopy = 0x10 , kPDStdPermEditNotes = 0x20 , kPDStdPermSaveAs = 0x40 , kPDStdPermExt = 0x80 ,
  kPDStdPermFillAndSign = 0x100 , kPDStdPermAccessible = 0x200 , kPDStdPermDocAssembly = 0x400 , kPDStdPermHighPrint = 0x800 ,
  kPDStdPermOwner = 0x8000 , kPDStdPermFormSubmit = 0x10000 , kPDStdPermFormSpawnTempl = 0x20000
}
 Specifies the user access permissions. More...
 
enum  { kPDStdPasswordMaxChars = 255 }
 Specifies the maximum number of characters allowed for a password.
 
enum  { kPDStdSecurityModifyUserPassword = 0x01 , kPDStdSecurityModifyOwnerPassword = 0x02 }
 Specifies the type of password being modified.
 

Functions

PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocSetNewSecurityHandler (PDDoc doc, PDAtom name, void *securityData)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetSecurityHandlerData (PDDoc doc, void **pSecurityData)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetSecurityHandlerName (PDDoc doc, PDAtom *pName)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetNewSecurityHandlerData (PDDoc doc, void **pSecurityData)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetNewSecurityHandlerName (PDDoc doc, PDAtom *pFilter)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocEncryptionIsModified (PDDoc doc, bool *pValue)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocPermRequest (PDDoc doc, PDPermReqObj permReqObj, PDPermReqOp permReqOp, const void *authData, bool *pGranted)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocPermRequestSecurity (PDDoc doc, PDPermReqObj permReqObj, PDPermReqOp permReqOp, const void *authData, bool *pGranted)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocPermRequestWithAuth (PDDoc doc, PDPermReqObj permReqObj, PDPermReqOp permReqOp, bool *pGranted)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDSecurityRegisterHandler (PDAtom filter, const PDSecurityHandler *handler, void *clientData)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDSecurityNewAuthData (PDAtom filter, void **pAuthData)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDSecurityFreeAuthData (PDAtom filter, void *authData)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDStdSecurityDataNew (PDDoc doc, PDStdSecurityData *pSecurityData)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDStdSecurityDataUpdateParams (PDStdSecurityData securityData, PDStdSecurityModifyFlags modifyFlags, const PDStdSecurityParams *params)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDStdSecurityDataGetParams (PDStdSecurityData securityData, PDStdSecurityParams *pParams)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDStdSecurityDataFree (PDStdSecurityData securityData)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDStdPasswordSetChars (PDStdPassword *authData, const wchar_t *chars)
 

Detailed Description

Security API.

Typedef Documentation

◆ PDPermReqObj

typedef enum PDPermReqObj PDPermReqObj

Specifies the type of object to check permissions for.

It is used in conjunction with PDPermReqOp to check permissions for a specific operation on one of the objects below.

For more information refer to section 7.7 Document structure, from the ISO 32000-2:2020 (PDF 2.0) Standard.

See also
PDPermReqOp
PDDocPermRequest
PDDocPermRequestSecurity
PDDocPermRequestWithAuth
RequestPermission

◆ PDPermReqOp

typedef enum PDPermReqOp PDPermReqOp

Specifies the operation to check permissions for.

It is used in conjunction with PDPermReqObj to check permissions to perform one of the operations below on a specific object.

See also
PDPermReqObj
PDDocPermRequest
PDDocPermRequestSecurity
PDDocPermRequestWithAuth
RequestPermission

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Specifies the user access permissions.

For more information refer to section 7.6.4 Standard security handler, Table 22 — Standard security handler user access permissions, from the ISO 32000-2:2020 (PDF 2.0) Standard.

Enumerator
kPDStdPermOpen 

Opening an encrypted document.

kPDStdPermSecure 

Applying security to a document.

kPDStdPermPrint 

Print the document. Bit position 3.

kPDStdPermEdit 

Modify the contents of the document by operations other than those controlled by bits 6, 9, and 11. Bit position 4.

kPDStdPermCopy 

Copy or otherwise extract text and graphics from the document. Bit position 5.

kPDStdPermEditNotes 

Add or modify text annotations, fill in interactive form fields. If bit 4 is also set (kPDStdPermEdit), create or modify interactive form fields (including signature fields). Bit position 6.

kPDStdPermSaveAs 

Permits a user to save the document along with modified form and/or annotation data. See 12.8.2.3 UR, Table 258 — Entries in the UR transform parameters dictionary, key Document.

kPDStdPermExt 

Permits the user to export form data files as FDF or XFDF. See 12.8.2.3 UR. Table 258 — Entries in the UR transform parameters dictionary, key Form.

kPDStdPermFillAndSign 

Permits a user to apply a digital signature to an existing signature form field or clear a signed signature form field. See 12.8.2.3 UR. Table 258 — Entries in the UR transform parameters dictionary, key Signature.

kPDStdPermAccessible 

Used to determine whether content could be extracted for the purposes of accessibility. Deprecated in PDF 2.0. Bit position 10.

kPDStdPermDocAssembly 

Assemble the document (insert, rotate, or delete pages and create document outline items or thumbnail images). Bit position 11.

kPDStdPermHighPrint 

Print the document in high quality. Bit position 12.

kPDStdPermFormSubmit 

Permits the user to submit form data when the document is not open in a Web browser. See 12.8.2.3 UR. Table 258 — Entries in the UR transform parameters dictionary, key Form.

kPDStdPermFormSpawnTempl 

Permits new pages to be instantiated from named page templates. See 12.8.2.3 UR. Table 258 — Entries in the UR transform parameters dictionary, key Form.

◆ PDPermReqObj

Specifies the type of object to check permissions for.

It is used in conjunction with PDPermReqOp to check permissions for a specific operation on one of the objects below.

For more information refer to section 7.7 Document structure, from the ISO 32000-2:2020 (PDF 2.0) Standard.

See also
PDPermReqOp
PDDocPermRequest
PDDocPermRequestSecurity
PDDocPermRequestWithAuth
RequestPermission
Enumerator
kPDPermReqObjDoc 

The document object also called 'document catalog'.

kPDPermReqObjPage 

The page object, contained within the page tree.

kPDPermReqObjContent 

The content stream, part of the page object.

kPDPermReqObjAnnot 

The annotation object, part of the page object.

kPDPermReqObjForm 

The form object, part of the AcroForm dictionary, which is located in the Document Catalog.

kPDPermReqObjBookmark 

The bookmark or 'outline entry' object. See 12.3.3 Document outline.

kPDPermReqObjAttachment 

The attachment or embedded files object See 7.7.2 Document catalog dictionary, Table 29 — Entries in the catalog dictionary and 7.7.4 Name dictionary, key EmbeddedFiles.

◆ PDPermReqOp

Specifies the operation to check permissions for.

It is used in conjunction with PDPermReqObj to check permissions to perform one of the operations below on a specific object.

See also
PDPermReqObj
PDDocPermRequest
PDDocPermRequestSecurity
PDDocPermRequestWithAuth
RequestPermission
Enumerator
kPDPermReqOpInsert 

An insert operation.

kPDPermReqOpDelete 

A delete operation.

kPDPermReqOpMove 

A move operation.

kPDPermReqOpRotate 

A rotate operation.

kPDPermReqOpModify 

A modify operation.

kPDPermReqOpExtract 

Copy or extract operation.

kPDPermReqOpAccessible 

An operation to extracted content for the purposes of accessibility.

kPDPermReqOpOpen 

An opening operation.

kPDPermReqOpSecure 

Checking the security permissions related to the 'document catalog' kPDPermReqObjDoc object.

kPDPermReqOpPrint 

A print operation.

kPDPermReqOpPrintHigh 

A high quality print operation.

kPDPermReqOpFillIn 

An operation to fill in existing interactive form fields (including signature fields).

kPDPermReqOpFullSave 

An operation to rewrite the entire PDF file, incorporating all changes.

kPDPermReqOpCopy 

A operation to copy or otherwise extract text and graphics from the document.

kPDPermReqOpCopyForAccessibility 

A operation to copy or otherwise extract text and graphics from the document for accessibility.

kPDPermReqOpCreationOfTemplatePages 

A operation to create invisible template pages. See 7.7.3.3 Page objects, key Type.

kPDPermReqOpAllowDocAssembly 

A operation to assemble a document.

Function Documentation

◆ PDDocGetNewSecurityHandlerData()

PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetNewSecurityHandlerData ( PDDoc doc,
void ** pSecurityData )

Gets the security data structure for the specified document's new security handler. Use PDDocGetSecurityData() to get the security data structure for the document's current security handler. The new security handler is used to encrypt the document during a save. Handler's copySecurityData is used to create the returned pointer

Parameters
docThe document whose new security data structure is obtained.
securityHandlerDataA pointer to the security data structure.
See also
PDDocGetSecurityData
PDDocSetNewSecurityHandler
PDDocGetSecurityHandlerName
PDDocGetNewSecurityHandlerName
PDDocPermRequest

◆ PDDocGetNewSecurityHandlerName()

PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetNewSecurityHandlerName ( PDDoc doc,
PDAtom * pFilter )

Gets the name of the new security handler.

"Standard" is the name of the default password protection handler

See also
PDDocGetSecurityData
PDDocGetNewSecurityData
PDDocSetNewSecurityHandler
PDDocPermRequest

◆ PDDocGetSecurityHandlerData()

PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetSecurityHandlerData ( PDDoc doc,
void ** pSecurityData )

Gets the security data structure for the specified document's current security handler. Use PDDocGetNewSecurityData() to get the security data structure for the document's new security handler. The current security handler is the security handler that is used to decrypt the current document and encrypt the document during a save if a new security handler is not set. Handler's copySecurityData is used to create the returned pointer

Parameters
docThe document whose new security data structure is obtained.
securityHandlerDataA pointer to the security data structure.
See also
PDDocGetSecurityData
PDDocSetNewSecurityHandler
PDDocGetSecurityHandlerName
PDDocGetNewSecurityHandlerName
PDDocPermRequest

◆ PDDocGetSecurityHandlerName()

PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetSecurityHandlerName ( PDDoc doc,
PDAtom * pName )

Gets the name of the current security handler.

"Standard" is the name of the default password protection handler

See also
PDDocGetSecurityData
PDDocGetNewSecurityData
PDDocSetNewSecurityHandler
PDDocPermRequest

◆ PDDocSetNewSecurityHandler()

PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocSetNewSecurityHandler ( PDDoc doc,
PDAtom name,
void * securityData )

Sets the specified document's new security handler. The new security handler is used to encrypt the document during a save.

Parameters
docThe document whose new security handler is set.
nameThe PDAtom for the name of the new security handler to use for the document. This name must be the same as the pdfName used when the security handler was registered using PDRegisterSecurityHandler().
securityDataThe new security data structure to set for doc. If the call succeeds, doc will take ownership of securityData and will free it later using PDSecurityHandler::freeSecurityData
See also
PDRegisterSecurityHandler