PDF SDK Documentation

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

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

Document API. More...

Go to the source code of this file.

Classes

struct  PDVersion
 
struct  PDPageRange
 
struct  PDDocAuthProcs
 
struct  PDDocStreamProcs
 
struct  PDDocOpenParams
 
struct  PDOptSaveSettings
 
struct  PDDocSaveParams
 

Macros

#define kPDPageIndexNull   ((size_t)(-1))
 

Typedefs

typedef struct PDPageRec_ * PDPage
 
typedef void(PDFSDK_CALLCONV * PDDocPagesChangedProc) (PDPageOperation operation, const PDPageRange *pageRange, void *clientData)
 
typedef PDErrCode(PDFSDK_CALLCONV * PDDocAuthProc) (void *authProcData, PDAtom securityHandlerName, void *pAuthData)
 
typedef PDErrCode(PDFSDK_CALLCONV * PDDocAuthFreeDataProc) (void *authProcData)
 
typedef PDErrCode(PDFSDK_CALLCONV * PDDocStreamReadAtProc) (void *streamData, uint64_t pos, void *buffer, size_t nbytes, size_t *pRead)
 
typedef PDErrCode(PDFSDK_CALLCONV * PDDocStreamGetSizeProc) (void *streamData, uint64_t *pSize)
 
typedef PDErrCode(PDFSDK_CALLCONV * PDDocStreamFreeDataProc) (void *streamData)
 
typedef uint32_t PDDocSaveFlags
 
typedef uint32_t PDOptSaveFlags
 

Enumerations

enum  PDPageOperation {
  kPDInsertPages , kPDDeletePages , kPDMovePages , kPDRotatePages ,
  kPDResizePages
}
 
enum  PDDocSaveFlagsBits {
  kPDDocSaveIncremental = 0x01 , kPDDocSaveFull = 0x02 , kPDDocSaveCopy = 0x04 , kPDDocSaveLinearized = 0x08 ,
  kPDDocSaveCompressed = 0x10 , kPDDocSaveXRefCompressed = 0x20
}
 
enum  {
  kPDOptSaveRemoveHiddenObjects = 1 << 0 , kPDOptSaveDownsampleImages = 1 << 1 , kPDOptSaveRemoveMetadata = 1 << 2 , kPDOptSaveRemoveStructTree = 1 << 3 ,
  kPDOptSaveRemoveAttachments = 1 << 4 , kPDOptSaveRemoveBookmarks = 1 << 5 , kPDOptSaveRemoveAcroform = 1 << 6 , kPDOptSaveRemoveOCProperties = 1 << 7 ,
  kPDOptSaveRemoveAnnotations = 1 << 8 , kPDOptSaveRemoveOpenActions = 1 << 9 , kPDOptSaveRemoveJavaScript = 1 << 10 , kPDOptSaveRemoveInfo = 1 << 11
}
 
enum  PDOptSaveImageQuality {
  kPDOptSaveImageQualityMin , kPDOptSaveImageQualityLow , kPDOptSaveImageQualityMedium , kPDOptSaveImageQualityHigh ,
  kPDOptSaveImageQualityMax
}
 
enum  PDPageDirection { kPDPageDirectionL2R , kPDPageDirectionR2L }
 

Functions

PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocCreate (PDDoc *pDoc)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocOpen (const PDDocOpenParams *params, PDDoc *pDoc)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocIsCompressed (PDDoc doc, bool *pValue)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocIsModified (PDDoc doc, bool *pValue)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocSetModified (PDDoc doc, bool value)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocSave (PDDoc doc, const PDDocSaveParams *params)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocPurgeCaches (PDDoc doc)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetFilePath (PDDoc doc, wchar_t *buffer, size_t bufSize, size_t *pSize)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetPage (PDDoc doc, size_t index, PDPage *pPage)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetNumPages (PDDoc doc, size_t *pNumPages)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocAttachPagesChangedCallback (PDDoc doc, PDDocPagesChangedProc proc, void *clientData)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocDetachPagesChangedCallback (PDDoc doc, PDDocPagesChangedProc proc, void *clientData)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocNotifyPagesChanged (PDDoc doc, PDPageOperation operation, const PDPageRange *range)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocCreatePage (PDDoc doc, size_t insertAt, const PDRectF *mediaBox, PDPage *pPage)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocCreatePages (PDDoc doc, size_t insertAt, size_t count, const PDRectF *mediaBox)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocDeletePages (PDDoc doc, const PDPageRange *range, const PDProgressMonitor *progress, void *progressData)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocInsertPages (PDDoc doc, size_t insertAt, PDDoc sourceDoc, const PDPageRange *sourceRange, const PDProgressMonitor *progress, void *progressData)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocInsertPage (PDDoc doc, PDPage page, size_t insertAt)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocMovePages (PDDoc doc, size_t insertAt, const PDPageRange *range, const PDProgressMonitor *progress, void *progressData)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocFindPageIndexForLabel (PDDoc doc, const wchar_t *label, size_t labelSize, size_t *pIndex)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetLabelForPageIndex (PDDoc doc, size_t index, wchar_t *buffer, size_t bufferSize, size_t *pSize)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetID (PDDoc doc, const char **pPermaID, size_t *pPermaLen, const char **pInstanceID, size_t *pInstanceLen)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetVersion (PDDoc doc, PDVersion *pVersion)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetFileSize (PDDoc doc, uint64_t *pFileSize)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetInfoString (PDDoc doc, PDAtom infoStringAtom, wchar_t *buffer, size_t bufferSize, size_t *pSize)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocSetInfoString (PDDoc doc, PDAtom infoStringAtom, const wchar_t *buffer, size_t bufferSize)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetCreationDate (PDDoc doc, PDDateTime *creationDate)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocSetCreationDate (PDDoc doc, const PDDateTime *creationDate)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetModDate (PDDoc doc, PDDateTime *modDate)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocSetModDate (PDDoc doc, const PDDateTime *modDate)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocSetPageLayout (PDDoc doc, PDAtom layout)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetPageLayout (PDDoc doc, PDAtom *pLayout)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocSetPageMode (PDDoc doc, PDAtom mode)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetPageMode (PDDoc doc, PDAtom *pMode)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocSetPageDirection (PDDoc doc, PDPageDirection direction)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetPageDirection (PDDoc doc, PDPageDirection *pDirection)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDStructTreeRoleMapGetTag (PDDoc doc, PDAtom tag, PDAtom *pValue)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDStructTreeFindStructParent (PDDoc doc, int structParent, int MCID, PDObject *pObj)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageGetDoc (PDPage page, PDDoc *pDoc)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageGetIndex (PDPage page, size_t *pIndex)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageIsContentModified (PDPage page, bool *pValue)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageSetContentModified (PDPage page, bool value)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageFlushModifiedContent (PDPage page)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageSetMediaBox (PDPage page, const PDRectF *mediaBox)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageGetMediaBox (PDPage page, PDRectF *pMediaBox)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageSetCropBox (PDPage page, const PDRectF *cropBox)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageGetCropBox (PDPage page, PDRectF *pCropBox)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageSetTrimBox (PDPage page, const PDRectF *trimBox)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageGetTrimBox (PDPage page, PDRectF *pTrimBox)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageSetArtBox (PDPage page, const PDRectF *artBox)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageGetArtBox (PDPage page, PDRectF *pArtBox)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageSetBleedBox (PDPage page, const PDRectF *bleedBox)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageGetBleedBox (PDPage page, PDRectF *pBleedBox)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageSetRotate (PDPage page, PDRotate rotate)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageGetRotate (PDPage page, PDRotate *pRotate)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageSetUserUnitSize (PDPage page, float unitSize)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageGetUserUnitSize (PDPage page, float *pUnitSize)
 
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageGetPDObject (PDPage page, PDObject *pObj)
 

Detailed Description

Document API.

Typedef Documentation

◆ PDDocAuthProc

typedef PDErrCode(PDFSDK_CALLCONV * PDDocAuthProc) (void *authProcData, PDAtom securityHandlerName, void *pAuthData)

A callback used by PDDocOpen. It is called when an encrypted document is being opened to determine whether the user is authorized to open the file. It may be given in PDDocOpen()'s PDDocOpenParams::authProc (for the embedded standard security handler) OR be part of the PDCryptSecurityHandler callbacks.

pAuthorizationData will be created using the Security Handlers PDCryptNewAuthorizationDataProc when this is called. This callback must set the pAuthorizationData either by displaying a dialog and asking for a user / passowrd either by using whatever authorization strategy is necessary for this security handler. The data will be given to the security handler PDCryptAutorizeProc handler to continue with the autorization process.

The callback may be used at any point in the life of the document when autorization data needs to be updated. Generaly this is at the open of a document but it may also happen when an Embedded Encrypted File is accessed for the first time or when the user calls PDDocPermRequestAuthDataCallback.

Parameters
[in]authProcDataUser-supplied data that was passed in the call to PDDocOpen() in PDDocOpenParams::authProcData.
[in]securityHandlerNameThe name of the security handler as it appears in the Encrypt dictionary. kPDAtom_Standard is used for the embedded standard security handler.
[out]pAuthorizationDataSet by the callback after optionaly diplaying a dialog to collect data from the user.
See also
PDCryptAutorizeProc
PDCryptNewAuthorizationDataProc
PDDocPermRequestAuthDataCallback

