public class Document extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
ConvertDocumentResp |
convert(ConvertDocumentReq req)
Markdown/HTML 内容转换为文档块,将 Markdown/HTML 格式的内容转换为文档块,以便于将 Markdown/HTML
格式的内容插入到文档中。
|
ConvertDocumentResp |
convert(ConvertDocumentReq req,
RequestOptions reqOptions)
Markdown/HTML 内容转换为文档块,将 Markdown/HTML 格式的内容转换为文档块,以便于将 Markdown/HTML
格式的内容插入到文档中。
|
CreateDocumentResp |
create(CreateDocumentReq req)
创建文档,创建文档类型为 docx 的文档。
|
CreateDocumentResp |
create(CreateDocumentReq req,
RequestOptions reqOptions)
创建文档,创建文档类型为 docx 的文档。
|
GetDocumentResp |
get(GetDocumentReq req)
获取文档基本信息,获取文档标题和最新版本 ID。
|
GetDocumentResp |
get(GetDocumentReq req,
RequestOptions reqOptions)
获取文档基本信息,获取文档标题和最新版本 ID。
|
RawContentDocumentResp |
rawContent(RawContentDocumentReq req)
获取文档纯文本内容,获取文档的纯文本内容。
|
RawContentDocumentResp |
rawContent(RawContentDocumentReq req,
RequestOptions reqOptions)
获取文档纯文本内容,获取文档的纯文本内容。
|
public Document(Config config)
public ConvertDocumentResp convert(ConvertDocumentReq req, RequestOptions reqOptions) throws Exception
**若要将 Markdown/HTML 格式的内容插入到文档,需依次执行以下操作:**;;1. 调用[创建文档](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document/create)接口创建一篇类型为 docx 的文档(若目标文档已存在,则无需此步骤)。;2. 调用当前接口将 Markdown/HTML 格式的内容转换为文档块。;3. 调用[创建嵌套块](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document-block-descendant/create)接口将步骤二中返回的块批量插入到目标文档中。;;;;**在上述接口调用过程中需注意以下事项:**;;- 将带表格的 Markdown/HTML 格式的内容转换为文档块后,在调用[创建嵌套块](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document-block-descendant/create)接口批量插入块到文档前,需先去除表格(Table)块中的 `merge_info` 字段。由于当前 `merge_info` 为只读属性,传入该字段会引发报错。;;- 将包含图片的 Markdown/HTML 格式的内容转换为文档块,并调用[创建嵌套块](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document-block-descendant/create)接口将图片(Image)块插入到文档后,需调用[上传图片素材](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/drive-v1/media/upload_all)接口,以 Image BlockID 作为 `parent_node` 上传素材,接着调用[更新块](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document-block/patch)或[批量更新块](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document-block/batch_update)接口,指定 `replace_image` 操作,将图片素材 ID 设置到对应的 Image Block。;;- 当转换后的块数量过多时,需分批调用[创建嵌套块](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document-block-descendant/create)接口,单次调用[创建嵌套块](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document-block-descendant/create)接口最多可插入 1000 个块。 ;
Exceptionpublic ConvertDocumentResp convert(ConvertDocumentReq req) throws Exception
**若要将 Markdown/HTML 格式的内容插入到文档,需依次执行以下操作:**;;1. 调用[创建文档](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document/create)接口创建一篇类型为 docx 的文档(若目标文档已存在,则无需此步骤)。;2. 调用当前接口将 Markdown/HTML 格式的内容转换为文档块。;3. 调用[创建嵌套块](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document-block-descendant/create)接口将步骤二中返回的块批量插入到目标文档中。;;;;**在上述接口调用过程中需注意以下事项:**;;- 将带表格的 Markdown/HTML 格式的内容转换为文档块后,在调用[创建嵌套块](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document-block-descendant/create)接口批量插入块到文档前,需先去除表格(Table)块中的 `merge_info` 字段。由于当前 `merge_info` 为只读属性,传入该字段会引发报错。;;- 将包含图片的 Markdown/HTML 格式的内容转换为文档块,并调用[创建嵌套块](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document-block-descendant/create)接口将图片(Image)块插入到文档后,需调用[上传图片素材](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/drive-v1/media/upload_all)接口,以 Image BlockID 作为 `parent_node` 上传素材,接着调用[更新块](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document-block/patch)或[批量更新块](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document-block/batch_update)接口,指定 `replace_image` 操作,将图片素材 ID 设置到对应的 Image Block。;;- 当转换后的块数量过多时,需分批调用[创建嵌套块](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document-block-descendant/create)接口,单次调用[创建嵌套块](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/document-docx/docx-v1/document-block-descendant/create)接口最多可插入 1000 个块。 ;
Exceptionpublic CreateDocumentResp create(CreateDocumentReq req, RequestOptions reqOptions) throws Exception
官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=create&project=docx&resource=document&version=v1 ;
Exceptionpublic CreateDocumentResp create(CreateDocumentReq req) throws Exception
官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=create&project=docx&resource=document&version=v1 ;
Exceptionpublic GetDocumentResp get(GetDocumentReq req, RequestOptions reqOptions) throws Exception
官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=get&project=docx&resource=document&version=v1 ;
Exceptionpublic GetDocumentResp get(GetDocumentReq req) throws Exception
官网API文档链接:https://open.feishu.cn/api-explorer?from=op_doc_tab&apiName=get&project=docx&resource=document&version=v1 ;
Exceptionpublic RawContentDocumentResp rawContent(RawContentDocumentReq req, RequestOptions reqOptions) throws Exception
Exceptionpublic RawContentDocumentResp rawContent(RawContentDocumentReq req) throws Exception
ExceptionCopyright © 2026. All rights reserved.