API | Description |
Generates a sync file-to-image preview URL. | |
Generates a sync file-to-HTML preview URL. |
String GenerateDocPreviewUrl(DocHtmlRequest docJobRequest);
DocHtmlRequest
has the following sub-nodes:Node Name (Keyword) | Description | Type | Required |
bucketName | String | Yes | |
objectKey | Name of the image file in the COS bucket. The COS bucket is specified by Host. For example, if the file is img.jpg in the test directory in the examplebucket-1250000000 bucket in Beijing, then Host is examplebucket-1250000000.cos.ap-beijing.myqcloud.com, and ObjectKey is test/img.jpg. | String | Yes |
srcType | 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. | String | No |
page | Number of the page to be converted, which is counted from 1 by default. For spreadsheets, page indicates to convert the xth image in the xth sheet. | Int | No |
dstType | Type of the output target file. Valid values: png (converts to .png image) jpg (converts to .jpg image) pdf (converts to .pdf file, where the page number cannot be selected, and the page parameter does not take effect.) html (converts to HTML online file)
If the input file format cannot be recognized, the jpg format will be used by default. The default value for the SDK is html. | String | No |
password | Password to open the Office file. If you need to convert a password-protected file, set this field. | String | No |
comment | Whether to hide comments and apply track changes. Default value:0. 0: Hide comments and apply track changes. 1: Show comments and track changes. | Int | No |
ImageParams | Processing parameters for the output image. All parameters of basic image processing are supported. To specify multiple parameters, separate them with pipeline operators. In this way, the image can be processed by multiple parameters in sequence in the same request. | String | No |
quality | 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%. | Int | No |
scale | 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%. | Int | No |
imageDpi | Renders the image based on the specified DPI. This parameter works together with scale. Value range: 96–600. Default value: 96. The width of the output image must be less than 65500 px. | Int | No |
//1. Create a request objectDocHtmlRequest request = new DocHtmlRequest();//2. Add request parameters as detailed in the API documentationrequest.setBucketName("markjrzhang-1251704708");// For conversion to image, `dstType` is `DocHtmlRequest.DocType.jpg`.request.setDstType(DocHtmlRequest.DocType.html);request.setObjectKey("1.pptx");request.setPage("1");//3. Call the API to get the job response objectString previewUrl = client.GenerateDocPreviewUrl(request);System.out.println(previewUrl);
Was this page helpful?