Document Content Operation
💡 API calls require authentication. Refer to Interface Authentication for authentication
API Interface
POST {apiPrefix}/content/update
Submit document content operation task
- If task addition fails, the failure reason is returned synchronously
- If task addition succeeds, the task ID is returned synchronously. Third parties can configure task callback notifications to get task status.
Request Body
Content-Type is application/json
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| fileUrl | string | File download address | Yes |
| filename | string | Filename with extension, currently source file types support doc/docx/wps/pdf | Yes |
| tokenType | string | Third-party token type, value is cookie or header | No |
| tokenValue | string | Third-party token value, passed back when zOffice downloads files or callback notifications | No |
| callback | string | Callback address. zOffice will callback to notify status after task completion | Yes |
| ops | array | Ordered operation array for document content operations, array objects see op description below. Supported operation list see Operation List | Yes |
- For fileUrl/tokenType/tokenValue/callback description, see Common Field Description in this document
Request body example
{
"fileUrl": "http://{{thirdparty-demo}}/v2/context/local-PublicAPI-contentUpdate-clearDoc/content",
"filename": "demo-docx.docx",
"tokenType":"cookie",
"tokenValue":"zdocs_access_token={{zdocs_access_token}}",
"callback": "http://{{thirdparty-demo}}/v2/context/convert/callback",
"ops": [ {
"actId": "ClearDoc",
"options": {
"args": ["acceptAllTrack", "removeAllComment"]
}
}]
}
Normal Response:
{
"taskId": "6f6598c8-c87e-420b-b6c4-6f1b187201dc",
"code": "Ok",
"detail": {
"taskStatus": "IN_QUEUE"
}
}
Error Response:
{
"taskId": "695fbf6e-90d2-42ba-83d5-00e81e5e366e",
"code": "TaskQueueCongestion",
"detail": {
"taskStatus": "FAIL"
}
}
Operation List
Clear Document
{
"actId": "ClearDoc",
"options": {
"args": ["acceptAllTrack", "removeAllComment"]
}
}
The args array represents the specific operations to clear the document
- acceptAllTrack means accept all track change records
- removeAllComment means remove all comments
Supports docx/wps/doc, source file maximum 300m, docx format 600m, maximum 1000 pages
If args is empty, it means execute all the above operationsBookmark Content Replacement
Usage Restrictions- Multiple UpdateBookmarkRef operations are not allowed in ops
- UpdateBookmarkRef cannot be passed together with other operations in the same document content operation request
- Supports formats doc/docx/wps, total size of all files (including source files and reference files) maximum 300m
Usage Instructions
-
Template file download address is passed in request body fileUrl
-
Template filename is passed in request body filename, filename needs to include extension
-
Bookmark replacement content is passed in request body ops, structure as follows
{
"actId": "UpdateBookmarkRef",
"options": {
"args": [
{
"bookname": "Bookmark Name",
"dataType": "Bookmark Reference Type",
"dataRef": "Bookmark Reference Content",
"refName": "Bookmark Reference Content Name"
}
]
}
}
options Description
| Option Name | Option Type | Required | Description |
|---|---|---|---|
| args | BookmarkRef array | Yes | BookmarkRef object contains four attributes:* bookname * dataType * dataRef * refName |
- bookname: Bookmark name. When bookmark name does not exist, the corresponding replacement will be ignored, but will not affect other bookmark replacements.
- dataType: Bookmark reference type. Optional values TEXT, DOC, PIC. Respectively correspond to reference content as string, document, image.
- dataRef: Bookmark reference content.
- When dataType is TEXT, this value is a string;
- When dataType is DOC or PIC, this value is the URL to download the corresponding file.
- The request URL is required to return the corresponding file stream, no other restrictions.
- When zOffice requests the URL, it uses the authentication method described in tokenType/tokenValue.
- refName: Bookmark reference name.
- When dataType is TEXT, this value can be omitted;
- When dataType is DOC or PIC, this value is the filename with extension corresponding to dataRef, please ensure the file extension is correct, otherwise the result may not meet expectations. Supported formats: png/jpeg/doc/wps/docx
Example - Multiple Bookmark Replacements
{
"actId": "UpdateBookmarkRef",
"options": {
"args": [
{
"bookname": "Document Title",
"dataType": "TEXT",
"dataRef": "zOffice PublicAPI Bookmark Application"
},
{
"bookname": "Signature Department",
"dataType": "PIC",
"dataRef": "http://{{thirdparty-demo}}/v2/context/local-PublicAPI-contentUpdate-updateBkRef-pic/content",
"refName": "sign.png"
},
{
"bookname": "Body",
"dataType": "DOC",
"dataRef": "http://{{thirdparty-demo}}/v2/context/local-PublicAPI-contentUpdate-updateBkRef-body/content",
"refName": "body.docx"
},
{
"bookname": "Footer Note",
"dataType": "TEXT",
"dataRef": "Technology Changes Life",
"refName": ""
}
]
}
}
Apply Position Text Watermark
{
"actId": "ApplyWatermark",
"options": {
"text": "watermark for test",
"fontcolor": "#DC134C",
"fontsize": "70",
"font": "SimHei",
"rotation": 315,
"transparent": 20,
"position": "BOTTOM_RIGHT"
}
}
Supported Types:
| Source File Type | Restrictions |
|---|---|
| docx/wps/doc/ofd | Source file maximum 300m, docx format 600m, maximum 1000 pages |
options Description see Position Text Watermark
Apply Position Image Watermark
Word Files
{
"actId": "ApplyPicWatermark",
"options": {
"picUrl": "http://{{thirdparty-demo}}/v2/context/local-pic/content",
"picName": "pic.png",
"isErosion": false,
"rotation": 0,
"position": "CENTER",
"picScale": 100
}
}
PDF, OFD Files
Do not pass the scaling parameter: picScale, watermark image adapts to page
{
"actId": "ApplyPicWatermark",
"options": {
"picUrl": "http://{{thirdparty-demo}}/v2/context/local-logo/content",
"picName": "local-logo.png",
"picScale": 100,
"transparent": 78,
"rotation": 0,
"position": "CENTER"
}
}
Supported Types:
| Source File Type | Restrictions |
|---|---|
| docx/wps/doc | Source file maximum 300m, docx format 600m, maximum 1000 pages, watermark image maximum 50m |
| pdf/ofd | Source file maximum 200m, maximum 1000 pages, watermark image maximum 50m |
options Description see Position Image Watermark
Apply Tiled Text Watermark
{
"actId": "ApplyWatermarkForFixed",
"options": {
"line1": "watermark for test",
"withDate": true,
"font": "SimHei",
"fontcolor": "#DC134C",
"fontsize": "70",
"transparent": 70,
"rotation": 315,
"spacing": 50
}
}
Supported Types:
| Source File Type | Restrictions |
|---|---|
| pdf/ofd | Source file maximum 200m, maximum 1000 pages |
options Description see Tiled Text Watermark
Apply Tiled Image Watermark
{
"actId": "ApplyTiledImgWatermarkForFixed",
"options": {
"picUrl": "http://{{thirdparty-demo}}/v2/context/local-png/content",
"picName": "filez.png",
"picScale": 100,
"rotation": 315,
"transparent": 70,
"spacing": 80
}
}
Supported Types:
| Source File Type | Restrictions |
|---|---|
| ofd | Source file maximum 200m, maximum 1000 pages |
options Description see Tiled Image Watermark