PDFPage

PDFPage

PDFPage类

Constructor

new PDFPage()

Example
let pdfDoc; // PDFDoc实例
let pdfPage = await pdfDoc.getPageByIndex(0);

Methods

(async) addAnnot(annotJson) → {Promise.<Array.<Annot>>}

Description:
  • 添加注释到PDF页面。
Properties:
Name Type Attributes Description
annotJson.type string 注释类型,支持的类型包括:
- 'highlight'
- 'strikeOut'
- 'underline'
- 'squiggly'
- 'caret'
- 'text'
- 'fileAttachment'
- 'freeText'
- 'ink'
- 'line'
- 'link'
- 'circle'
- 'square'
- 'polygon'
- 'polyline'
- 'stamp'
- 'screen'
annotJson.rect Rect 注释的矩形区域
annotJson.borderInfo Object <optional>
边框信息,包含以下属性:
- width: 边框宽度
- style: 边框样式,支持的样式包括:0(实线)、1(虚线)、2(下划线)、3(斜面)、4(内嵌)、5(云状)
- cloudIntensity: 云状边框的强度,仅当style为5时有效,取值范围0-2,0表示无云状效果
- dashPhase: 虚线的相位,仅当style为1时有效
- dashes: 虚线的点划数组,仅当style为1时有效
annotJson.alignment number <optional>
对齐方式,仅当type为'freeText'时有效,支持的值包括:0(左对齐)、1(居中)、2(右对齐)
annotJson.buffer Uint8Array <optional>
文件的二进制数据,仅当type为'fileAttachment'或'screen'时有效
annotJson.coords Array.<object> <optional>
文本标记注释的四边形区域数组,仅当type为'textMarkup'时有效
annotJson.creationTimestamp number <optional>
创建时间,仅当type为'markup'时有效
annotJson.date number <optional>
最后修改时间
annotJson.dicts Object <optional>
注释的字典对象
annotJson.defaultAppearance Object <optional>
默认外观属性,仅当type为'freeText'时有效,包含以下属性:
- textColor: 默认文本颜色,格式为0xRRGGBB
- textSize: 默认文本大小
annotJson.endCharIndex number <optional>
文本标记注释的结束字符索引,仅当type为'textMarkup'时有效
annotJson.endPoint Object <optional>
线注释的结束点,仅当type为'line'时有效,包含以下属性:
- x: 结束点的x坐标
- y: 结束点的y坐标
annotJson.flags number <optional>
注释标志
annotJson.measure Object <optional>
测量属性,仅当type为'circle'、'line'、'polyline'、'polygon'或'square'时有效,包含以下属性:
- unit: 测量单位
- ratio: 比例对象,包含以下属性: - ratio.userSpaceValue: 用户空间的比例值
- ratio.userSpaceUnit: 用户空间的比例单位
- ratio.realValue: 实际空间的比例值
- ratio.realUnit: 实际空间的比例单位
annotJson.endStyle number <optional>
线注释结束点的样式,仅当type为'line'时有效
annotJson.fileName string <optional>
文件名,仅当type为'fileAttachment'或'screen'时有效
annotJson.contentType string <optional>
媒体内容的MIME类型,仅当type为'screen'时有效
annotJson.fillColor string <optional>
填充颜色,格式为0xRRGGBB,仅当type为'freeText'、'circle'、'square'或'polygon'时有效
annotJson.iconInfo Object <optional>
印章注释的图标信息,仅当type为'stamp'时有效,包含以下属性:
- annotType: 注释类型,必须为'stamp'
- category: 图标类别
- name: 图标名称,仅支持ASCII字符
- fileType: 图标文件类型,支持'bmp'、'jpg'、'jpeg'、'png'、'webp'、'pdf'
- url: 图标的URL,支持HTTP、file、blob和base64格式
annotJson.icon string <optional>
印章注释的图标名称,仅当type为'stamp'时有效
annotJson.iconCategory string <optional>
印章注释的图标类别,仅当type为'stamp'时有效
annotJson.inkList Array.<object> <optional>
墨迹注释的墨迹列表,仅当type为'ink'时有效且不能为空
annotJson.intent string <optional>
注释的意图名称,仅当type为'markup'时有效
annotJson.multiBuffer Uint8Array <optional>
媒体的二进制数据,仅当type为'screen'时有效
annotJson.name string <optional>
注释的唯一ID
annotJson.noPopup boolean <optional>
是否生成弹出窗口,仅当type为'markup'时有效
annotJson.opacity number <optional>
不透明度,取值范围0-1,仅当type为'markup'时有效
annotJson.startCharIndex number <optional>
文本标记注释的起始字符索引,仅当type为'textMarkup'时有效
annotJson.startStyle number <optional>
线注释起始点的样式,仅当type为'line'时有效
annotJson.startPoint Object <optional>
线注释的起始点,仅当type为'line'时有效,包含以下属性:
- x: 起始点的x坐标
- y: 起始点的y坐标
annotJson.length number <optional>
线注释的引导线长度,仅当type为'line'时有效
annotJson.styleFillColor string <optional>
线注释结束样式的填充颜色,格式为0xRRGGBB,仅当type为'polyline'或'line'时有效
annotJson.subject string <optional>
注释的主题字符串,仅当type为'markup'时有效
annotJson.title string <optional>
注释的标题字符串,仅当type为'markup'时有效
annotJson.vertexes Array.<object> <optional>
多边形或折线注释的顶点数组,仅当type为'polyline'或'polygon'时有效
annotJson.rotation number <optional>
注释的顺时针旋转角度,仅当type为'freeText'、'stamp'或'screen'时有效,'freeText'和'screen'类型支持0、90、180、270四个值,'stamp'类型支持0-360范围内的任意值
annotJson.richText Array.<Object> <optional>
富文本数组,仅支持FreeText注释,每个富文本对象包含以下属性:
- content: 富文本内容字符串,不能为空
- richTextStyle: 富文本样式对象,包含以下属性
- richTextStyle.font: 字体对象,包含以下属性
- richTextStyle.font.name: 字体名称,标准字体不支持样式和字符集属性
- richTextStyle.font.styles: 字体样式
- richTextStyle.font.charset: 字符集
- richTextStyle.textSize: 文本大小,不能为负值,0表示不显示文本
- richTextStyle.textAlignment: 文本对齐方式
- richTextStyle.textColor: 文本颜色,格式为0xRRGGBB
- richTextStyle.isBold: 是否加粗
- richTextStyle.isItalic: 是否斜体
- richTextStyle.isUnderline: 是否下划线
- richTextStyle.isStrikethrough: 是否删除线
- richTextStyle.cornerMarkStyle: 角标样式,1表示无角标,2表示上标,3表示下标
Example
let embedView; // View实例
let pdfPage = await embedView.pdfDoc.getPageByIndex(0);
let annots = await pdfPage.addAnnot({
  type: 'square',
  rect: { left: 100, right: 200, top: 200, bottom: 100 },
  content: 'This is a text annotation',
});
Parameters:
Name Type Description
annotJson Object 注释的JSON对象
Returns:
Type
Promise.<Array.<Annot>>

(async) getAnnots() → {Promise.<Array.<Annot>>}

Description:
  • 获取PDF页面上的所有注释。
Returns:
Type
Promise.<Array.<Annot>>

(async) getAnnotsByIds(annotIds) → {Promise.<Array.<Annot>>}

Description:
  • 获取PDF页面上指定ID的注释。
Parameters:
Name Type Description
annotIds Array.<number> 注释ID数组
Returns:
Type
Promise.<Array.<Annot>>

(async) removeAnnotById(annotId) → {Promise.<Array.<Annot>>}

Description:
  • 从PDF页面中删除指定ID的注释。
Parameters:
Name Type Description
annotId number 注释的ID
Returns:
被删除的注释对象数组
Type
Promise.<Array.<Annot>>