3.5 Edit
Right PDF SDK provides APIs to edit PDF objects, including text, images, and path. Call the function ZSPage_AcquireEContent initially to get the page objects before using other functions to edit page objects. Here are some common APIs for editing listed in Table 3.6. For a complete list of APIs, please refer to ZSEdit.h.
Table 3.6
|
API Name |
Description |
1 |
ZSPage_AcquireEContent |
Acquire page content in a PDF page. |
2 |
ZSEContent_NumObjects |
Receive the total count of ZSEObject in content. |
3 |
ZSEObject_GetType |
Receive the type of pageObj. |
4 |
ZSEObject_GetColor |
Get the color of pageObj. |
5 |
ZSTextObject_HasTransparency |
Define whether pageObj is transparent. |
6 |
ZSImageObject_CloneBitmap |
Clone a bitmap from an image object. |
7 |
ZSEObject_AddClipObject |
Get an object from a clip in pageObj. |
8 |
ZSPathData_Create |
Create new path data. |
9 |
ZSPathData_GetSegment |
Get specific segment from the path data. |
This is an example of editing text, images, and path of a page.
Example: Text, image, and path edit
ZSEContent content;
ZSPage_AcquireEContent(page, &content);
//text
ZSEObject textObj;
ZSTextObject_Create(&textObj);
// set custom font and text state
ZSTextObject_AddUnicodeString(textObj, 0, &textState, &text);
ZSEContent_InsertObject(content, 0, textObj);
ZSEObject_Release(textobj);
//image
ZSEObject imageObj;
ZSImageObject_CreateFromFileName(&filename, 0, &imageObj);
ZSEContent_InsertObject(content, 1, imageObj);
ZSEObject_Release(imageObj);
//path
ZSEObject pathObj;
ZSPathObject_Create(&pathObj);
//set custom path data
ZSPathObject_SetPathData(pathObj, pathData);
ZSPathObject_SetStrokeState(pathObj, ZS_TRUE);
ZSEContent_InsertObject(content, 2, pathObj);
ZSEObject_Release(pathObj);
ZSPage_SetEContent(page);
|