tencent cloud

Cloud Object Storage

Release Notes and Announcements
Release Notes
Announcements
Product Introduction
Overview
Features
Use Cases
Strengths
Concepts
Regions and Access Endpoints
Specifications and Limits
Service Regions and Service Providers
Billing
Billing Overview
Billing Method
Billable Items
Free Tier
Billing Examples
Viewing and Downloading Bill
Payment Overdue
FAQs
Getting Started
Console
Getting Started with COSBrowser
User Guide
Creating Request
Bucket
Object
Data Management
Batch Operation
Global Acceleration
Monitoring and Alarms
Operations Center
Data Processing
Content Moderation
Smart Toolbox
Data Processing Workflow
Application Integration
User Tools
Tool Overview
Installation and Configuration of Environment
COSBrowser
COSCLI (Beta)
COSCMD
COS Migration
FTP Server
Hadoop
COSDistCp
HDFS TO COS
GooseFS-Lite
Online Tools
Diagnostic Tool
Use Cases
Overview
Access Control and Permission Management
Performance Optimization
Accessing COS with AWS S3 SDK
Data Disaster Recovery and Backup
Domain Name Management Practice
Image Processing
Audio/Video Practices
Workflow
Direct Data Upload
Content Moderation
Data Security
Data Verification
Big Data Practice
COS Cost Optimization Solutions
Using COS in the Third-party Applications
Migration Guide
Migrating Local Data to COS
Migrating Data from Third-Party Cloud Storage Service to COS
Migrating Data from URL to COS
Migrating Data Within COS
Migrating Data Between HDFS and COS
Data Lake Storage
Cloud Native Datalake Storage
Metadata Accelerator
GooseFS
Data Processing
Data Processing Overview
Image Processing
Media Processing
Content Moderation
File Processing Service
File Preview
Troubleshooting
Obtaining RequestId
Slow Upload over Public Network
403 Error for COS Access
Resource Access Error
POST Object Common Exceptions
API Documentation
Introduction
Common Request Headers
Common Response Headers
Error Codes
Request Signature
Action List
Service APIs
Bucket APIs
Object APIs
Batch Operation APIs
Data Processing APIs
Job and Workflow
Content Moderation APIs
Cloud Antivirus API
SDK Documentation
SDK Overview
Preparations
Android SDK
C SDK
C++ SDK
.NET(C#) SDK
Flutter SDK
Go SDK
iOS SDK
Java SDK
JavaScript SDK
Node.js SDK
PHP SDK
Python SDK
React Native SDK
Mini Program SDK
Error Codes
Harmony SDK
Endpoint SDK Quality Optimization
Security and Compliance
Data Disaster Recovery
Data Security
Cloud Access Management
FAQs
Popular Questions
General
Billing
Domain Name Compliance Issues
Bucket Configuration
Domain Names and CDN
Object Operations
Logging and Monitoring
Permission Management
Data Processing
Data Security
Pre-signed URL Issues
SDKs
Tools
APIs
Agreements
Service Level Agreement
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

Document-to-HTML Synchronous Request

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-01-13 16:34:03

Description

The document-to-HTML feature supports generating HTML previews for various document types, meeting online requirements for viewing documents across multiple user terminals including PCs and Apps. It is applicable to business scenarios such as online education, enterprise OA, online knowledge bases, and document preview in cloud drives.
Note:
Cloud Infinite encapsulates the JS preview SDK, allowing access to the HTML preview service with just a single URL.
If you need to use it within a mini program, see Mini Program Configuring Business Domain.
To integrate a CDN domain, you need to enable Advanced Cache Expiration Settings in CDN. For details, see the Node Cache Expiration Configuration in CDN documentation.

Authorization Description

When a sub-account is used, you must grant the cos:GetObject and cos:HeadObject permissions in the action of the Authorization Policy. For all APIs supported by COS, see COS action.

Service Activation

To use this feature, you need to bind Bucket in advance and activate the Cloud Infinite service.
To use this feature, you need to activate the document processing service in advance via the console or API.
Note:
After Cloud Infinite is bound, if you manually unbind Cloud Infinite from the Bucket, you will not be able to continue using this feature.

Use Limits

When using this interface, please first confirm the relevant restrictions. For details, see Usage Limits.

Fee Instructions

This is a paid service. Calling this API will incur Document Processing Fees and Traffic Fees, which will be charged by Cloud Infinite.

Request

Request sample

GET /<ObjectKey>?ci-process=doc-preview&dstType=html HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: GMT Date
Authorization: Auth String
Note:
Authorization: A request header that carries authentication information. If your COS file has private read permission, the request can be verified with this header. For details, see Request Signature.

Request header

This API only uses common request headers. For details, see Common Request Headers.

Request Parameter

Name
Description
Type
Required
ObjectKey
Name of the object file, for example folder/document.pdf
String
Yes
ci-process
The processing capability of Cloud Infinite; HTML document preview is fixed as doc-preview.
String
Yes
dstType
Output type of the target file. HTML document preview is fixed as html (must be lowercase).
String
Yes
srcType
Enter the type of the target file. For supported file types and limitations, see below Notes section
String
No
sign
Signature for object download. If the object to be previewed has private read permission, a signature is required. For details, see Request Signature.
Note: URL encoding is required.
String
No
copyable
Whether it can be copied. The default is copyable: <1> indicates copyable; <0> indicates not copyable.
String
No
htmlwaterword
Watermark text requires URL-safe Base64 encoding, default is empty.
String
No
htmlfillstyle
Watermark RGBA (color and transparency) requires URL-safe Base64 encoding. Default: rgba(192,192,192,0.6).
String
No
htmlfront
Style of the watermark text requires URL-safe Base64 encoding, default: bold 20px Serif.
String
No
htmlrotate
Rotation angle of the watermark text, 0 - 360, default 315 degrees
String
No
htmlhorizontal
Horizontal spacing of the watermark text, unit: px, default: 50
String
No
htmlvertical
Vertical spacing of the watermark text, unit: px, default: 100
String
No

Note
:
Currently supported types of input files include the following formats:
Presentation files: pptx, ppt, pot, potx, pps, ppsx, dps, dpt, pptm, potm, ppsm.
Document files: doc, dot, wps, wpt, docx, dotx, docm, dotm.
Spreadsheet files: xls, xlt, et, ett, xlsx, xltx, xlsb, xlsm, xltm, ets.
Other format files: pdf, lrc, c, cpp, h, asm, s, java, asp, bat, bas, prg, cmd, rtf, txt, log, xml, htm, html.
Size of the input file is limited to 200MB.
Input file page count is limited to 5000 pages.
Word documents default to continuous layout on mobile devices and to page layout on PC.

Request body

The request body of this request is empty.

Response

Response Headers

This API only returns common response headers. For details, see Common Response Headers.

Response Body

The response body of this API request contains HTML preview content. For the display effect, see Actual Example.

Error Codes

This request has no unique error messages. For common error messages, see Error Codes.

Practical Case

Case 1: Simple Preview

To preview the PPT file with ObjectKey test.pptx in Bucket examples-1258125638 online, the final URL is as follows:
https://examples-1258125638.cos.ap-guangzhou.myqcloud.com/test.pptx?ci-process=doc-preview&dstType=html
Note:
You can also customize more features through the JS-SDK. For details, see Custom Configuration Overview.
Open the link directly in the browser. The generated preview page is shown in the figure below. For slide documents, you can also perform a full-screen slide show, supporting effects such as animations, triggers, and providing features such as virtual laser pointer, presenter mode.


Case 2: Watermark + Custom Configuration Preview

To preview the PPT file with ObjectKey test.pptx in Bucket examples-1258125638 online.
1. Set non-copyable (copyable = 0).
2. Set test watermark (via URL-safe Base64 encoding resulting in htmlwaterword = dGVzdAog).
3. Set custom configuration parameters (htmlParams is {"mode":"normal","commonOptions":{"isShowHeader":false,"isShowTopArea":true},"pptOptions":{"isSlidesStatusPlay": true}}, encoded via URL-safe Base64 to htmlParams=eyJtb2RlIjoibm9ybWFsIiwiY29tbW9uT3B0aW9ucyI6eyJpc1Nob3dIZWFkZXIiOmZhbHNlLCJpc1Nob3dUb3BBcmVhIjp0cnVlfSwicHB0T3B0aW9ucyI6eyJpc1NsaWRlc1N0YXR1c1BsYXkiOiB0cnVlfX0=).
The final URL is as follows:
https://examples-1258125638.cos.ap-guangzhou.myqcloud.com/test.pptx?ci-process=doc-preview&dstType=html&copyable=0&htmlwaterword=dGVzdAog&htmlParams=eyJtb2RlIjoibm9ybWFsIiwiY29tbW9uT3B0aW9ucyI6eyJpc1Nob3dIZWFkZXIiOmZhbHNlLCJpc1Nob3dUb3BBcmVhIjp0cnVlfSwicHB0T3B0aW9ucyI6eyJpc1NsaWRlc1N0YXR1c1BsYXkiOiB0cnVlfX0=
Open the link directly in the browser. The generated preview page is shown in the figure below. For slide documents, you can also perform a full-screen slide show, supporting effects such as animations, triggers, and providing features such as virtual laser pointer, presenter mode.

The preview link can also be embedded as an iframe in the business page, as shown below:
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,user-scalable=no">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<meta name="keywords" content="COS,document preview">
<meta name="description" content="">
<title>Tencent Cloud - COS - Document Preview</title>
<style>
html,
body {
padding: 0;
margin: 0;
height: 100%;
touch-action: manipulation;
}
</style>
</head>
<body>
<iframe src="https://examples-1258125638.cos.ap-guangzhou.myqcloud.com/test.pptx?ci-process=doc-preview&dstType=html&copyable=0&htmlwaterword=dGVzdAog&htmlParams=eyJtb2RlIjoibm9ybWFsIiwiY29tbW9uT3B0aW9ucyI6eyJpc1Nob3dIZWFkZXIiOmZhbHNlLCJpc1Nob3dUb3BBcmVhIjp0cnVlfSwicHB0T3B0aW9ucyI6eyJpc1NsaWRlc1N0YXR1c1BsYXkiOiB0cnVlfX0=" width="100%" height="100%" allowFullScreen="true"></iframe>
</body>
</html>

Case 3: Switch Preview Language to English

To preview the PPT file with ObjectKey test.pptx in Bucket examples-1258125638 online.
Set the htmlParams parameter (htmlParams is {"commonOptions":{"language": "en"}}, encoded via URL-safe Base64 to htmlParams=eyJjb21tb25PcHRpb25zIjp7Imxhbmd1YWdlIjoiZW4ifX0).
The final URL is as follows:
https://examples-1258125638.cos.ap-guangzhou.myqcloud.com/test.pptx?ci-process=doc-preview&dstType=html&htmlParams=eyJjb21tb25PcHRpb25zIjp7Imxhbmd1YWdlIjoiZW4ifX0


Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan