Creates a document format conversion task to convert the format of a document stored in an Object Storage Service (OSS) bucket.
Operation description
-
Before you call this operation, make sure that you are familiar with the billing of Intelligent Media Management (IMM).****
**
Note Asynchronous processing does not guarantee timely task completion.
-
The operation supports the following input formats:
- Text documents: doc, docx, wps, wpss, docm, dotm, dot, dotx, and html
- Presentation documents: pptx, ppt, pot, potx, pps, ppsx, dps, dpt, pptm, potm, ppsm, and dpss
- Spreadsheet documents: xls, xlt, et, ett, xlsx, xltx, csv, xlsb, xlsm, xltm, and ets
- PDF documents: pdf
-
The operation supports the following output formats:
- Image files: png and jpg
- Text files: txt
- PDF files: pdf
-
Each input document can be up to 200 MB in size.
-
The maximum conversion time is 120 seconds. If the document contains too much or complex content, the conversion may time out.
-
The operation is an asynchronous operation. After a task is executed, the task information is saved only for seven days. When the retention period ends, the task information can no longer be retrieved. You can use one of the following methods to query task information:
- Call the GetTask or ListTasks operation to query information about the task.``
- In the region in which the IMM project is located, configure a Simple Message Queue (SMQ) subscription to receive task information notifications. For information about the asynchronous notification format, see Asynchronous message examples. For information about SMQ SDKs, see Use queues.
- In the region in which the IMM project is located, create an ApsaraMQ for RocketMQ 4.0 instance, a topic, and a group to receive task notifications. For information about the asynchronous notification format, see Asynchronous message examples. For more information about how to use ApsaraMQ for RocketMQ, see Call HTTP SDKs to send and subscribe to messages.
- In the region in which the IMM project is located, use EventBridge to receive task information notifications. For more information, see IMM events.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
imm:CreateOfficeConversionTask | create | *Project acs:imm:{#regionId}:{#accountId}:project/{#ProjectName} |
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
ProjectName | string | Yes | immtest | |
SourceURI | string | No | The URI of the source file. Specify the OSS URI in the oss://${Bucket}/${Object} format, where | oss://test-bucket/test-object |
TargetURI | string | No | The address template of the output file. Specify the value in the Note
Specify at least one of the TargetURI and TargetURIPrefix parameters.
| oss://{bucket}/{tags.custom}/{dirname}/{barename}.{autoext} |
TargetURIPrefix | string | No | The prefix of the storage address of the output file. Specify the prefix in the Note
Specify at least one of the TargetURI and TargetURIPrefix parameters.
| oss://bucket1/ |
SourceType | string | No | The name extension of the source file. By default, the type of the source file is determined based on the name extension of the source object in OSS. If the object in OSS does not have a name extension, you can specify this parameter. Valid values:
| doc |
TargetType | string | Yes | The format of the output file. Valid values:
| png |
UserData | string | No | The custom information, which is returned in an asynchronous notification and facilitates notification management. The maximum information length is 2,048 bytes. | {"file_id": "abc"} |
Tags | object | No | The custom tags in dictionary format. You can use the custom tags to search for the task. | {"test":"val1"} |
StartPage | long | No | The starting page for document conversion. Default value: 1. Note
| 1 |
EndPage | long | No | The ending page for document conversion. The default value is -1, which converts the file until the last page of the file. Note
| -1 |
Password | string | No | The password that protects the source document. To convert a password-protected document, specify this parameter. | ******** |
ScalePercentage | long | No | The percentage scale relative to the source document. Valid values: 20 to 200. The default value is 100, which indicates that the document is not scaled. Note
A value that is less than 100 indicates a size reduction. A value that is greater than 100 indicates an enlargement.
| 100 |
Quality | long | No | The quality of the output file. Valid values: 0 to 100. A smaller value indicates lower quality and better conversion performance. By default, the system specifies an appropriate value that provides an optimal balance between the quality and conversion performance based on the document content. | 60 |
Pages | string | No | The numbers of pages to be converted. This parameter takes precedence over the StartPage and EndPage parameters. The value of this parameter can be in different formats:
| 1,2-4,7 |
MaxSheetRow | long | No | The maximum number of spreadsheet rows to be converted to an image. By default, all rows within the spreadsheet file are converted. Note
This parameter takes effect only when the LongPicture parameter is set to true .
| 10 |
MaxSheetColumn | long | No | The maximum number of spreadsheet columns to be converted to an image. By default, all columns within the spreadsheet file are converted. Note
This parameter takes effect only when the LongPicture parameter is set to true .
| 10 |
SheetCount | long | No | The number of sheets to be converted to an image. By default, all sheets within the spreadsheet file are converted. | 1 |
SheetIndex | long | No | The index number of the sheet to be converted to an image. The value ranges from 1 to the index number of the last sheet. By default, the conversion starts from the first sheet. | 1 |
FitToWidth | boolean | No | Specifies whether to convert all columns of a spreadsheet document to one single image or a single-page PDF document when you convert the spreadsheet file to an image or a PDF document. Valid values:
| false |
FitToHeight | boolean | No | Specifies whether to convert all rows of a spreadsheet document to one single image or a single-page PDF document when you convert the table document to an image or a PDF document. Valid values:
| false |
FirstPage | boolean | No | Specifies whether to return only the first resulting image when you convert a spreadsheet document to images. The number of rows and the number of columns in the first image are determined by the automatic splitting process. Valid values:
Note
This parameter takes effect only when the LongPicture parameter is set to true .
| false |
PaperSize | string | No | The paper size for converting a spreadsheet document to images. Conversion to images is similar to printing the content on a sheet of paper. Valid values:
Note
This parameter takes effect only when the FitToHeight and FitToWidth parameters are specified.
| A4 |
PaperHorizontal | boolean | No | Specifies whether to place sheets of paper horizontally for converting a spreadsheet document to images. Conversion to images is similar to printing the content on a sheet of paper. Valid values:
| false |
TrimPolicy | TrimPolicy | No | The trim policy for converting a spreadsheet file. Empty rows and columns may generate blank spaces in the output file if no appropriate trim policy is specified. | |
ShowComments | boolean | No | Specifies whether to display comments in resulting images when a text document is converted to images. Valid values:
| false |
LongPicture | boolean | No | Specifies whether to convert the document to a long image. Valid values:
Note
You can convert up to 20 pages of a document into a long image. If you convert more than 20 pages to a long image, an error may occur.
| false |
ImageDPI | long | No | The dots per inch (DPI) of output images. Valid values: 96 to 600. Default value: 96. | 96 |
LongText | boolean | No | Specifies whether to convert the document to a long text file. Valid values:
| false |
HoldLineFeed | boolean | No | Specifies whether to retain line feeds in the output file when a document is converted to a text file. Valid values:
| false |
CredentialConfig | CredentialConfig | No | If you have no special requirements, leave this parameter empty. The authorization chain settings. For more information, see Use authorization chains to access resources of other entities. | |
Notification | Notification | No | The notification settings. For information about the asynchronous notification format, see Asynchronous message examples. |
Response parameters
Examples
Sample success responses
JSON
format
{
"RequestId": "FF3B7D81-66AE-47E0-BF69-157DCF18*****",
"TaskId": "formatconvert-00bec802-073a-4b61-ba3b-39bc2fdd*****",
"EventId": "2C2-1I0EG57VR37J4rQ8oKG6C9*****"
}
Error codes
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2024-11-29 | The internal configuration of the API is changed, but the call is not affected | View Change Details |
2024-10-18 | The request parameters of the API has changed | View Change Details |
2023-04-03 | The request parameters of the API has changed | View Change Details |
2023-03-09 | The request parameters of the API has changed | View Change Details |
2022-08-16 | The request parameters of the API has changed | View Change Details |
2022-08-16 | The request parameters of the API has changed | View Change Details |