Document

... 2022-7-14 大约 12 分钟

# Document

参数说明: 腾讯文档 Doc 文档内容

{
  "document": object(Document)
}
1
2
3
1
2
3
参数名称 类型 描述
document object(Node) Doc 文档结构,详见Node

# Node

参数说明: 构成文档内容的节点

{
  "begin": integer,
  "end": integer,
  "property": object(Property),
  "type": string,
  "children": []object(Node),
  "text": string
}
1
2
3
4
5
6
7
8
1
2
3
4
5
6
7
8
参数名称 类型 描述
begin integer 起始位置
end integer 结束位置
property object(Property) 文档属性,详见Property
type string 节点类型,详见Type
children []object(Node) 子节点
text string 文本内容

# Type

参数名称 描述
Document Doc 文档
MainStory 文档主节点,文档主体内容
Section
Paragraph 段落
Table 表格
TableRow 表格行
TableCell 表格单元格
Text 一个具有相同属性集合的文本容器
Drawing 图形化对象 , 例如图表、图片等
Footnote 脚注
Endnote 尾注
Comment 批注
CommentRef 批注引用
TextBox 文本框
Footer 页脚
Header 页眉

# Property

参数说明: 表示文档节点的样式。详见

[Office Open XML File Formats — Fundamentals and Markup Language Reference]

