Aspose.Note FOSS for Python 是一个 100% 免费、MIT 许可证的库,允许您完全在 Python 中读取 Microsoft OneNote (.one) 文件,无需 Microsoft Office、COM 自动化,也不需要专有运行时。它公开了一个简洁的公共 API(aspose.note.*),其模型基于熟悉的 Aspose.Note 用于 .NET 接口,并由用纯 Python 编写的内置 MS-ONE/OneStore 二进制解析器支持。
使用 pip install aspose-note 从 PyPI 安装(或使用 pip install "aspose-note[pdf]" 启用 PDF 导出)。需要 Python 3.10 或更高版本。
该库适用于文档自动化脚本、内容索引管道、归档工具以及任何需要在不依赖 Microsoft Office 的情况下消费 OneNote 内容的服务器端工作流。企业产品系列请参见 Aspose.Note — Enterprise Product Family。
Document打开任何OneNote部分,从一个文件路径或二进制流中.Document → Page → Outline → OutlineElement → RichText / Image / Table / AttachedFile.RichText.Text阅读原始文档,或检查 TextRun 分段以获取粗字体,斜写字符,字母,颜色和超链接元数据.Table → TableRow → TableCell 的层次结构;通过TableColumn.Width读取列宽度.NoteTag 文本,图像和表节点的元数据 (形状,标记,颜色,完成状态)..one 文件将嵌入图像和附件保存到磁盘上.Document保存到PDP中使用 Document.Save(path, SaveFormat.Pdf). FOSS版本采用默认染;此版不提供高级每页Pdf选项.Image节点来获取原始字节 (Bytes),文件名 ( FileName) 和维度 ( OriginalWidth, OriginalHeight).AttachedFile节点以将嵌入式文件附录存储到磁盘上..one从二进制流 (例如, io.BytesIO) 的文件而无需写入磁盘.Aspose.Note FOSS 使用单个 pip install aspose-note 命令进行安装。基础包没有可选依赖;PDF 导出需要 ReportLab,通过 pip install "aspose-note[pdf]" 安装。
该 API 采用了熟悉的 Aspose.Note 用于 .NET 界面:Document、Page、Outline、RichText、Image、Table、AttachedFile。该库采用 MIT 许可证,开源,并接受在 GitHub 上的错误报告和贡献。
使用 pip 安装,然后传递一个文件路径到 Document() 解析 OneNote 二进制格式. GetChildNodes(RichText)执行深度复用搜索并返回文档中的每个文字节点,这对于全文索引或迁移管道有用.
pip install aspose-note
from aspose.note import Document, RichText
doc = Document("notebook.one")
print(f"Pages: {len(list(doc))}")
# Extract all text across the entire document
texts = [rt.Text for rt in doc.GetChildNodes(RichText) if rt.Text]
for text in texts:
print(text)
需要选择的 ReportLab 依赖. 使用 pip install "aspose-note[pdf]" 安装它. 同样的Document 对象也可以为 Image节点代,以一次传输提取并将所有嵌入图像保存到磁盘上.
from aspose.note import Document, SaveFormat, Image
import pathlib
doc = Document("notebook.one")
# Export the document to PDF (requires aspose-note[pdf])
doc.Save("output.pdf", SaveFormat.Pdf)
# Save all embedded images to disk
out_dir = pathlib.Path("images")
out_dir.mkdir(exist_ok=True)
for i, img in enumerate(doc.GetChildNodes(Image)):
name = img.FileName or f"image_{i}.bin"
(out_dir / name).write_bytes(img.Bytes)
它是一个免费的,获得MIT许可证的Python库来阅读Microsoft OneNote (.one) 文件而不需要 Microsoft Office,COM自动化或任何专有运行时间.
任何有效的.one部分文件都可以加载.
运行pip install aspose-note用于基础库,或 pip install "aspose-note[pdf]" 将可选的 ReportLab 依赖性包含在 PDF 出口中.
是的. 调用Document.Save(path, SaveFormat.Pdf). PDF导出需要通过 [pdf] 额外安装可选的 ReportLab 依赖性.
是的. Document 类接受二进制流 (例如,io.BytesIO 或一个HTTP响应体),因此您可以处理文件而不需要写到磁盘上.
需要Python 3.10或更新的版本.
没有.当前版本仅供读.它可以打开和解析任何有效的.one部分文件,但不支持写回OneNote二进制格式.
没有.加载密码保护的.one文件会产生一个 IncorrectPasswordException.目前版本中不支持加密文档.
图书馆是MIT授权的,并托管在GitHub.错误报告和拉请求都欢迎.