3.2 Attachment
The attachments here only refer to attachments of documents and do not include the files attached as annotations. The APIs enable operations such as loading, acquiring, inserting and removing attachments, setting creation and modified date, and more. Here are some common attachment APIs listed in Table 3.3. For a complete list of APIs, please refer to ZSAttachment.h.
Table3.3
|
API Name |
Description |
1 |
ZSDoc_LoadAttachments |
Load all attachments of PDF document. |
2 |
ZSAttachments_Release |
Release an attachment object. |
3 |
ZSAttachments_GetAttachment |
Get a specific attachment. |
4 |
ZSAttachments_NumAttachments |
Get a count of attachments. |
5 |
ZSAttachments_InsertAttachment |
Insert an attachment. |
6 |
ZSAttachments_RemoveAttachment |
Remove an attachment. |
7 |
ZSAttachment_GetFileName |
Get file name of an attachment. |
8 |
ZSAttachment_GetDescription |
Get the description of an attachment. |
9 |
ZSAttachment_SetCreationDateTime |
Set the creation date and time of an attachment. |
10 |
ZSAttachment_GetData |
Get the attachment data asynchronously. |
11 |
ZSAttachment_GetDocument |
Get a document handle related to an attachment. |
This is an example of how to work with PDF attachments.
Example: Insert an attachment file into a PDF document
ZSAttachment attachs;
ZSAttachment attach;
ZSResult ret = ZSDoc_LoadAttachments(doc, &attachs);
ret = ZSAttachment_Create(doc, &attach);
ret = ZSAttachments_NumAttachments(attachs, &count);
ret = ZSAttachments_InsertAttachment(attachs, count, attach);
ZS_BSTRC(filename, “./MyFile.pdf”);
ZSFile file = NULL;
ret = ZSFile_CreateFromFileName(&filename, ZS_FILEMODE_READONLY, &file);
ret = ZSAttachment_SetFile(attach, file);
|