3.4 PDF Document
Use ZSDoc handle object for PDF document-level operations such as creating and saving files, and inserting and deleting pages, metadata and annotations. Initialize ZSDoc handle by calling ZSDoc_Open to allow more APIs to work. Here are some common APIs at document level listed in Table 3.5. For a complete list of APIs for accessing PDF documents, please refer to ZSDoc.h.
Table 3.5
|
API Name |
Description |
1 |
ZSDoc_Open |
Open the PDF document and get a pointer to ZSDoc. |
2 |
ZSDoc_Create |
Create a new document object. |
3 |
ZSDoc_Close |
Close a PDF document. |
4 |
ZSDoc_GetPasswordType |
Get the current password type. |
5 |
ZSDoc_SetAction |
Set document trigger action. |
6 |
ZSDoc_GetAction |
Get document trigger action. |
7 |
ZSDoc_SetDisplayMode |
Set display mode specified in PDF document. |
8 |
ZSDoc_Numpages |
Get page number in document. |
9 |
ZSDoc_SetFileVersion |
Specify the PDF file version which will be stored in PDF header section. This function doesn't check whether the PDF matches the specified version. |
10 |
ZSViewerPref_GetNonFullScreenPageMode |
Get display mode for non-full-screen mode from viewer preferences. |
11 |
ZSViewerPref_SetPrintRanges |
Set the page ranges to be printed. |
12 |
ZSViewerPref_SetReadingDirection |
Set reading direction in viewer preferences. |
13 |
ZSMetedata_GetDateTime |
Get a date and time value from metadata. |
14 |
ZSMetedata_SetString |
Set a UTF-8 string value to parameter key in metadata. |
15 |
ZSDoc_InsertPages |
Start a progressive process of inserting a range of pages from a source document into the target document. |
This is an example of working with a PDF document using APIs.
Example: Open a PDF document and acquire pages
ZSDoc doc = NULL;
if (ZS_OK == ZSDoc_Open(&filename, NULL, &doc))
{
ZSPage page = NULL;
if (ZS_OK == ZSDoc_AcquirePage(doc, 0, &page))
{
// do something
}
ZSPage_Release(page);
Page = NULL;
}
ZSDoc_Close(doc);
doc = NULL;
|