API | Operation | Description |
Submitting a file preview job | Submits a file preview job. | |
Querying file preview job | Queries specified file preview job. | |
Pulling file preview jobs | Pulls eligible file preview jobs. |
CreateDocProcessJobs
) is used to submit a file preview job.doc bucket unbinded, bucket's host is unavailable
will be reported.<?phprequire dirname(__FILE__) . '/../vendor/autoload.php';$secretId = "SECRETID"; //Replace it with the actual `SecretId`, which can be viewed and managed in the CAM console at https://console.tencentcloud.com/cam/capi$secretKey = "SECRETKEY"; //Replace it with the actual `SecretKey`, which can be viewed and managed in the CAM console at https://console.tencentcloud.com/cam/capi$region = "ap-beijing"; //Replace it with the actual `region`, which can be viewed in the console at https://console.tencentcloud.com/cos5/bucket$cosClient = new Qcloud\\Cos\\Client(array('region' => $region,'schema' => 'https', //Protocol header, which is http by default'credentials'=> array('secretId' => $secretId ,'secretKey' => $secretKey)));try {$result = $cosClient->createDocProcessJobs(array('Bucket' => 'examplebucket-1250000000', // Bucket name in the format of `BucketName-APPID`, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket'Tag' => 'DocProcess', // Job tag: DocProcess'QueueId' => 'pd8e422a2ea134165a92f2012ea43****', // Queue ID of the job'Input' => array('Object' => 'Append Test Feature.pdf' // The object to be processed),'Operation' => array('DocProcess' => array('SrcType' => 'pdf', // Source file extension'TgtType' => 'png', // Target file extension'SheetId' => 0, // Sheet parameter, indicating to convert the xth sheet. Default value: `1`.'StartPage' => 1, // Start page number, indicating to convert the file starting from the xth page. Default value: `1`.'EndPage' => 3, // End page number, indicating to convert the file till the Xth page. Default value: `-1` (convert all pages).'ImageParams' => '', // Image processing parameters after the conversion'DocPassword' => '', // Office file password'Comments' => 0, // Whether to hide comments and apply track changes. Default value: `0`.'PaperDirection' => 0, // Paper orientation of the spreadsheet. Default value: `0`.'Quality' => 100, // Quality of the generated preview image. Value range: [1-100]. Default value: `100`.'Zoom' => 100, // Scaling parameter of the preview image. Value range: [10-200]. Default value: `100`.),'Output' => array('Region' => $region, // Bucket region'Bucket' => 'examplebucket-1250000000', // Result storage bucket'Object' => 'pic-${Page}.jpg', // Output file path),),));// Request succeededprint_r($result);} catch (\\Exception $e) {// Request failedecho($e);}
Request
has the following sub-nodes:Parameter Name | Type | Description | Required |
Bucket | String | Bucket name in the format of BucketName-APPID | Yes |
Operation | Array | Operation rule | Yes |
Tag | String | Job tag, which currently can only be DocProcess . | Yes |
Input | Array | The object to be processed | Yes |
QueueId | String | Queue ID of the job | Yes |
Input
has the following sub-nodes:Parameter Name | Type | Description | Required |
Object | File URL in COS. Bucket is specified by Host . | Yes | |
Operation
has the following sub-nodes:Parameter Name | Type | Description | Required |
DocProcess | Array | Specifies the parameter for the job, which takes effect only if Tag is DocProcess . | Yes |
Output | Array | Result output address | Yes |
DocProcess
has the following sub-nodes:Parameter Name | Type | Description | Required |
srcType | String | Source data type. Currently, the file conversion feature determines the source data type according to the file extension of the COS object. If the object has no extension, you can set this value. | No |
tgtType | String | Type of the output target file. Valid values: png , jpg , pdf . If the input file format cannot be recognized, the jpg format will be used by default. You cannot specify pages for the pdf format. | No |
sheetId | Integer | Sheet parameter, indicating to convert the xth sheet. Default value: 1 . If it is set to 0 , all sheets will be converted. | No |
startPage | Integer | Starts conversion from page X. A spreadsheet file may be split into multiple pages, with multiple images generated, and StartPage indicates to start the conversion from page X of the specified SheetId . Default value: 1 . | No |
endPage | Integer | Ends conversion on page X. A spreadsheet file may be split into multiple pages, with multiple images generated, and EndPage indicates to end the conversion on page X of the specified SheetId . Default value: -1 (converting all pages). | No |
imageParams | String | Processing parameters for the output image. All parameters of basic image processing are supported. To specify multiple parameters, separate them by pipeline operator. In this way, the image can be processed by multiple parameters in sequence in the same request. | No |
docPassword | String | Password to open the Office file. If you need to convert a password-protected file, set this field. | No |
comments | Integer | Whether to hide comments and apply track changes. 0: hide comments and apply track changes; 1: show comments and track changes. Default value: 0 . | No |
paperDirection | Integer | Paper orientation of the spreadsheet. 0 : vertical; other values: horizontal. Default value: 0 . | No |
quality | Integer | Quality of the generated preview image. Value range: [1-100]. Default value: 100 . For example, if the value is 100 , the quality of the generated image will be 100%. | No |
zoom | Integer | Scaling parameter of the preview image. Value range: [10, 200]. Default value: 100 . For example, if the value is 200 , the image will be scaled up (enlarged) by 200%. | No |
Output
has the following sub-nodes:Parameter Name | Type | Description | Required |
Region | String | Bucket region | Yes |
Bucket | String | Result storage bucket | Yes |
Object | String | Output file path | Yes |
Parameter | Type | Description |
Code | String | Error code, which will be meaningful only if State is Failed . |
Message | String | Error description, which will be meaningful only if State is Failed . |
JobId | String | Job ID |
Tag | String | Job tag: DocProcess |
State | String | Job status. Valid values: Submitted , Running , Success , Failed , Pause , Cancel . |
CreationTime | String | Job creation time |
QueueId | String | ID of the queue which the job is in |
Input | Array | Input file path of the job |
Operation | Array | Operation rule |
DescribeDocProcessJob
) is used to query a specified file preview job.<?phprequire dirname(__FILE__) . '/../vendor/autoload.php';$secretId = "SECRETID"; //Replace it with the actual `SecretId`, which can be viewed and managed in the CAM console at https://console.tencentcloud.com/cam/capi$secretKey = "SECRETKEY"; //Replace it with the actual `SecretKey`, which can be viewed and managed in the CAM console at https://console.tencentcloud.com/cam/capi$region = "ap-beijing"; //Replace it with the actual `region`, which can be viewed in the console at https://console.tencentcloud.com/cos5/bucket$cosClient = new Qcloud\\Cos\\Client(array('region' => $region,'schema' => 'https', //Protocol header, which is http by default'credentials'=> array('secretId' => $secretId ,'secretKey' => $secretKey)));try {$result = $cosClient->describeDocProcessJob(array('Bucket' => 'examplebucket-1250000000', // Bucket name in the format of `BucketName-APPID`, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket'Key' => 'examplejobid', // JobId));// Request succeededprint_r($result);} catch (\\Exception $e) {// Request failedecho($e);}
Parameter | Type | Description |
Bucket | COS bucket name | String |
Key | Job ID | String |
Parameter | Type | Description |
jobsDetail | Job details | Array |
DescribeDocProcessJobs
) is used to pull file preview jobs that meet specified conditions.<?phprequire dirname(__FILE__) . '/../vendor/autoload.php';$secretId = "SECRETID"; //Replace it with the actual `SecretId`, which can be viewed and managed in the CAM console at https://console.tencentcloud.com/cam/capi$secretKey = "SECRETKEY"; //Replace it with the actual `SecretKey`, which can be viewed and managed in the CAM console at https://console.tencentcloud.com/cam/capi$region = "ap-beijing"; //Replace it with the actual `region`, which can be viewed in the console at https://console.tencentcloud.com/cos5/bucket$cosClient = new Qcloud\\Cos\\Client(array('region' => $region,'schema' => 'https', //Protocol header, which is http by default'credentials'=> array('secretId' => $secretId ,'secretKey' => $secretKey)));try {$result = $cosClient->getDescribeDocProcessJobs(array('Bucket' => 'examplebucket-1250000000', // Bucket name in the format of `BucketName-APPID`, which can be viewed in the COS console at https://console.tencentcloud.com/cos5/bucket'QueueId' => 'pd8e422a2ea134165a92f2012ea43****', // ID of the queue from which jobs are pulled'Tag' => 'DocProcess', // Job tag: DocProcess// 'NextToken' => '143486', // Context token for pagination// 'OrderByTime' => 'Desc', // `Desc` (default) or `Asc`// 'Size' => 2, // Maximum number of jobs that can be pulled. Default value: `10`. Maximum value: `100`.// 'States' => 'All', // Status of the jobs to pull. If you enter multiple job statuses, separate them by comma. Valid values: `All` (default), `Submitted`, `Running`, `Success`, `Failed`, `Pause`, `Cancel`.// 'StartCreationTime' => '2021-10-10T16:20:07+0800', // Start time of the time range for job pulling// 'EndCreationTime' => '2021-10-10T16:20:07+0800', // End time of the time range for job pulling));// Request succeededprint_r($result);} catch (\\Exception $e) {// Request failedecho($e);}
Parameter | Type | Description | Required |
Bucket | String | COS bucket name | Yes |
QueueId | String | ID of the queue from which jobs are pulled | Yes |
Tag | String | Job tag: DocProcess | Yes |
OrderByTime | String | Desc (default) or Asc | No |
NextToken | String | Context token for pagination | No |
Size | Integer | Maximum number of jobs that can be pulled. The default value is 10. The maximum value is 100. | No |
States | String | Status of the jobs to pull. If you enter multiple job statuses, separate them by comma. Valid values: All (default), Submitted , Running , Success , Failed , Pause , Cancel . | No |
StartCreationTime | String | Start time of the time range for job pulling in the format of %Y-%m-%dT%H:%m:%S%z . | No |
EndCreationTime | String | End time of the time range for job pulling in the format of %Y-%m-%dT%H:%m:%S%z . | No |
Parameter | Type | Description |
JobDetail | Array | List of job details |
nextToken | String | Context token for pagination |
Was this page helpful?