aspose-note-foss 26.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aspose_note_foss-26.9.0/LICENSE +21 -0
- aspose_note_foss-26.9.0/MANIFEST.in +4 -0
- aspose_note_foss-26.9.0/PKG-INFO +560 -0
- aspose_note_foss-26.9.0/README.md +528 -0
- aspose_note_foss-26.9.0/THIRD_PARTY_NOTICES.md +42 -0
- aspose_note_foss-26.9.0/pyproject.toml +47 -0
- aspose_note_foss-26.9.0/setup.cfg +4 -0
- aspose_note_foss-26.9.0/src/aspose/__init__.py +8 -0
- aspose_note_foss-26.9.0/src/aspose/note/__init__.py +71 -0
- aspose_note_foss-26.9.0/src/aspose/note/_internal/__init__.py +1 -0
- aspose_note_foss-26.9.0/src/aspose/note/_internal/ms_one/__init__.py +5 -0
- aspose_note_foss-26.9.0/src/aspose/note/_internal/ms_one/entities/__init__.py +18 -0
- aspose_note_foss-26.9.0/src/aspose/note/_internal/ms_one/loader.py +1046 -0
- aspose_note_foss-26.9.0/src/aspose/note/_internal/onestore/__init__.py +12 -0
- aspose_note_foss-26.9.0/src/aspose/note/_internal/onestore/parser.py +812 -0
- aspose_note_foss-26.9.0/src/aspose/note/enums.py +37 -0
- aspose_note_foss-26.9.0/src/aspose/note/exceptions.py +58 -0
- aspose_note_foss-26.9.0/src/aspose/note/model.py +1381 -0
- aspose_note_foss-26.9.0/src/aspose/note/saving/__init__.py +8 -0
- aspose_note_foss-26.9.0/src/aspose/note/saving/options.py +49 -0
- aspose_note_foss-26.9.0/src/aspose/note/saving/pdf_writer.py +1829 -0
- aspose_note_foss-26.9.0/src/aspose_note_foss.egg-info/PKG-INFO +560 -0
- aspose_note_foss-26.9.0/src/aspose_note_foss.egg-info/SOURCES.txt +34 -0
- aspose_note_foss-26.9.0/src/aspose_note_foss.egg-info/dependency_links.txt +1 -0
- aspose_note_foss-26.9.0/src/aspose_note_foss.egg-info/requires.txt +12 -0
- aspose_note_foss-26.9.0/src/aspose_note_foss.egg-info/top_level.txt +1 -0
- aspose_note_foss-26.9.0/tests/test_aspose_note_compat_smoke.py +113 -0
- aspose_note_foss-26.9.0/tests/test_aspose_note_dom_content.py +178 -0
- aspose_note_foss-26.9.0/tests/test_aspose_note_dom_document.py +215 -0
- aspose_note_foss-26.9.0/tests/test_aspose_note_exceptions_and_stubs.py +140 -0
- aspose_note_foss-26.9.0/tests/test_aspose_note_history.py +168 -0
- aspose_note_foss-26.9.0/tests/test_aspose_note_pdf_goldens.py +144 -0
- aspose_note_foss-26.9.0/tests/test_aspose_note_richtext_formatting.py +226 -0
- aspose_note_foss-26.9.0/tests/test_aspose_note_save_options.py +758 -0
- aspose_note_foss-26.9.0/tests/test_aspose_note_tags.py +226 -0
- aspose_note_foss-26.9.0/tests/test_imports_smoke.py +20 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aspose
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aspose-note-foss
|
|
3
|
+
Version: 26.9.0
|
|
4
|
+
Summary: Aspose.Note-compatible Python API for reading OneNote (.one) files
|
|
5
|
+
Author: Aspose
|
|
6
|
+
License-Expression: LicenseRef-Aspose-Split
|
|
7
|
+
Project-URL: Homepage, https://github.com/aspose-note-foss/Aspose.Note-FOSS-for-Python
|
|
8
|
+
Project-URL: Repository, https://github.com/aspose-note-foss/Aspose.Note-FOSS-for-Python
|
|
9
|
+
Project-URL: Issues, https://github.com/aspose-note-foss/Aspose.Note-FOSS-for-Python/issues
|
|
10
|
+
Keywords: onenote,one,aspose,parser,pdf
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Topic :: File Formats
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
License-File: THIRD_PARTY_NOTICES.md
|
|
22
|
+
Provides-Extra: pdf
|
|
23
|
+
Requires-Dist: reportlab>=3.6; extra == "pdf"
|
|
24
|
+
Provides-Extra: test-pdf
|
|
25
|
+
Requires-Dist: pypdf>=5.3; extra == "test-pdf"
|
|
26
|
+
Requires-Dist: Pillow>=10.0; extra == "test-pdf"
|
|
27
|
+
Requires-Dist: PyMuPDF>=1.25; extra == "test-pdf"
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
30
|
+
Requires-Dist: twine>=5.0; extra == "dev"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# Aspose.Note FOSS for Python
|
|
34
|
+
|
|
35
|
+
[](https://pypi.org/project/aspose-note-foss/) [](https://pypi.org/project/aspose-note-foss/) [](LICENSE) [](https://github.com/aspose-note-foss/Aspose.Note-FOSS-for-Python/actions/workflows/ci.yml)
|
|
36
|
+
|
|
37
|
+
[](https://products.aspose.org/note/python/)
|
|
38
|
+
|
|
39
|
+
Aspose.Note FOSS for Python is a free, open-source Python library for working with Microsoft
|
|
40
|
+
OneNote `.one` files. It gives Python programs read access to OneNote notebooks — pages, rich
|
|
41
|
+
text, images, attachments, tables, tags, and numbered lists — and can export pages to PDF, with
|
|
42
|
+
no Microsoft OneNote installation or COM automation involved.
|
|
43
|
+
|
|
44
|
+
## Navigation
|
|
45
|
+
|
|
46
|
+
- [At a Glance](#at-a-glance)
|
|
47
|
+
- [Key Capabilities](#key-capabilities)
|
|
48
|
+
- [Installation](#installation)
|
|
49
|
+
- [Quick Start](#quick-start)
|
|
50
|
+
- [Additional Examples](#additional-examples)
|
|
51
|
+
- [API Reference](#api-reference)
|
|
52
|
+
- [Documentation & Resources](#documentation--resources)
|
|
53
|
+
- [Scope and Limitations](#scope-and-limitations)
|
|
54
|
+
- [Development and Testing](#development-and-testing)
|
|
55
|
+
- [License](#license)
|
|
56
|
+
|
|
57
|
+
## At a Glance
|
|
58
|
+
|
|
59
|
+
```mermaid
|
|
60
|
+
flowchart TD
|
|
61
|
+
subgraph StartingPoints["Starting Points"]
|
|
62
|
+
direction TB
|
|
63
|
+
i1["An existing OneNote (.one) file"]
|
|
64
|
+
end
|
|
65
|
+
PRODUCT["Aspose.Note FOSS for Python"]
|
|
66
|
+
subgraph Capabilities["Core Capabilities"]
|
|
67
|
+
direction LR
|
|
68
|
+
subgraph capl[" "]
|
|
69
|
+
direction TB
|
|
70
|
+
c1["Parse the MS-ONE/OneStore binary container"]
|
|
71
|
+
c2["Traverse the Document/Page/Outline DOM"]
|
|
72
|
+
c3["Extract rich text and hyperlinks"]
|
|
73
|
+
end
|
|
74
|
+
subgraph capr[" "]
|
|
75
|
+
direction TB
|
|
76
|
+
c4["Extract images and attached files"]
|
|
77
|
+
c5["Inspect tables, tags, and numbered lists"]
|
|
78
|
+
c6["Export pages to PDF"]
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
subgraph Outputs["Outputs"]
|
|
82
|
+
direction TB
|
|
83
|
+
o1["PDF file"]
|
|
84
|
+
end
|
|
85
|
+
StartingPoints --> PRODUCT --> Capabilities --> Outputs
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Key Capabilities
|
|
89
|
+
|
|
90
|
+
- Parse a `.one` file from a path or a binary stream into an Aspose.Note-compatible DOM via `Document`, with no dependency on Microsoft OneNote or COM automation.
|
|
91
|
+
- Traverse the parsed document as a tree of `Page`, `Outline`, `OutlineElement`, `RichText`, `Image`, `Table`, and `AttachedFile` nodes, using `CompositeNode.GetChildNodes()` for type-based search or the `DocumentVisitor` pattern for full traversal.
|
|
92
|
+
- Read page metadata through `Page.Title`, `Page.Author`, `Page.CreationTime`, and `Page.Level`, plus revision history via `PageHistory` and `Document.GetPageHistory()`.
|
|
93
|
+
- Extract rich text with per-run formatting through `TextRun` and `TextStyle` (bold, italic, underline, strikethrough, superscript, subscript, font, color, hyperlinks) and paragraph-level styling via `RichText.ParagraphStyle`.
|
|
94
|
+
- Extract embedded images through `Image` (bytes, file name, dimensions, alignment) and attached files through `AttachedFile` (bytes, file name), ready to save straight to disk.
|
|
95
|
+
- Inspect tables through `Table`, `TableRow`, `TableCell`, and `TableColumn` (rows, cells, and their content); OneNote tags through `NoteTag` (yellow star, question mark, musical note, and custom tags) attached to text, images, and tables; and numbered lists through `NumberList`.
|
|
96
|
+
- Export pages to PDF through `PdfSaveOptions` (`Document.Save(target, SaveFormat.Pdf)`), tuning image compression, JPEG quality, and page range.
|
|
97
|
+
|
|
98
|
+
## Installation
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pip install aspose-note-foss
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
PDF export needs the optional `pdf` extra, which pulls in [ReportLab](https://pypi.org/project/reportlab/):
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
pip install "aspose-note-foss[pdf]"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Requires Python 3.10 or later. The PyPI distribution is named `aspose-note-foss`; the import package is
|
|
111
|
+
`aspose.note` — `from aspose.note import Document`.
|
|
112
|
+
|
|
113
|
+
## Dependencies
|
|
114
|
+
|
|
115
|
+
### Required Package Dependencies
|
|
116
|
+
|
|
117
|
+
No required third-party package dependencies.
|
|
118
|
+
|
|
119
|
+
### Optional Dependencies
|
|
120
|
+
|
|
121
|
+
- `reportlab` — pulled in by the `pdf` extra (`pip install "aspose-note-foss[pdf]"`); required only to export pages to PDF via `Document.Save(..., SaveFormat.Pdf)`.
|
|
122
|
+
- `pypdf`, `Pillow`, `PyMuPDF` — pulled in by the `test-pdf` extra; used by the PDF golden-output tests to compare generated PDFs against stored manifests, not by the library at runtime.
|
|
123
|
+
|
|
124
|
+
### Native and System Requirements
|
|
125
|
+
|
|
126
|
+
- Requires Python 3.10 or later.
|
|
127
|
+
|
|
128
|
+
### Development Dependencies
|
|
129
|
+
|
|
130
|
+
- `build`, `twine` — used to build and publish the package release; not needed to use or test the library.
|
|
131
|
+
|
|
132
|
+
## Quick Start
|
|
133
|
+
|
|
134
|
+
Load a `.one` file, print its display name, and walk its pages:
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
from aspose.note import Document
|
|
138
|
+
|
|
139
|
+
doc = Document("SimpleTable.one")
|
|
140
|
+
print(doc.DisplayName)
|
|
141
|
+
for page in doc:
|
|
142
|
+
print(page.Title.TitleText.Text)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Export the same document to PDF:
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
from aspose.note import Document, SaveFormat
|
|
149
|
+
|
|
150
|
+
doc = Document("SimpleTable.one")
|
|
151
|
+
doc.Save("out.pdf", SaveFormat.Pdf)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Additional Examples
|
|
155
|
+
|
|
156
|
+
More real, runnable scripts are available in [`examples/`](examples/). The most illustrative one
|
|
157
|
+
beyond Quick Start is saving every embedded image to disk.
|
|
158
|
+
|
|
159
|
+
### Save Embedded Images to Disk
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
from pathlib import Path
|
|
163
|
+
from aspose.note import Document, Image
|
|
164
|
+
|
|
165
|
+
out_dir = Path("out_images")
|
|
166
|
+
out_dir.mkdir(exist_ok=True)
|
|
167
|
+
|
|
168
|
+
doc = Document("3ImagesWithDifferentAlignment.one")
|
|
169
|
+
for i, img in enumerate(doc.GetChildNodes(Image), start=1):
|
|
170
|
+
name = img.FileName or f"image_{i}.png"
|
|
171
|
+
(out_dir / name).write_bytes(img.Bytes)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
<details>
|
|
175
|
+
<summary>View Additional Examples</summary>
|
|
176
|
+
|
|
177
|
+
### Load From a Binary Stream
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
from aspose.note import Document
|
|
181
|
+
|
|
182
|
+
with open("SimpleTable.one", "rb") as f:
|
|
183
|
+
doc = Document(f)
|
|
184
|
+
print(doc.DisplayName, len(list(doc)))
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Traverse Tables (Rows and Cells)
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
from aspose.note import Document, Table, TableRow, TableCell, RichText
|
|
191
|
+
|
|
192
|
+
doc = Document("SimpleTable.one")
|
|
193
|
+
for table in doc.GetChildNodes(Table):
|
|
194
|
+
for row in table.GetChildNodes(TableRow):
|
|
195
|
+
cells = row.GetChildNodes(TableCell)
|
|
196
|
+
values = [" ".join(rt.Text for rt in cell.GetChildNodes(RichText)) for cell in cells]
|
|
197
|
+
print(values)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Extract Attached Files
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
from pathlib import Path
|
|
204
|
+
from aspose.note import Document, AttachedFile
|
|
205
|
+
|
|
206
|
+
doc = Document("OnePageWithFile.one")
|
|
207
|
+
for i, af in enumerate(doc.GetChildNodes(AttachedFile), start=1):
|
|
208
|
+
name = af.FileName or f"attachment_{i}.bin"
|
|
209
|
+
Path(name).write_bytes(af.Bytes)
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Inspect OneNote Tags
|
|
213
|
+
|
|
214
|
+
```python
|
|
215
|
+
from aspose.note import Document, RichText
|
|
216
|
+
|
|
217
|
+
doc = Document("TagSizes.one")
|
|
218
|
+
for rt in doc.GetChildNodes(RichText):
|
|
219
|
+
for tag in rt.Tags:
|
|
220
|
+
print(tag.Label, tag.Status)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Count Nodes With a DocumentVisitor
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
from aspose.note import Document, DocumentVisitor, Page, Image, RichText
|
|
227
|
+
|
|
228
|
+
class Counter(DocumentVisitor):
|
|
229
|
+
def __init__(self):
|
|
230
|
+
self.pages = 0
|
|
231
|
+
self.rich_texts = 0
|
|
232
|
+
self.images = 0
|
|
233
|
+
|
|
234
|
+
def VisitPageStart(self, page: Page) -> None:
|
|
235
|
+
self.pages += 1
|
|
236
|
+
|
|
237
|
+
def VisitRichTextStart(self, rich_text: RichText) -> None:
|
|
238
|
+
self.rich_texts += 1
|
|
239
|
+
|
|
240
|
+
def VisitImageStart(self, image: Image) -> None:
|
|
241
|
+
self.images += 1
|
|
242
|
+
|
|
243
|
+
doc = Document("3ImagesWithDifferentAlignment.one")
|
|
244
|
+
counter = Counter()
|
|
245
|
+
doc.Accept(counter)
|
|
246
|
+
print(counter.pages, counter.rich_texts, counter.images)
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Extract All Text
|
|
250
|
+
|
|
251
|
+
```python
|
|
252
|
+
from aspose.note import Document, RichText
|
|
253
|
+
|
|
254
|
+
doc = Document("FormattedRichText.one")
|
|
255
|
+
texts = [rt.Text for rt in doc.GetChildNodes(RichText)]
|
|
256
|
+
print("\n".join(texts))
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Export to PDF With Custom Options
|
|
260
|
+
|
|
261
|
+
```python
|
|
262
|
+
from aspose.note import Document, SaveFormat
|
|
263
|
+
from aspose.note.saving import PdfSaveOptions
|
|
264
|
+
|
|
265
|
+
doc = Document("TagSizes.one")
|
|
266
|
+
opts = PdfSaveOptions(JpegQuality=90)
|
|
267
|
+
doc.Save("out.pdf", opts)
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Extract Hyperlinks
|
|
271
|
+
|
|
272
|
+
```python
|
|
273
|
+
from aspose.note import Document, RichText
|
|
274
|
+
|
|
275
|
+
doc = Document("FormattedRichText.one")
|
|
276
|
+
for rt in doc.GetChildNodes(RichText):
|
|
277
|
+
for run in rt.TextRuns:
|
|
278
|
+
if run.Style.IsHyperlink and run.Style.HyperlinkAddress:
|
|
279
|
+
print(run.Text, "->", run.Style.HyperlinkAddress)
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Inspect Numbered Lists
|
|
283
|
+
|
|
284
|
+
```python
|
|
285
|
+
from aspose.note import Document, OutlineElement
|
|
286
|
+
|
|
287
|
+
doc = Document("NumberedListWithTags.one")
|
|
288
|
+
for oe in doc.GetChildNodes(OutlineElement):
|
|
289
|
+
nl = oe.NumberList
|
|
290
|
+
if nl is None:
|
|
291
|
+
continue
|
|
292
|
+
print("format=", nl.Format, "number_format=", nl.NumberFormat, "restart=", nl.Restart)
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
</details>
|
|
296
|
+
|
|
297
|
+
## API Reference
|
|
298
|
+
|
|
299
|
+
The primary entry point is `Document`, which loads a `.one` file and exposes its pages as a tree
|
|
300
|
+
of `Page`, `Outline`, `OutlineElement`, `RichText`, `Image`, `Table`, and `AttachedFile` nodes;
|
|
301
|
+
`Document.Save()` is the sole write path, currently limited to PDF via `PdfSaveOptions`. The
|
|
302
|
+
supported public entry points are `aspose.note` and `aspose.note.saving` — everything under
|
|
303
|
+
`aspose.note._internal` is an implementation detail and may change.
|
|
304
|
+
|
|
305
|
+
<details>
|
|
306
|
+
<summary>View the Supported Public API Surface</summary>
|
|
307
|
+
|
|
308
|
+
### Core API
|
|
309
|
+
|
|
310
|
+
| Class | Description |
|
|
311
|
+
|---|---|
|
|
312
|
+
| `AsposeNoteError` | Base exception for the library; all other library exceptions inherit from it. |
|
|
313
|
+
| `AttachedFile` | A file attached to a page — exposes its raw `Bytes`, `FileName`, and `Tags`. |
|
|
314
|
+
| `CompositeNode` | Base class for every container node (`Document`, `Page`, `Table`, ...); provides child-node access and `GetChildNodes()`. |
|
|
315
|
+
| `Document` | The root DOM object — loads a `.one` file or stream, exposes its `Page` children, and is the sole `Save()` entry point. |
|
|
316
|
+
| `DocumentVisitor` | Base visitor class for traversing the DOM via `Visit*Start`/`Visit*End` callbacks. |
|
|
317
|
+
| `FileCorruptedException` | Raised when the source file's OneStore container is malformed. |
|
|
318
|
+
| `Image` | An embedded image — bytes, file name, dimensions, alignment, and OneNote tags. |
|
|
319
|
+
| `IncorrectDocumentStructureException` | Raised when the parsed OneStore object graph doesn't match the expected document structure. |
|
|
320
|
+
| `IncorrectPasswordException` | Raised when `LoadOptions.DocumentPassword` is supplied — password-protected documents are not supported. |
|
|
321
|
+
| `License` | Compatibility surface for the commercial licensing API; see Scope and Limitations. |
|
|
322
|
+
| `LoadOptions` | Options passed to `Document()` — `DocumentPassword` and `LoadHistory`. |
|
|
323
|
+
| `Metered` | Compatibility surface for the commercial metered-licensing API; see Scope and Limitations. |
|
|
324
|
+
| `Node` | Base class for every DOM node — `ParentNode`, `Document`, and `Accept()`. |
|
|
325
|
+
| `NoteTag` | A OneNote tag (yellow star, question mark, musical note, or custom) attached to text, images, or tables. |
|
|
326
|
+
| `NumberList` | Numbered-list formatting applied to an `OutlineElement`. |
|
|
327
|
+
| `Outline` | A positioned container of `OutlineElement` nodes on a page. |
|
|
328
|
+
| `OutlineElement` | A single outline item — may hold `RichText`, `Image`, `Table`, or nested content, plus an optional `NumberList`. |
|
|
329
|
+
| `Page` | A single OneNote page — title, author, timestamps, level, and revision history. |
|
|
330
|
+
| `PageHistory` | The ordered revision history for a `Page`, returned by `Document.GetPageHistory()`. |
|
|
331
|
+
| `ParagraphStyle` | Default paragraph-level text formatting used by `RichText.ParagraphStyle`. |
|
|
332
|
+
| `RichText` | A run of formatted text content — `Text`, `TextRuns`, alignment, and tags. |
|
|
333
|
+
| `Table` | A table on a page — columns, border visibility, and tags. |
|
|
334
|
+
| `TableCell` | A single cell within a `TableRow`, holding rich text, images, or nested content as child nodes. |
|
|
335
|
+
| `TableColumn` | A table column's width and lock state. |
|
|
336
|
+
| `TableRow` | A row within a `Table`, containing one `TableCell` per column. |
|
|
337
|
+
| `TextRun` | A single formatted run within `RichText.Text` — `Text` plus its `TextStyle`. |
|
|
338
|
+
| `TextStyle` | Character-level formatting — bold, italic, underline, font, color, hyperlink, and more. |
|
|
339
|
+
| `Title` | A page's title — `TitleText`, `TitleDate`, and `TitleTime`, each a `RichText`. |
|
|
340
|
+
| `UnsupportedFileFormatException` | Raised when the source isn't a recognized OneNote format; carries the detected `FileFormat`. |
|
|
341
|
+
| `UnsupportedSaveFormatException` | Raised by `Document.Save()` for anything other than `SaveFormat.Pdf`. |
|
|
342
|
+
|
|
343
|
+
#### Enumerations
|
|
344
|
+
|
|
345
|
+
| Enumeration | Description |
|
|
346
|
+
|---|---|
|
|
347
|
+
| `FileFormat` | The detected OneNote source format (`Unknown`, `OneNote2010`, `OneNoteOnline`, `OneNote2007`). |
|
|
348
|
+
| `HorizontalAlignment` | Horizontal text/image alignment (`Left`, `Center`, `Right`). |
|
|
349
|
+
| `NodeType` | The DOM node kind used by `CompositeNode.GetChildNodes(node_type)`. |
|
|
350
|
+
| `SaveFormat` | The output format accepted by `Document.Save()` — currently only `Pdf`. |
|
|
351
|
+
| `TagStatus` | A `NoteTag`'s completion state (`Open`, `Completed`, `Disabled`). |
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
### Saving
|
|
356
|
+
|
|
357
|
+
| Class | Description |
|
|
358
|
+
|---|---|
|
|
359
|
+
| `AttachmentTagFlowable` | Internal ReportLab `Flowable` that lays out an attachment's tag icon in the generated PDF. |
|
|
360
|
+
| `OutlinePrefixFlowable` | Internal ReportLab `Flowable` that lays out an outline element's numbered-list prefix in the generated PDF. |
|
|
361
|
+
| `PdfSaveOptions` | Options for PDF export — image compression, JPEG quality, page settings, and page range. |
|
|
362
|
+
| `SaveOptions` | Abstract base for save-options types; exposes `SaveFormat`, `PageIndex`, `PageCount`, `FontsSubsystem`. |
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
#### Detailed Member Reference
|
|
367
|
+
|
|
368
|
+
### Document and Traversal
|
|
369
|
+
|
|
370
|
+
- `Document(source=None, load_options=None)`
|
|
371
|
+
- `DisplayName: str | None`, `CreationTime: datetime | None`
|
|
372
|
+
- `FileFormat -> FileFormat` — always reports `OneNote2010`, see Scope and Limitations
|
|
373
|
+
- iteration: `for page in doc: ...`
|
|
374
|
+
- `GetPageHistory(page) -> PageHistory`
|
|
375
|
+
- `DetectLayoutChanges()` — compatibility stub, see Scope and Limitations
|
|
376
|
+
- `Save(target, format_or_options=None)` — `SaveFormat.Pdf` only
|
|
377
|
+
- `PageHistory`
|
|
378
|
+
- `Current: Page`, `Count: int`, `IsReadOnly: bool`
|
|
379
|
+
- `Add(page)`, `AddRange(pages)`, `Remove(page)`, `RemoveAt(index)`, iteration/indexing
|
|
380
|
+
- `DocumentVisitor` — base visitor:
|
|
381
|
+
- `VisitDocumentStart/End`, `VisitPageStart/End`, `VisitTitleStart/End`, `VisitOutlineStart/End`, `VisitOutlineElementStart/End`, `VisitRichTextStart/End`, `VisitImageStart/End`
|
|
382
|
+
- `Node`
|
|
383
|
+
- `ParentNode: Node | None`, `Document: Document | None`, `Accept(visitor)`
|
|
384
|
+
- Container nodes (`Document`, `Page`, `Title`, `Outline`, `OutlineElement`, `Image`, `Table`, `TableRow`, `TableCell`)
|
|
385
|
+
- `FirstChild`, `LastChild`
|
|
386
|
+
- `AppendChildLast(node)`, `AppendChildFirst(node)`, `InsertChild(index, node)`, `RemoveChild(node)`
|
|
387
|
+
- iteration `for child in node: ...`
|
|
388
|
+
- `GetChildNodes(node_type) -> list[TNode]` — recursive search by type
|
|
389
|
+
|
|
390
|
+
### Document Structure
|
|
391
|
+
|
|
392
|
+
- `Page`
|
|
393
|
+
- `Title: Title | None`, `Author: str | None`
|
|
394
|
+
- `CreationTime: datetime | None`, `LastModifiedTime: datetime | None`, `Level: int | None`
|
|
395
|
+
- `Clone(cloneHistory=False) -> Page`
|
|
396
|
+
- `Title`
|
|
397
|
+
- `TitleText: RichText | None`, `TitleDate: RichText | None`, `TitleTime: RichText | None`
|
|
398
|
+
- `Outline`
|
|
399
|
+
- `HorizontalOffset`, `VerticalOffset`, `MaxWidth`, `MaxHeight`, `MinWidth`, `ReservedWidth`, `IndentPosition`, `DescendantsCannotBeMoved`, `LastModifiedTime`
|
|
400
|
+
- `OutlineElement`
|
|
401
|
+
- `NumberList: NumberList | None`
|
|
402
|
+
|
|
403
|
+
### Content
|
|
404
|
+
|
|
405
|
+
- `RichText(Node)`
|
|
406
|
+
- `Text: str`, `TextRuns: list[TextRun]`, `ParagraphStyle: ParagraphStyle`, `Length: int`
|
|
407
|
+
- `Alignment: HorizontalAlignment | None`, `Tags: list[NoteTag]`
|
|
408
|
+
- `Append(text, style=None)`, `Insert(index, text, style=None)`, `Remove(start, count)`, `Replace(old_value, new_value, style=None)`, `Trim()`/`TrimStart()`/`TrimEnd()`, `IndexOf(value, startIndex, count, comparison) -> int`
|
|
409
|
+
- `TextRun`
|
|
410
|
+
- `Text: str`, `Style: TextStyle`
|
|
411
|
+
- `ParagraphStyle`
|
|
412
|
+
- default paragraph-level text formatting; `ParagraphStyle.Default() -> ParagraphStyle`
|
|
413
|
+
- `TextStyle`
|
|
414
|
+
- `IsBold/IsItalic/IsUnderline/IsStrikethrough/IsSuperscript/IsSubscript: bool`, `IsHidden: bool`, `IsMathFormatting: bool`
|
|
415
|
+
- `FontName: str | None`, `FontSize: float | None`, `FontColor: int | None`, `Highlight: int | None`, `Language: int | None`
|
|
416
|
+
- `IsHyperlink: bool`, `HyperlinkAddress: str | None`, `FontStyle: int`
|
|
417
|
+
- `TextStyle.Default()`, `.DefaultMsOneNoteTitleTextStyle()`, `.DefaultMsOneNoteTitleDateStyle()`, `.DefaultMsOneNoteTitleTimeStyle()`
|
|
418
|
+
- `Image`
|
|
419
|
+
- `FileName: str | None`, `Bytes: bytes`, `Width`, `Height`
|
|
420
|
+
- `AlternativeTextTitle`, `AlternativeTextDescription`, `HyperlinkUrl`, `Tags: list[NoteTag]`
|
|
421
|
+
- `Replace(image) -> None`
|
|
422
|
+
- `AttachedFile(Node)`
|
|
423
|
+
- `FileName: str | None`, `Bytes: bytes`, `Tags: list[NoteTag]`
|
|
424
|
+
- `Table`
|
|
425
|
+
- `Columns: list[TableColumn]`, `IsBordersVisible`, `Tags: list[NoteTag]`
|
|
426
|
+
- `TableColumn`
|
|
427
|
+
- `Width: float | None`, `LockedWidth: bool`
|
|
428
|
+
- `NoteTag`
|
|
429
|
+
- `Label`, `Icon`, `Status: TagStatus`, `Highlight`, `CreationTime`, `CompletedTime`, `FontColor`
|
|
430
|
+
- `NoteTag.CreateYellowStar(label)`, `.CreateQuestionMark(label)`, `.CreateMusicalNote(label)`
|
|
431
|
+
- `NumberList`
|
|
432
|
+
- `Format`, `NumberFormat`, `Font`, `FontSize`, `FontColor`, `IsBold`, `IsItalic`, `Restart`
|
|
433
|
+
- `GetNumberedListHeader(number) -> str`
|
|
434
|
+
|
|
435
|
+
### Load and Save Options
|
|
436
|
+
|
|
437
|
+
- `LoadOptions`
|
|
438
|
+
- `DocumentPassword: str | None` — not supported, see Scope and Limitations
|
|
439
|
+
- `LoadHistory: bool`
|
|
440
|
+
- `SaveOptions` (base)
|
|
441
|
+
- `SaveFormat: SaveFormat`, `PageIndex: int`, `PageCount: int | None`, `FontsSubsystem`
|
|
442
|
+
- `PdfSaveOptions(SaveOptions)`
|
|
443
|
+
- `ImageCompression`, `JpegQuality`, `PageSettings`, `PageSplittingAlgorithm`
|
|
444
|
+
|
|
445
|
+
### Licensing
|
|
446
|
+
|
|
447
|
+
- `License.SetLicense(license_path_or_stream)` — no-op in this edition, see Scope and Limitations
|
|
448
|
+
- `Metered.SetMeteredKey(public_key, private_key)` — no-op in this edition, see Scope and Limitations
|
|
449
|
+
|
|
450
|
+
### Enumerations
|
|
451
|
+
|
|
452
|
+
- `FileFormat`: `Unknown`, `OneNote2010`, `OneNoteOnline`, `OneNote2007`
|
|
453
|
+
- `SaveFormat`: `Pdf`
|
|
454
|
+
- `HorizontalAlignment`: `Left`, `Center`, `Right`
|
|
455
|
+
- `NodeType`: `Document`, `Page`, `Outline`, `OutlineElement`, `RichText`, `Image`, `Table`, `AttachedFile`
|
|
456
|
+
- `TagStatus`: `Open`, `Completed`, `Disabled`
|
|
457
|
+
|
|
458
|
+
### Exceptions
|
|
459
|
+
|
|
460
|
+
All inherit from `AsposeNoteError`.
|
|
461
|
+
|
|
462
|
+
- `AsposeNoteError` — base exception for the library
|
|
463
|
+
- `FileCorruptedException` — the OneStore container is malformed
|
|
464
|
+
- `IncorrectDocumentStructureException` — the parsed object graph doesn't match the expected structure
|
|
465
|
+
- `IncorrectPasswordException` — a password was supplied; password-protected documents aren't supported
|
|
466
|
+
- `UnsupportedFileFormatException` — the source isn't a recognized OneNote format (carries `FileFormat`)
|
|
467
|
+
- `UnsupportedSaveFormatException` — `Document.Save()` was called with anything other than `SaveFormat.Pdf`
|
|
468
|
+
|
|
469
|
+
</details>
|
|
470
|
+
|
|
471
|
+
## Documentation & Resources
|
|
472
|
+
|
|
473
|
+
- **[Getting started guide](https://docs.aspose.org/note/python/)** — installation, walkthroughs, and feature guides for this library.
|
|
474
|
+
- **[How-to guides & FAQ](https://kb.aspose.org/note/python/)** — task-focused answers for common OneNote-parsing questions.
|
|
475
|
+
- **[Full API reference](https://reference.aspose.org/note/python/)** — the complete, browsable reference for all 39 public types (the [API reference](#api-reference) section above covers the essentials).
|
|
476
|
+
- Found a bug or have a feature request? [Open an issue](https://github.com/aspose-note-foss/Aspose.Note-FOSS-for-Python/issues) on GitHub.
|
|
477
|
+
|
|
478
|
+
## Scope and Limitations
|
|
479
|
+
|
|
480
|
+
- Writing back to `.one` is not implemented — this library only reads OneNote files.
|
|
481
|
+
- `LoadOptions.DocumentPassword` / encrypted documents are not supported — supplying a password raises `IncorrectPasswordException`.
|
|
482
|
+
- `SaveFormat` currently declares only `Pdf` — `Document.Save()` raises `UnsupportedSaveFormatException` for any other format or options object.
|
|
483
|
+
- `License.SetLicense()` and `Metered.SetMeteredKey()` are present for API-shape compatibility with the commercial product but are no-ops in this edition — no license is required to use this library.
|
|
484
|
+
- `DetectLayoutChanges()` is a compatibility stub and performs no layout computation.
|
|
485
|
+
|
|
486
|
+
These limitations don't apply to
|
|
487
|
+
[Aspose.Note — Enterprise Edition](https://products.aspose.com/note/), the
|
|
488
|
+
full-featured Aspose product — it adds full read/write support (including writing OneNote files
|
|
489
|
+
back out), broader format conversion, and wider OneNote compatibility beyond what this free
|
|
490
|
+
edition covers.
|
|
491
|
+
|
|
492
|
+
## Development and Testing
|
|
493
|
+
|
|
494
|
+
Clone the repository and install the package together with the test extras used in CI:
|
|
495
|
+
|
|
496
|
+
```bash
|
|
497
|
+
git clone https://github.com/aspose-note-foss/Aspose.Note-FOSS-for-Python.git
|
|
498
|
+
cd Aspose.Note-FOSS-for-Python
|
|
499
|
+
python -m pip install -e ".[pdf,test-pdf]"
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
Run the unit test suite the same way [`ci.yml`](.github/workflows/ci.yml) does:
|
|
503
|
+
|
|
504
|
+
```bash
|
|
505
|
+
python -m unittest tests.test_imports_smoke -v
|
|
506
|
+
python -m unittest tests.test_aspose_note_compat_smoke -v
|
|
507
|
+
python -m unittest tests.test_aspose_note_dom_content -v
|
|
508
|
+
python -m unittest tests.test_aspose_note_dom_document -v
|
|
509
|
+
python -m unittest tests.test_aspose_note_exceptions_and_stubs -v
|
|
510
|
+
python -m unittest tests.test_aspose_note_richtext_formatting -v
|
|
511
|
+
python -m unittest tests.test_aspose_note_save_options -v
|
|
512
|
+
python -m unittest tests.test_aspose_note_tags -v
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
<details>
|
|
516
|
+
<summary>PDF Golden Tests and Example Scripts</summary>
|
|
517
|
+
|
|
518
|
+
The PDF golden-output tests (`tests.test_aspose_note_pdf_goldens`) compare generated PDFs against
|
|
519
|
+
manifests in `tests/goldens/pdf/`, not raw bytes, so they stay stable across platforms and
|
|
520
|
+
ReportLab internals. The PDF writer uses deterministic Base-14 fonts by default; set
|
|
521
|
+
`ASPOSE_NOTE_PDF_USE_SYSTEM_FONTS=1` before export if you want to try Windows system fonts for
|
|
522
|
+
local inspection instead:
|
|
523
|
+
|
|
524
|
+
```bash
|
|
525
|
+
python -m unittest tests.test_aspose_note_pdf_goldens -v
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
On a mismatch, the generated PDFs and manifests are written to
|
|
529
|
+
`tests/out/pdf_golden_failures/` for inspection. If `PyMuPDF` is installed, the failing test also
|
|
530
|
+
renders baseline/generated pages to PNG and writes visual diff artifacts into the same output
|
|
531
|
+
tree; if `PyMuPDF` is unavailable but `pdftoppm` is on `PATH`, the tests fall back to `pdftoppm`
|
|
532
|
+
as the renderer.
|
|
533
|
+
|
|
534
|
+
Regenerate the golden baselines after an intentional PDF-output change with
|
|
535
|
+
[`tools/regenerate_pdf_goldens.py`](tools/regenerate_pdf_goldens.py):
|
|
536
|
+
|
|
537
|
+
```bash
|
|
538
|
+
python tools/regenerate_pdf_goldens.py
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
Regenerate only selected cases:
|
|
542
|
+
|
|
543
|
+
```bash
|
|
544
|
+
python tools/regenerate_pdf_goldens.py --case formatted_richtext --case simple_table
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
Runnable example scripts have their own setup and usage notes in
|
|
548
|
+
[`examples/README.md`](examples/README.md).
|
|
549
|
+
[`publish-pypi.yml`](.github/workflows/publish-pypi.yml) shows the exact release-time commands
|
|
550
|
+
this project runs in CI.
|
|
551
|
+
|
|
552
|
+
</details>
|
|
553
|
+
|
|
554
|
+
## License
|
|
555
|
+
|
|
556
|
+
This project is licensed under the [MIT License](LICENSE). The MIT License permits use, copying,
|
|
557
|
+
modification, distribution, sublicensing, and commercial use, provided its copyright and
|
|
558
|
+
permission notice are retained. The software is provided without warranty. The optional PDF-export
|
|
559
|
+
dependency, [ReportLab](https://pypi.org/project/reportlab/), is BSD-3-Clause licensed; see
|
|
560
|
+
[THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for the full text.
|