Skip to content

MNDocument

MNDocument是用于文档级操作的核心对象,提供文档读取、页面定位、内容提取和导出等功能,支持获取文档信息、操作页面内容和管理文档相关的学习集。

new MNDocument(document: MbBook|string|MNDocument)

构造一个新的MNDocument实例。

参数名类型必填说明
documentMbBook|string|MNDocument文档对象、文档id或文档URL。
字段名类型说明
cachedDocumentsRecord<string,MNDocument>文档实例缓存。键是docMd5,值是MNDocument实例。
currentDocumentMNDocument当前文档的包装实例。
static async extractPDFPage(path: string,targetPageIndices: number[]): Promise<NSData|undefined>

从PDF中提取指定页并返回新的PDF数据。

参数名类型必填说明
pathstringPDF文件路径。
targetPageIndicesnumber[]要提取的页码数组。
  • 类型:Promise<NSData|undefined>
  • 语义:返回提取的PDF数据或undefined。
字段名类型说明
documentMbBook|undefined原生文档对象。
docMd5string|undefined文档md5。
md5string|undefineddocMd5别名。
idstring|undefineddocMd5别名。
docTitlestring|undefined文档标题。
titlestring|undefineddocTitle别名。
pageCountnumber|undefined文档总页数。
fullPathFileNamestring|undefined文档完整路径。
pathstring|undefinedfullPathFileName别名。
fileDataNSData|undefined文档文件二进制数据。
lastVisitnumber|Date|undefined最近访问时间。
currentTopicIdstring|undefined当前关联学习集id。
currentNotebookIdstring|undefined当前关联学习集id。
currentNotebookMNNotebook|undefined当前关联学习集对象。
cacheContentRecord<number,string>按页缓存文本内容。
tocNotesMNNote[]|undefined文档目录卡片集合。
documentNotebooksMNNote[]以该文档为主文档的文档学习集。
studySetsMNNote[]包含该文档的学习集。
info{ pageCount?: number; docURL: string; file_type?: string; type: string; title?: string; docId?: string; md5: string; currentNotebook?: { id: string; name: string }; path: string; fileExists: boolean; name?: string }文档信息对象,含路径、页数、URL和存在状态。
fileExistsboolean文档文件是否存在。
getFileDataAtPages(pageIndices: number[]): NSData|undefined

读取指定页组成的新PDF数据。

参数名类型必填说明
pageIndicesnumber[]要读取的页码数组。
  • 类型:NSData|undefined
  • 语义:返回PDF数据或undefined。
textContentsForPageNo(pageNo: number): string

读取指定页文本。

参数名类型必填说明
pageNonumber页码。
  • 类型:string
  • 语义:返回页面文本。
getPageContent(pageNo: number,cache?: boolean): string

读取一页文本,可选使用缓存。

参数名类型必填说明
pageNonumber页码。
cacheboolean是否使用缓存。
  • 类型:string
  • 语义:返回页面文本。
getFileContent(asArray?: boolean,cache?: boolean): string|string[]

读取整本文本,可返回拼接字符串或分页数组。

参数名类型必填说明
asArrayboolean是否返回数组。
cacheboolean是否使用缓存。
  • 类型:string|string[]
  • 语义:返回文本字符串或文本数组。
open(notebookId?: string): void

打开该文档。

参数名类型必填说明
notebookIdstring学习集id。
  • 类型:void
  • 语义:无返回值。
openAtPage(pageNo: number,notebookId?: string): Promise<void>

打开文档并定位到指定页。

参数名类型必填说明
pageNonumber页码。
notebookIdstring学习集id。
  • 类型:Promise<void>
  • 语义:无返回值。
documentNotebookInStudySet(notebookId?: string): MNNotebook|undefined

在学习集中查找该文档对应的文档学习集。

参数名类型必填说明
notebookIdstring学习集id。
  • 类型:MNNotebook|undefined
  • 语义:返回文档学习集或undefined。
notesInDocumentInStudySet(notebookId?: string): MNNote[]

获取该文档在学习集对应文档学习集下的卡片。

参数名类型必填说明
notebookIdstring学习集id。
  • 类型:MNNote[]
  • 语义:返回卡片数组。
mainNoteInNotebook(notebookId?: string): MNNote|undefined

获取文档在学习集中的主卡片。

参数名类型必填说明
notebookIdstring学习集id。
  • 类型:MNNote|undefined
  • 语义:返回主卡片或undefined。
copy(): void

复制文档关键信息到剪贴板。

  • 类型:void
  • 语义:无返回值。
头文件 API 清单

正在加载…

协议:,来源: