Aspose.Note FOSS for Python
Tham chiếu này bao phủ toàn bộ bề mặt API công cộng của aspose-note phiên bản 26.3.1. Chỉ các ký hiệu được xuất ra từ aspose.note gói được tài liệu hoá ở đây. Bất kỳ thứ gì dưới aspose.note._internal là chi tiết triển khai và có thể thay đổi mà không thông báo.
Enumerations: pip install aspose-note (core) hoặc pip install "aspose-note[pdf]" (với xuất PDF)
Enumerations: from aspose.note import Document, RichText, ...
Enumerations
Tài liệu và Duyệt
| Enumerations | Enumerations |
|---|---|
Document | Đối tượng tài liệu gốc. Tải một .one tệp, duyệt các trang, và lưu thành PDF. |
DocumentVisitor | Lớp cơ sở trừu tượng cho việc duyệt theo mẫu visitor của cây tài liệu. |
Node | Lớp cơ sở cho tất cả các nút tài liệu. |
CompositeNode | Lớp cơ sở cho các nút có thể chứa các nút con. |
Cấu trúc Tài liệu
| Enumerations | Enumerations |
|---|---|
Page | Biểu diễn một trang OneNote. |
Title | Khối tiêu đề trang chứa TitleText, TitleDate, TitleTime. |
Outline | Bộ chứa vị trí cho các nút OutlineElement. |
OutlineElement | Bộ chứa lá; chứa RichText, Image, Table, AttachedFile. |
Enumerations
| Enumerations | Enumerations |
|---|---|
RichText | Khối văn bản với các đoạn định dạng, thẻ và siêu liên kết. |
TextRun | Đoạn văn bản định dạng đơn trong RichText. |
TextStyle | Thuộc tính định dạng cho TextRun. |
Image | Hình ảnh nhúng với dữ liệu thô và siêu dữ liệu. |
AttachedFile | Tệp đính kèm nhúng với dữ liệu thô. |
Table | Bảng với các hàng, ô và độ rộng cột. |
TableRow | Một hàng trong Table. |
TableCell | Một ô trong TableRow; chứa các nút nội dung. |
NoteTag | Thẻ OneNote (ngôi sao, hộp kiểm, v.v.) gắn vào nút nội dung. |
NumberList | Siêu dữ liệu danh sách có số thứ tự trên một OutlineElement. |
Enumerations
| Enumerations | Enumerations |
|---|---|
LoadOptions | Các tùy chọn để tải một .one tệp. |
SaveOptions | Lớp cơ sở cho các tùy chọn lưu. |
PdfSaveOptions | Các tùy chọn lưu đặc thù cho PDF (biểu tượng thẻ). |
Stub Tương thích
| Enumerations | Enumerations |
|---|---|
License | Mã giả tương thích: SetLicense() không thực hiện gì trong triển khai FOSS này. |
Metered | Mã giả tương thích: SetMeteredKey() không thực hiện gì trong triển khai FOSS này. |
Chi tiết Lớp
Enumerations
Lớp tài liệu gốc. Tải một .one tệp từ đường dẫn tệp, một pathlib.Path, hoặc một luồng nhị phân.
from aspose.note import Document, LoadOptions
doc = Document(source=None, load_options=None)Tham số khởi tạo:
| Enumerations | Enumerations | Enumerations |
|---|---|---|
source | `str | Path |
load_options | `LoadOptions | None` |
Enumerations:
| Enumerations | Enumerations | Enumerations |
|---|---|---|
DisplayName | `str | None` |
CreationTime | `datetime | None` |
FileFormat | FileFormat | Chỉ báo cố gắng tốt nhất về phiên bản định dạng tệp OneNote |
Enumerations:
| Enumerations | Enumerations | Enumerations |
|---|---|---|
Count() | () -> int | Số lượng trang con trực tiếp |
GetPageHistory(page) | (Page) -> list[Page] | Enumerations [page] (đầu giả; lịch sử đầy đủ chưa được triển khai) |
DetectLayoutChanges() | () -> None | Đầu giả tương thích; không thực hiện gì |
Save(target, format_or_options) | `(str | Path |
Accept(visitor) | (DocumentVisitor) -> None | Gọi việc duyệt visitor |
for page in doc | N/A | Lặp qua con trực tiếp Page các nút |
Document.FileFormat ghi chú: Thuộc tính này cung cấp một chỉ báo nỗ lực tốt nhất về phiên bản định dạng tệp OneNote. Thuộc tính FileFormat enum có ba giá trị: OneNote2010, OneNoteOnline, và OneNote2007.
Document.Save() hỗ trợ stream: target có thể là một luồng nhị phân (io.BytesIO, tay cầm tệp được mở ở chế độ ghi nhị phân, v.v.). Điều này được xác nhận bởi bộ kiểm thử: doc.Save(io.BytesIO(), PdfSaveOptions(SaveFormat.Pdf)).
DocumentVisitor
Lớp cơ sở trừu tượng cho việc duyệt theo mẫu visitor. Ghi đè các phương thức visit mà bạn cần:
| Enumerations | Được gọi khi |
|---|---|
VisitDocumentStart(doc) | Đang vào nút Document |
VisitDocumentEnd(doc) | Rời khỏi nút Document |
VisitPageStart(page) | Đang vào nút Page |
VisitPageEnd(page) | Rời khỏi nút Page |
VisitTitleStart(title) | Đang vào nút Title |
VisitTitleEnd(title) | Rời khỏi nút Title |
VisitOutlineStart(outline) | Đang vào nút Outline |
VisitOutlineEnd(outline) | Rời khỏi nút Outline |
VisitOutlineElementStart(oe) | Đang vào nút OutlineElement |
VisitOutlineElementEnd(oe) | Rời khỏi nút OutlineElement |
VisitRichTextStart(rt) | Đang vào nút RichText |
VisitRichTextEnd(rt) | Rời khỏi nút RichText |
VisitImageStart(img) | Đang vào nút Image |
VisitImageEnd(img) | Rời khỏi nút Image |
Enumerations
Lớp cơ sở cho tất cả các nút cây tài liệu.
| Thuộc tính / Phương thức | Enumerations | Enumerations |
|---|---|---|
ParentNode | `Node | None` |
Document | `Document | None` |
Accept(visitor) | (DocumentVisitor) -> None | Gửi visitor cho nút này |
CompositeNode
Enumerations Node. Thêm quản lý con:
| Thuộc tính / Phương thức | Enumerations |
|---|---|
FirstChild | Nút con đầu tiên, hoặc None |
LastChild | Nút con cuối cùng, hoặc None |
AppendChildLast(node) | Thêm một nút con vào cuối; sets node.ParentNode = self |
AppendChildFirst(node) | Thêm một nút con vào đầu |
InsertChild(index, node) | Chèn một nút con vào vị trí đã cho |
RemoveChild(node) | Xóa một nút con; sets node.ParentNode = None |
GetEnumerator() | Trả về một iterator trên các nút con trực tiếp |
for child in node | Lặp qua các nút con trực tiếp |
GetChildNodes(Type) | (Type) -> list[Type]: đệ quy, tìm kiếm theo chiều sâu của toàn bộ cây con bao gồm self |
Enumerations
Enumerations CompositeNode. Đại diện cho một trang OneNote.
| Enumerations | Enumerations | Enumerations |
|---|---|---|
Title | `Title | None` |
Author | `str | None` |
CreationTime | `datetime | None` |
LastModifiedTime | `datetime | None` |
Level | `int | None` |
Enumerations:
| Enumerations | Enumerations |
|---|---|
Clone(deep=False) | Trả về một bản sao nông hoặc sâu của trang |
Enumerations
Enumerations CompositeNode. Giữ khối tiêu đề của một Page.
| Enumerations | Enumerations | Enumerations |
|---|---|---|
TitleText | `RichText | None` |
TitleDate | `RichText | None` |
TitleTime | `RichText | None` |
Enumerations
Enumerations CompositeNode. Một container vị trí cho OutlineElement các nút.
| Enumerations | Enumerations | Enumerations |
|---|---|---|
X | `float | None` |
Y | `float | None` |
Width | `float | None` |
OutlineElement
Enumerations CompositeNode. Một container lá chứa các nút nội dung.
| Enumerations | Enumerations | Enumerations |
|---|---|---|
IndentLevel | int | Độ sâu lồng nhau (0 = ngoài cùng) |
NumberList | `NumberList | None` |
Tags | list[NoteTag] | Thẻ OneNote gắn vào phần tử này |
RichText
Enumerations CompositeNode. Một khối văn bản có kiểu dáng.
| Enumerations | Enumerations | Enumerations |
|---|---|---|
Text | str | Chuỗi văn bản thuần đầy đủ (tất cả các đoạn được nối lại) |
Runs | list[TextRun] | Danh sách có thứ tự của các đoạn đã định dạng |
FontSize | `float | None` |
Tags | list[NoteTag] | Thẻ OneNote gắn vào khối này |
Enumerations:
| Enumerations | Enumerations | Enumerations |
|---|---|---|
Append(text, style=None) | `(str, TextStyle | None) -> RichText` |
Replace(old_value, new_value) | (str, str) -> None | Thay thế chuỗi trong bộ nhớ trên Text; không cập nhật Runs |
TextRun
Enumerations Node. Một đoạn văn bản định dạng đơn.
| Enumerations | Enumerations | Enumerations |
|---|---|---|
Text | str | Nội dung văn bản của đoạn (mặc định "") |
Style | TextStyle | Thuộc tính định dạng |
Start | `int | None` |
End | `int | None` |
TextStyle
Enumerations Node. Thuộc tính định dạng theo ký tự cho một TextRun.
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
Bold | bool | False | Enumerations |
Italic | bool | False | Enumerations |
Underline | bool | False | Enumerations |
Strikethrough | bool | False | Enumerations |
Superscript | bool | False | Enumerations |
Subscript | bool | False | Enumerations |
FontName | `str | None` | None |
FontSize | `float | None` | None |
FontColor | `int | None` | None |
HighlightColor | `int | None` | None |
LanguageId | `int | None` | None |
IsHyperlink | bool | False | Liệu lần chạy này có phải là siêu liên kết hay không |
HyperlinkAddress | `str | None` | None |
Enumerations
Enumerations CompositeNode. Một hình ảnh được nhúng.
| Enumerations | Enumerations | Enumerations |
|---|---|---|
FileName | `str | None` |
Bytes | bytes | Dữ liệu hình ảnh thô (mặc định b"") |
Width | `float | None` |
Height | `float | None` |
AlternativeTextTitle | `str | None` |
AlternativeTextDescription | `str | None` |
HyperlinkUrl | `str | None` |
Tags | list[NoteTag] | Thẻ OneNote đính kèm vào hình ảnh này |
Enumerations:
| Enumerations | Enumerations |
|---|---|
Replace(image) | Enumerations Bytes và FileName từ một khác Image nút vào nút này |
AttachedFile
Enumerations CompositeNode. Một tệp đính kèm nhúng.
| Enumerations | Enumerations | Enumerations |
|---|---|---|
FileName | `str | None` |
Bytes | bytes | Dữ liệu tệp thô (mặc định b"") |
Tags | list[NoteTag] | Thẻ OneNote đính kèm vào tệp đính kèm này |
Enumerations
Enumerations CompositeNode. Một bảng trong OutlineElement.
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
Columns | list[float] | [] | Chiều rộng của mỗi cột tính bằng điểm |
IsBordersVisible | bool | True | Có hiển thị viền bảng hay không |
Tags | list[NoteTag] | [] | Thẻ OneNote đính kèm vào bảng này |
TableRow
Enumerations CompositeNode. Một hàng trong một Table. Lặp lại GetChildNodes(TableCell) để truy cập các ô.
TableCell
Enumerations CompositeNode. Một ô trong một TableRow. Chứa RichText, Image, và các nút nội dung khác.
NoteTag
Enumerations Node. Một thẻ OneNote được gắn vào một nút nội dung.
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
shape | `int | None` | None |
label | `str | None` | None |
text_color | `int | None` | None |
highlight_color | `int | None` | None |
created | `int | None` | None |
completed | `int | None` | None |
Ghi chú thời gian: created và completed là các dấu thời gian nguyên thô được phân tích từ định dạng nhị phân MS-ONE, không datetime đối tượng.
Phương thức tạo:
| Enumerations | Enumerations |
|---|---|
NoteTag.CreateYellowStar() | Tạo một NoteTag(shape=None, label="Yellow Star") |
NumberList
Enumerations Node. Siêu dữ liệu danh sách có số hoặc dấu đầu dòng trên một OutlineElement.
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
Format | `str | None` | None |
Restart | `int | None` | None |
IsNumbered | bool | False | Đúng cho danh sách có thứ tự (đánh số) |
LoadOptions
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
DocumentPassword | `str | None` | None |
LoadHistory | bool | False | Trường tương thích API; không được sử dụng chức năng trong v26.3.1 |
SaveOptions
Lớp cơ sở cho tất cả các tùy chọn lưu. Đối số vị trí bắt buộc.
| Enumerations | Enumerations | Enumerations |
|---|---|---|
SaveFormat | SaveFormat | Định dạng lưu đích |
PdfSaveOptions
Enumerations SaveOptions. Cấu hình xuất đặc thù cho PDF. Tạo bằng PdfSaveOptions(SaveFormat.Pdf).
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
PageIndex | int | 0 | Trường tồn tại; không được chuyển tiếp tới bộ xuất PDF trong v26.3.1: không ảnh hưởng đến đầu ra |
PageCount | `int | None` | None |
TagIconDir | `str | None` | None |
TagIconSize | `float | None` | None |
TagIconGap | `float | None` | None |
PageIndex / PageCount cảnh báo: Các trường này được khai báo trên PdfSaveOptions để tương thích API, nhưng Document.Save() cài đặt trong v26.3.1 không đọc hoặc chuyển tiếp chúng tới bộ xuất PDF. Tất cả các trang luôn được xuất.
Giấy phép và Định mức
Các stub tương thích được xuất để duy trì hình dạng API với Aspose.Note cho .NET. Tất cả các phương thức đều không thực hiện gì trong triển khai FOSS này.
from aspose.note import License, Metered
lic = License()
lic.SetLicense("path/to/license.lic") # no-op
m = Metered()
m.SetMeteredKey("public_key", "private_key") # no-opKhông cần khóa giấy phép để sử dụng bất kỳ tính năng nào của Aspose.Note FOSS cho Python.
Enumerations
Tham chiếu liệt kê đầy đủ: Enumerations
SaveFormat
| Enumerations | Enumerations |
|---|---|
SaveFormat.Pdf | Xuất PDF: đã triển khai; yêu cầu pip install "aspose-note[pdf]" |
SaveFormat.One | Định dạng OneNote: chỉ khai báo; gây ra UnsupportedSaveFormatException |
FileFormat
Các giá trị enum đại diện cho phiên bản định dạng tệp OneNote. Document.FileFormat cung cấp một chỉ báo nỗ lực tốt nhất.
| Enumerations | Giá trị chuỗi |
|---|---|
FileFormat.OneNote2010 | "onenote2010" |
FileFormat.OneNoteOnline | "onenoteonline" |
FileFormat.OneNote2007 | "onenote2007" |
HorizontalAlignment
| Enumerations | Giá trị chuỗi |
|---|---|
HorizontalAlignment.Left | "left" |
HorizontalAlignment.Center | "center" |
HorizontalAlignment.Right | "right" |
NodeType
| Enumerations | Giá trị chuỗi |
|---|---|
NodeType.Document | "document" |
NodeType.Page | "page" |
NodeType.Outline | "outline" |
NodeType.OutlineElement | "outline_element" |
NodeType.RichText | "rich_text" |
NodeType.Image | "image" |
NodeType.Table | "table" |
NodeType.AttachedFile | "attached_file" |
Enumerations
Tham chiếu đầy đủ cho ngoại lệ: Enumerations
| Enumerations | Enumerations |
|---|---|
AsposeNoteError | Lớp cơ sở cho tất cả các ngoại lệ Aspose.Note FOSS |
FileCorruptedException | Enumerations .one tệp không thể được phân tích (bị hỏng hoặc nhị phân sai định dạng) |
IncorrectDocumentStructureException | Cấu trúc tệp không hợp lệ hoặc không được hỗ trợ |
IncorrectPasswordException | Được kích hoạt khi LoadOptions.DocumentPassword được đặt; tài liệu được mã hóa không được hỗ trợ |
UnsupportedFileFormatException | Định dạng tệp không được nhận dạng; tiết lộ một FileFormat trường (string) |
UnsupportedSaveFormatException | Yêu cầu SaveFormat không được triển khai trong phiên bản này |