{
  "sectionProperty": object(SectionProperty),
  "paragraphProperty":object(ParagraphProperty),
  "runProperty": object(RunProperty),
  "tableProperty":object(TableProperty),
  "tableRowProperty": object(TableRowProperty),
  "tableCellProperty":object(TableCellProperty),
  "textBoxProperty": object(TextBoxProperty),
  "drawingProperty":object(DrawingProperty),
  "commentStoryProperty": object(CommentProperty),
  "makeupProperty":object(CommentReferenceProperty),
  "footnoteProperty": object(FootnoteProperty),
  "endnoteProperty":object(EndnoteProperty),
  "footnoteOrEndnoteReferenceProperty": object(FootnoteOrEndnoteReferenceProperty),
  "headerProperty":object(HeaderProperty),
  "footerProperty": object(FooterProperty)
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
参数名称 参数类型 描述
sectionProperty SectionProperty section 属性
paragraphProperty ParagraphProperty 段落属性
runProperty RunProperty 文本属性
tableProperty TableProperty 表格属性
tableRowProperty TableRowProperty 表格行属性
tableCellProperty TableCellProperty 表格单元属性
textBoxProperty TextBoxProperty 文本框
drawingProperty DrawingProperty drawing 属性
commentStoryProperty CommentProperty 批注属性
makeupProperty CommentReferenceProperty 批注引用的属性
footnoteProperty FootnoteProperty 脚注属性
endnoteProperty EndnoteProperty 尾注属性
footnoteOrEndnoteReferenceProperty FootnoteOrEndnoteReferenceProperty 脚注或尾注的引用
headerProperty HeaderProperty 页眉属性
footerProperty FooterProperty 页脚属性

# SectionProperty

section 类型节点的属性

{
  "headerReference": object(headerfooterreference),
  "footerReference": object(headerfooterreference),
  "pageSize":  object(PageSize),
  "pageMargins": object(PageMargins)
}
1
2
3
4
5
6
1
2
3
4
5
6
参数名称 参数类型 描述
headerReference object(HeaderFooterReference) 页眉引用
footerReference object(HeaderFooterReference) 页眉引用
pageSize PageSize 页面尺寸
pageMargins PageMargins 页边距

# HeaderFooterReference

"headerReference": {
    "STHdrFtr_default": object(STHdrFtr)
}
1
2
3
1
2
3
参数名称 参数类型 描述
STHdrFtr_default object(STHdrFtr) 被引用的页眉或页脚的 ID

# STHdrFtr

{
    "id": "string",
    "type": "string"
}
1
2
3
4
1
2
3
4
参数名称 参数类型 描述
id string 被引用的页眉或页脚的 ID
type HeaderFooterType 页眉或页脚类型

# HeaderFooterType

参数名称 枚举值 描述
HEADER_FOOTER_TYPE_UNSPECIFIED 0 未知
HEADER_FOOTER_TYPE_EVEN 1 均匀
HEADER_FOOTER_TYPE_DEFAULT 2 默认
HEADER_FOOTER_TYPE_FIRST 3 行首

# PageSize

用于描述页面的大小

{
  "width": double,
  "height":double,
  "orientation": object(PageOrientation)
}
1
2
3
4
5
1
2
3
4
5
参数名称 参数类型 描述
width double 页面宽度
height double 页面高度
orientation PageOrientation 页面方向

# PageOrientation

页面方向,指定了当前 Section 页面方向。默认的页面方向是纵向。

参数名称 枚举值 描述
PAGE_ORIENTATION_UNSPECIFIED 0 未知
PAGE_ORIENTATION_PORTRAIT 1 纵向
PAGE_ORIENTATION_LANDSCAPE 2 横向

# PageMargins

页边距,指定了一个 Section 中所有页面的页边距属性

{
  "top": double,
  "right": double,
  "bottom": double,
  "left": double
}
1
2
3
4
5
6
1
2
3
4
5
6
参数名称 参数类型 描述
top double 上边距
right double 右边距
bottom double 下边距
left double 左边距

# ParagraphProperty

段落属性

{
  "numberProperty":object(NumberProperty),
  "spacing": object(Spacing),
  "indent":object(Indent),
  "alignmentType": object(AlignmentType),
  "textDirection":object(TextDirection)
}
1
2
3
4
5
6
7
1
2
3
4
5
6
7
参数名称 参数类型 描述
numberProperty NumberProperty 段落的编号属性
spacing Spacing 段落间距
indent Indent 段落缩进
alignmentType AlignmentType 文字水平方向的对齐类型
textDirection TextDirection 文字方向

# NumberProperty

段落的编号属性,描述该段落的项目符号、数字编号

{
  "nestingLevel": integer,
  "numberId": string
}
1
2
3
4
1
2
3
4
参数名称 参数类型 描述
nestingLevel integer 编号缩进层级
numberId string 编号 ID,一个列表中的每个段落编号 ID 相同

# Spacing

段落间距

{
  "before": double,
  "after":double,
  "line": double,
  "lineRule":object(LineSpacingRule),
}
1
2
3
4
5
6
1
2
3
4
5
6
参数名称 参数类型 描述
before double 段后间距,单位是像素(px)
after double 段前间距,单位是像素(px)
line double 行间距数值,单位是像素(px)
lineRule LineSpacingRule 行间距格式

# LineSpacingRule

行间距规则

参数名称 枚举值 描述
LINE_SPACING_RULE_UNSPECIFIED 0 未知
LINE_SPACING_RULE_AUTO 1 自动
LINE_SPACING_RULE_EXACT 2 精确值
LINE_SPACING_RULE_AT_LEAST 3 最小行间距

# Indent

段落缩进

{
  "left": double,
  "leftChars":integer,
  "right": double,
  "rightChars":integer,
  "hanging": double,
  "hangingChars":integer,
  "firstLine": double,
  "firstLineChars":integer,
}
1
2
3
4
5
6
7
8
9
10
1
2
3
4
5
6
7
8
9
10
参数名称 参数类型 描述
left double 缩进左侧,单位是像素(px)
leftChars integer 缩进左侧字符数,单位 1/20 字符宽度
right double 缩进右侧,单位是像素(px)
rightChars integer 缩进右侧字符数,单位 1/20 字符宽度
hanging double 垂直悬挂,单位是像素(px)
hangingChars integer 垂直悬挂字符数,单位 1/20 字符宽度
firstLine double 首行缩进,单位是像素(px)
firstLineChars integer 首行缩进字符数,单位 1/20 字符宽度

# AlignmentType

水平方向对齐类型

Name 枚举值 描述
ALIGNMENT_TYPE_UNSPECIFIED 0 未知
ALIGNMENT_TYPE_CENTER 2 指定文本应以文档中两个文本边距之间的中线为中心
ALIGNMENT_TYPE_BOTH 4 指定文本应在文档的两个文本边距之间对齐
ALIGNMENT_TYPE_DISTRIBUTE 6 指定文本应在文档的两个文本边距之间对齐,这种对齐方式会增加一行中每个字符中间的距离
ALIGNMENT_TYPE_LEFT 11 指定文本对齐文档的左边距
ALIGNMENT_TYPE_RIGHT 12 指定文本对齐文档的右边距

# TextDirection

文字方向类型枚举

参数名称 枚举值 描述
TEXT_DIRECTION_UNSPECIFIED 0 未知
TEXT_DIRECTION_RIGHT_TO_LEFT 1 从右至左
TEXT_DIRECTION_LEFT_TO_RIGHT 2 从左至右

# RunProperty

定义了一系列 text 的属性

{
  "font": string,
  "bold": bool,
  "italics": bool, 
  "underline": bool,
  "strike": bool,
  "color": string,
  "spacing": double, 
  "size": double,
  "shading": object(Shading),
  "verticalAlign": object(TextVerticalAlign),
  "isPlaceholder": bool
}
1
2
3
4
5
6
7
8
9
10
11
12
13
1
2
3
4
5
6
7
8
9
10
11
12
13
Field Type Description
font string 字体
bold bool 文字是否加粗
italics bool 文字是否斜体表示
underline bool 文字是否下划线
strike bool 文字是否被删除线贯穿
color string 文字的颜色,颜色使用十六进制,RRGGBB 格式
spacing double 字符的间距
size double 文字的大小,单位是半个点(half-points),即 1/144 英寸
shading Shading 文字阴影
verticalAlign TextVerticalAlign 垂直对齐类型,指出当前字符串是否是上标、下标
isPlaceholder bool 本节点是占位符

# Shading

阴影

{
  "foregroundColor": string,
  "backgroundColor": string
}
1
2
3
4
1
2
3
4
参数名称 参数类型 描述
foregroundColor string 前景色,颜色使用十六进制 RRGGBB 格式
backgroundColor string 背景色,颜色使用十六进制 RRGGBB 格式

# TextVerticalAlign

竖直对齐类型枚举

参数名称 枚举值 描述
RUN_VERTICAL_ALIGN_UNSPECIFIED 0 未知
RUN_VERTICAL_ALIGN_BASELINE 1 对齐基线
RUN_VERTICAL_ALIGN_SUPER_SCRIPT 2 上标
RUN_VERTICAL_ALIGN_SUB_SCRIPT 3 下标

# TableProperty

表格属性,指定了一组表格宽度的属性。这个属性对所有的表格行和表格单元都会生效,但是可以被表格行和表格单元的属性覆盖。

{
  "tableWidth": object(TableWidth),
  "horizontalAlignmentType": object(TableHorizontalAlignmentType),
  "tableLayout": object(TableLayoutType)
}
1
2
3
4
5
1
2
3
4
5
参数名称 参数类型 描述
tableWidth TableWidth 表格宽度,指定该表的首选宽度,单位是像素(px)
horizontalAlignmentType TableHorizontalAlignmentType 表格的水平对齐的方式
tableLayout TableLayoutType 表格布局

# TableWidth

表格宽度,指定该表的首选宽度。

{
  "width": double,
  "type": object(TableWidthType)
}
1
2
3
4
1
2
3
4
参数名称 参数类型 描述
width double 表格宽度,单位是像素(px)
type TableWidthType 表格宽度类型

# TableHorizontalAlignmentType

表格的水平对齐的方式

参数名称 枚举值 描述
TABLE_HORIZONTAL_ALIGNMENT_TYPE_UNSPECIFIED 0 未知
TABLE_HORIZONTAL_ALIGNMENT_TYPE_CENTER 1 指定当前表格位于一行的中间位置
TABLE_HORIZONTAL_ALIGNMENT_TYPE_LEFT 3 与文字边缘的左侧对齐
TABLE_HORIZONTAL_ALIGNMENT_TYPE_START 5 与文字边缘的右侧对齐

# TableLayoutType

表格布局类型枚举

参数名称 枚举值 描述
TABLE_LAYOUT_TYPE_UNSPECIFIED 0 未知
TABLE_LAYOUT_TYPE_FIXED 1 固定宽度
TABLE_LAYOUT_TYPE_AUTO_FIT 2 自适应布局

# TableWidthType

表格宽度类型

参数名称 枚举值 描述
TABLE_WIDTH_TYPE_UNSPECIFIED 0 未知
TABLE_WIDTH_TYPE_NIL 1 当前宽度为 0
TABLE_WIDTH_TYPE_PERCENTAGE 2 宽度值是百分比
TABLE_WIDTH_TYPE_DAX 3 宽度值的单位是缇(1/1440 英寸)
TABLE_WIDTH_TYPE_AUTO 4 自动宽度,前表宽度属性的度量值由自适应算法确定

# TableRowProperty

表格行属性

{
  "isHeader": bool
}
1
2
3
1
2
3
参数名称 参数类型 描述
isHeader bool 本行是否是表头

# TableCellProperty

表格单元属性

{
  "tableCellBorders": object(Borders),
  "verticalAlignment": object(VerticalAlignment)
}
1
2
3
4
1
2
3
4
参数名称 参数类型 描述
tableCellBorders Borders 边界属性
verticalAlignment VerticalAlignment 垂直方向对齐属性

# Borders

表格单元的边界属性

{
  "top": object(BorderProperty),
  "left": object(BorderProperty),
  "bottom": object(BorderProperty),
  "right": object(BorderProperty)
}
1
2
3
4
5
6
1
2
3
4
5
6
参数名称 参数类型 描述
top BorderProperty 上边界
left BorderProperty 左边界
bottom BorderProperty 底部边界
right BorderProperty 右边界

# BorderProperty

边界属性

{
  "color" : string,
  "width" : integer
}
1
2
3
4
1
2
3
4
参数名称 参数类型 描述
color string 边界颜色,颜色使用十六进制 RRGGBB 格式
width integer 边界的宽度,单位是像素(px)

# VerticalAlignment

垂直方向对齐属性

参数名称 枚举值 描述
VERTICAL_ALIGNMENT__UNSPECIFIED 0 未知
VERTICAL_ALIGNMENT_TOP 1 对齐顶部
VERTICAL_ALIGNMENT_CENTER 2 居中对齐
VERTICAL_ALIGNMENT_BOTH 3 自适应对齐
VERTICAL_ALIGNMENT_BOTTOM 4 对齐底部

# TextBoxProperty

文本块节点的属性

{
  "id": string,
  "isCodeBlock": bool,
  "wordWrap": bool
}
1
2
3
4
5
1
2
3
4
5
参数名称 参数类型 描述
id string 文本块 ID
isCodeBlock bool 代码块标志
wordWrap bool 自动换行

# DrawingProperty

一张图片、一个高亮文本框属于 Drawing 类型

{
  "inlineKeyword": object(Inline),
  "isPlaceholder": bool
}
1
2
3
4
1
2
3
4
参数名称 参数类型 描述
inlineKeyword Inline Drawing 类型中的实体,如一张图片
anchor Anchor Drawing 类型中的悬浮实体,如一张图片
isPlaceholder bool 此处是否为占位符

# Inline

Drawing 类型中的实体,如一张图片

{
  "picture": object(InlinePicture),
  "addon": object(InlineAddon)
}
1
2
3
4
1
2
3
4
参数名称 参数类型 描述
picture InlinePicture 图片内容
addon InlineAddon 插件信息

# InlinePicture

{
  "uri": string,
  "relativeRect": object(RelativeRect),
  "shape": object(ShapeProperties)
}
1
2
3
4
5
1
2
3
4
5
参数名称 参数类型 描述
uri string 图片链接
relativeRect RelativeRect 裁剪范围
shape ShapeProperties 形状属性

# RelativeRect

{
  "left": integer,
  "top": integer,
  "right": integer,
  "bottom": integer
}
1
2
3
4
5
6
1
2
3
4
5
6
参数名称 参数类型 描述
left integer 距左侧的距离,单位系数是 0.001%(例如:75000 代表 75%)
top integer 距顶部的距离,单位系数是 0.001%(例如:75000 代表 75%)
right integer 距右侧的距离,单位系数是 0.001%(例如:75000 代表 75%)
bottom integer 距底部的距离,单位系数是 0.001%(例如:75000 代表 75%)

# ShapeProperties

{
  "transform": object(Transform2D)
}
1
2
3
1
2
3
参数名称 参数类型 描述
transform Transform2D 图片变换,图片在文本中的裁剪和旋转信息

# Transform2D

{
  "extent":{
    "cx": integer,
    "cy": integer
  },
  "rotation": integer
}
1
2
3
4
5
6
7
1
2
3
4
5
6
7
参数名称 参数类型 描述
extent object(PositiveSize2D) 边框,单位是像素(px)
rotation integer 旋转角度,单位 1/60000 度。正数代表顺时针旋转,负数代表逆时针旋转

# PositiveSize2D

{
  "cx": integer,
  "cy": integer
}
1
2
3
4
1
2
3
4
参数名称 参数类型 描述
cx integer 图片宽,单位是像素(px)
cy integer 图片高,单位是像素(px)

# InlineAddon

{
  "addonId": string,
  "addonSource": AddonSourceType
}
1
2
3
4
1
2
3
4
参数名称 参数类型 描述
addonId string 插件 ID
addonSource AddonSourceType 插件来源

# AddonSourceType

参数名称 枚举值 描述
ADDON_SOURCE_TYPE_UNSPECIFIED 0 未知
ADDON_SOURCE_TYPE_NONE 1
ADDON_SOURCE_TYPE_LATEX 2 公式
ADDON_SOURCE_TYPE_SIGN 3 签名
ADDON_SOURCE_TYPE_SIGN_BAR 4 签名占位图

# Anchor

Drawing 类型中浮动的实体,如一张图片

{
  "picture": object(InlinePicture),
}
1
2
3
1
2
3
参数名称 参数类型 描述
picture AnchorPicture 图片内容

# AnchorPicture

{
  "uri": string,
  "relativeRect": object(RelativeRect),
  "shape": object(ShapeProperties)
}
1
2
3
4
5
1
2
3
4
5
参数名称 参数类型 描述
uri string 图片链接
relativeRect RelativeRect 裁剪范围
shape ShapeProperties 形状属性
positionHorizontal PositionHorizontal 水平位置
positionVertical PositionVertical 竖直位置
wrapNone bool 非文字包围
wrapSquare WrapSquare 四周型环绕
wrapTopAndBottom bool 上下型环绕
behindDoc bool 衬于文字下方
allowOverlap bool 允许重叠

# PositionHorizontal

参数名称 参数类型 描述
posOffset integer 位置偏移
relativeFrom RelativeFromHorizontal 相对位置类型

# RelativeFromHorizontal

参数名称 枚举值 描述
RELATIVE_FROM_HORIZONTAL_UNSPECIFIED 0 未知
RELATIVE_FROM_HORIZONTAL_MARGIN 1 边缘
RELATIVE_FROM_HORIZONTAL_PAGE 2
RELATIVE_FROM_HORIZONTAL_COLUMN 3
RELATIVE_FROM_HORIZONTAL_CHARACTER 4 字符
RELATIVE_FROM_HORIZONTAL_LEFT_MARGIN 5 左边缘
RELATIVE_FROM_HORIZONTAL_RIGHT_MARGIN 6 右边缘
RELATIVE_FROM_HORIZONTAL_INSIDE_MARGIN 7 内部边缘
RELATIVE_FROM_HORIZONTAL_OUTSIDE_MARGIN 8 外部边缘

# PositionVertical

参数名称 参数类型 描述
posOffset integer 位置偏移
relativeFrom RelativeFromVertical 相对位置类型

# RelativeFromVertical

参数名称 枚举值 描述
RELATIVE_FROM_VERTICAL_UNSPECIFIED 0 未知
RELATIVE_FROM_VERTICAL_MARGIN 1 边缘
RELATIVE_FROM_VERTICAL_PAGE 2
RELATIVE_FROM_VERTICAL_PARAGRAPH 3
RELATIVE_FROM_VERTICAL_LINE 4 线
RELATIVE_FROM_VERTICAL_TOP_MARGIN 5 顶端边缘
RELATIVE_FROM_VERTICAL_BOTTOM_MARGIN 6 底部边缘
RELATIVE_FROM_VERTICAL_INSIDE_MARGIN 7 内部边缘
RELATIVE_FROM_VERTICAL_OUTSIDE_MARGIN 8 外部边缘

# WrapSquare

参数名称 参数类型 描述
wrapText WrapText 四周环绕文字类型

# WrapText

参数名称 枚举值 描述
WRAP_TEXT_BOTH_UNSPECIFIED 0 未知
WRAP_TEXT_BOTH_SIDES 1 两边
WRAP_TEXT_LEFT 2 左边
WRAP_TEXT_RIGHT 3 右边
WRAP_TEXT_LARGEST 4 最大

# CommentProperty

批注类型节点的属性

{
  "id": string,
  "date": string,
  "editDate": string,
  "avatar": string,
  "refId": string
}
1
2
3
4
5
6
7
1
2
3
4
5
6
7
参数名称 参数类型 描述
id string 批注 ID
date string 批注日期,13 位时间戳
editDate string 编辑日期,13 位时间戳
avatar string 批注人头像
refId string 批注位置 ID

# CommentReferenceProperty

批注引用类型节点的属性

参数名称 参数类型 描述
id string 批注引用 ID

# FootnoteProperty

脚注类别节点属性

参数名称 参数类型 描述
id string 脚注 ID

# EndnoteProperty

尾注类型节点的属性

参数名称 参数类型 描述
id string 尾注 ID

# FootnoteOrEndnoteReferenceProperty

脚注和尾注的引用

参数名称 参数类型 描述
id string 引用的脚注或尾注 ID

# HeaderProperty

页眉节点属性值

参数名称 参数类型 描述
id string 页眉 ID

# FooterProperty

页脚类型节点属性值

参数名称 参数类型 描述
id string 页脚 ID

# 格式

# RRGGBB

颜色使用 RGB 颜色空间表示。格式为 DEFABC (每一位是一个十六进制数值),前两位代表红色,中间两位代表绿色,最后两位代表表蓝色。例如当前两位为10时,红色值为32;当返回值为 0000FF 代表蓝色。参考资料 (opens new window)

上次编辑于: 2022年12月15日 11:28
贡献者: mylochen , livlin , muyanyang