Function Documentation

◆ PDDocGetInfoString()

PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetInfoString ( PDDoc doc,
PDAtom infoStringAtom,
wchar_t * buffer,
size_t bufferSize,
size_t * pSize )

Gets the document's general information, such as the document’s title, author from the Info dictionary.

See Section 14.3.3 in the PDF Reference for information about Info dictionaries.

Parameters
docThe document whose Info dictionary is obtained.
infoStringAtomAtom specifies what information string to retrieve. Supported atoms: Author, Title, Subject, Keywords, Creator, Producer.
bufferString buffer where requested info will be copied.
bufferSizeBuffer size.
pSizeActual size of requested info string in symbols.

◆ PDDocGetPageDirection()

PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetPageDirection ( PDDoc doc,
PDPageDirection * pDirection )

Gets the value of the Direction key in the ViewerPreferences dialog entry in the Catalog dictionary.

From 12.2 Viewer Preferences: "This entry has no direct effect on the document’s contents or page numbering but may be used to determine the relative positioning of pages when displayed side by side or printed n-up."

Parameters
docIN/OUT The document whose page mode is obtained.
pModePage mode value from PDF Catalog dictionary.
See also
PDDocSetPageMode

◆ PDDocGetPageLayout()

PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetPageLayout ( PDDoc doc,
PDAtom * pLayout )

Gets the value of the PageLayout key in the Catalog dictionary.

Parameters
docIN The document whose layout mode is obtained.
pLayoutLayout mode value from the PDF Catalog dictionary.
See also
PDDocSetPageLayout

◆ PDDocGetPageMode()

PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetPageMode ( PDDoc doc,
PDAtom * pMode )

Gets the value of the PageMode key in the Catalog dictionary.

Parameters
docIN/OUT The document whose page mode is obtained.
pModePage mode value from PDF Catalog dictionary.
See also
PDDocSetPageMode

◆ PDDocSetInfoString()

PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocSetInfoString ( PDDoc doc,
PDAtom infoStringAtom,
const wchar_t * buffer,
size_t bufferSize )

Sets the document's general information, such as the document’s title, author into the Info dictionary.

See Section 14.3.3 in the PDF Reference for information about Info dictionaries.

Parameters
docThe document whose Info dictionary is set.
infoStringAtomAtom specifies what information string to retrieve. Supported atoms: Author, Title, Subject, Keywords, Creator, Producer.
bufferString buffer which contains info string to be set.
bufferSizeSize of the buffer.

◆ PDPageFlushModifiedContent()

PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageFlushModifiedContent ( PDPage page)

Saves the contents of the page to a PDF stream.

Warning
Call this function only then you are 100% sure that all content handles are released. Otherwise, it will cause UB and will probably crash the application.
Parameters
[in]pageThe page whose content is saved.
Returns
The stream containing the page's content.

◆ PDPageGetCropBox()

PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageGetCropBox ( PDPage page,
PDRectF * pCropBox )

Gets the crop box for a page. The crop box is the region of the page to display and print.

Parameters
[in]pageThe page whose crop box is obtained.
[out]pCropBoxA pointer to a rectangle specifying the page's crop box, specified in user space coordinates.
See also
PDPageSetCropBox
PDPageGetMediaBox
PDPageGetBBox

◆ PDPageGetMediaBox()

PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageGetMediaBox ( PDPage page,
PDRectF * pMediaBox )

Gets the media box for a page. The media box is the natural size of the page (for example, the dimensions of an A4 sheet of paper).

Parameters
pageIN/OUT The page whose media box is obtained.
pMediaBoxIN/OUT (Filled by the method) A pointer to a rectangle specifying the page's media box, specified in user space coordinates.
See also
PDPageSetMediaBox
PDPageGetCropBox
PDPageGetBBox

◆ PDPageGetRotate()

PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageGetRotate ( PDPage page,
PDRotate * pRotate )

Gets the rotation value for a page.

Parameters
[in]pageThe page whose rotation is obtained.
[out]pRotateRotation value for the given page. It must be one of the PDRotate values.
See also
PDPageSetRotate

◆ PDPageGetUserUnitSize()

PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDPageGetUserUnitSize ( PDPage page,
float * pUnitSize )

Returns the UserUnit value for the page. If the key is not present in the page dictionary the default of 1.0 is returned.

Parameters
pageThe page whose UserUnit value is being obtained.
pUnitSizeThe value of UserUnit from the page dictionary, or a default value of 1.0 if not present.