All Products
Search
Document Center

Intelligent Media Management:CreateOfficeConversionTask

最終更新日:Dec 30, 2024

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

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

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.
OperationAccess levelResource typeCondition keyAssociated operation
imm:CreateOfficeConversionTaskcreate
*Project
acs:imm:{#regionId}:{#accountId}:project/{#ProjectName}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
ProjectNamestringYes

The name of the project.

immtest
SourceURIstringNo

The URI of the source file.

Specify the OSS URI in the oss://${Bucket}/${Object} format, where ${Bucket} is the name of the bucket in the same region as the current project and ${Object} is the path of the object with the extension included.

oss://test-bucket/test-object
TargetURIstringNo

The address template of the output file.

Specify the value in the oss://{bucket}/{tags.custom}/{dirname}/{barename}.{autoext} format. For more information, see TargetURI template.

Note Specify at least one of the TargetURI and TargetURIPrefix parameters.
oss://{bucket}/{tags.custom}/{dirname}/{barename}.{autoext}
TargetURIPrefixstringNo

The prefix of the storage address of the output file.

Specify the prefix in the oss://${Bucket}/${Prefix}/ format, where ${Bucket} is the name of the bucket in the same region as the current project and ${Prefix} is the prefix of the output file.

Note Specify at least one of the TargetURI and TargetURIPrefix parameters.
oss://bucket1/
SourceTypestringNo

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:

  • 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
doc
TargetTypestringYes

The format of the output file. Valid values:

  • png: a PNG image.
  • jpg: a JPG image.
  • pdf: a PDF file.
  • txt: a TXT file. You can specify this value to extract the text content of the source document. Only presentation, text, or spreadsheet documents can be converted to a TXT file. If the source document is a spreadsheet, only one TXT is created and sheet-related parameters do not take effect.
png
UserDatastringNo

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"}
TagsobjectNo

The custom tags in dictionary format. You can use the custom tags to search for the task.

{"test":"val1"}
StartPagelongNo

The starting page for document conversion. Default value: 1.

Note
  • If the document is a spreadsheet file, specify the index number of the corresponding sheet instead.

  • This parameter takes effect only when you convert the file to an image format. It does not take effect when you convert the file into a PDF or TXT file.

1
EndPagelongNo

The ending page for document conversion. The default value is -1, which converts the file until the last page of the file.

Note
  • If the source is a spreadsheet file, specify the index number of the corresponding sheet instead.

  • If you convert a large number of pages within the document, we recommend that you split the pages into several document conversion tasks to prevent conversion timeouts.

  • This parameter takes effect only when you convert the file into an image. It does not take effect when you convert the file into a PDF or TXT file.

-1
PasswordstringNo

The password that protects the source document. To convert a password-protected document, specify this parameter.

********
ScalePercentagelongNo

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
QualitylongNo

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
PagesstringNo

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:

  • If you specify pages separately by page number, separate page numbers with commas (,). Example: 1,2
  • If you specify consecutive pages by using a page range, connect the starting and ending page numbers with a hyphen (-). Example: 1,2-4,7
1,2-4,7
MaxSheetRowlongNo

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
MaxSheetColumnlongNo

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
SheetCountlongNo

The number of sheets to be converted to an image. By default, all sheets within the spreadsheet file are converted.

1
SheetIndexlongNo

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
FitToWidthbooleanNo

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 (default): converts all columns of the document to multiple images or a multi-page PDF document.
  • true: converts all columns of the document to one single image or a single-page PDF document.
false
FitToHeightbooleanNo

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 (default): converts all rows of the document to multiple images or a multi-page PDF document. This is the default value.
  • true: converts all rows of the document to one single image or a single-page PDF document.
false
FirstPagebooleanNo

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:

  • false (default): does not return only the first resulting image. All the resulting images are returned.
  • true: returns only the first resulting image. A thumbnail is generated.
Note This parameter takes effect only when the LongPicture parameter is set to true.
false
PaperSizestringNo

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:

  • A0
  • A2
  • A4 (default)
Note This parameter takes effect only when the FitToHeight and FitToWidth parameters are specified.
A4
PaperHorizontalbooleanNo

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 (default): does not place sheets of paper horizontally. Paper sheets are placed vertically.
  • true: places sheets of paper horizontally.
false
TrimPolicyTrimPolicyNo

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.

ShowCommentsbooleanNo

Specifies whether to display comments in resulting images when a text document is converted to images. Valid values:

  • false (default): does not display comments in resulting images.
  • true: displays comments in resulting images.
false
LongPicturebooleanNo

Specifies whether to convert the document to a long image. Valid values:

  • false (default): does not convert the document to a long image.
  • true: converts the document to a long image.
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
ImageDPIlongNo

The dots per inch (DPI) of output images. Valid values: 96 to 600. Default value: 96.

96
LongTextbooleanNo

Specifies whether to convert the document to a long text file. Valid values:

  • false (default): does not convert the document to a long text file. Each page of the document is converted to a text file.
  • true: converts the entire document to a long text file.
false
HoldLineFeedbooleanNo

Specifies whether to retain line feeds in the output file when a document is converted to a text file. Valid values:

  • false (default): does not retain the line feeds.
  • true: retains the line feeds.
false
CredentialConfigCredentialConfigNo

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.

NotificationNotificationNo

The notification settings. For information about the asynchronous notification format, see Asynchronous message examples.

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

RequestIdstring

The request ID.

FF3B7D81-66AE-47E0-BF69-157DCF18*****
TaskIdstring

The task ID.

formatconvert-00bec802-073a-4b61-ba3b-39bc2fdd*****
EventIdstring

The event ID.

2C2-1I0EG57VR37J4rQ8oKG6C9*****

Examples

Sample success responses

JSONformat

{
  "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 timeSummary of changesOperation
2024-11-29The internal configuration of the API is changed, but the call is not affectedView Change Details
2024-10-18The request parameters of the API has changedView Change Details
2023-04-03The request parameters of the API has changedView Change Details
2023-03-09The request parameters of the API has changedView Change Details
2022-08-16The request parameters of the API has changedView Change Details
2022-08-16The request parameters of the API has changedView Change Details