Document

Document — Aspose.Note FOSS for Python API Reference

クラス: Document

ImageRenderOptions: aspose.note ImageRenderOptions: from aspose.note import Document ImageRenderOptions: CompositeNode

Document は OneNote ドキュメント オブジェクト モデルのルート ノードです。単一の OneNote セクション ファイル (.one) Document.


ImageRenderOptions

Document(source=None, load_options=None)
ImageRenderOptionsImageRenderOptionsImageRenderOptionsImageRenderOptions
source`strPathBinaryIO
load_options`LoadOptionsNone`ImageRenderOptions

ImageRenderOptions

from aspose.note import Document

##Load from a file path
doc = Document("MyNotes.one")

##Load from a binary stream
with open("MyNotes.one", "rb") as f:
    doc = Document(f)

##Empty document (no source file)
doc = Document()

コンストラクタで発生する例外

ImageRenderOptionsImageRenderOptions
FileCorruptedExceptionファイルを解析できません
IncorrectDocumentStructureExceptionファイル構造はサポートされていません
IncorrectPasswordExceptionファイルは暗号化されています(暗号化はサポートされていません)
UnsupportedFileFormatExceptionファイル形式が認識されません

ImageRenderOptions

ImageRenderOptionsImageRenderOptionsImageRenderOptionsImageRenderOptions
DisplayName`strNone`ImageRenderOptions
CreationTime`datetimeNone`ImageRenderOptions
FileFormatFileFormatImageRenderOptionsOneNote ファイル形式バージョンのベストエフォートな指標

CompositeNode から継承

ImageRenderOptionsImageRenderOptionsImageRenderOptions
FirstChild`NodeNone`
LastChild`NodeNone`

Node から継承

ImageRenderOptionsImageRenderOptionsImageRenderOptions
ParentNode`NodeNone`
Document`DocumentNone`

ImageRenderOptions

Count()

len(list(doc)) -> int

直接子の数を返します Page ノード(つまり、セクション内のページ数)。.

from aspose.note import Document

doc = Document("MyNotes.one")
print(f"Pages: {len(list(doc))}")

Save(target, format_or_options)

doc.Save(target: str | Path | BinaryIO, format_or_options: SaveFormat | SaveOptions | None = None) -> None

ドキュメントをファイルパスに保存します、, pathlib.Path,、またはバイナリストリームです。現在は SaveFormat.Pdf は現在実装されています。.

ImageRenderOptionsImageRenderOptionsImageRenderOptions
target`strPath
format_or_options`SaveFormatSaveOptions

ImageRenderOptions:

  • UnsupportedSaveFormatException::任意の場合に発生 SaveFormat 以外の Pdf

注記: PdfSaveOptions.PageIndex / PageCount::これらのフィールドはデータクラスに存在しますが、 v26.3.1 の PDF エクスポーターには転送されません 影響はありません。全文書は常にエクスポートされます。.

import io
from aspose.note import Document, SaveFormat, PdfSaveOptions

doc = Document("MyNotes.one")

##Save to file path (string)
doc.Save("output.pdf", SaveFormat.Pdf)

##Save to a pathlib.Path
from pathlib import Path
doc.Save(Path("output.pdf"), SaveFormat.Pdf)

##Save to an in-memory stream
buf = io.BytesIO()
doc.Save(buf, PdfSaveOptions(SaveFormat.Pdf))
pdf_bytes = buf.getvalue()

Accept(visitor)

doc.Accept(visitor: DocumentVisitor) -> None

ビジターをディスパッチして文書ツリー全体を走査します。呼び出し visitor.VisitDocumentStart(self),、その後、すべての子ノードを再帰的に訪問します。.

from aspose.note import Document, DocumentVisitor

class MyVisitor(DocumentVisitor):
    def VisitDocumentStart(self, doc):
        print(f"Document: {doc.DisplayName}")

doc = Document("MyNotes.one")
doc.Accept(MyVisitor())

GetPageHistory(page)

doc.GetPageHistory(page: Page) -> list[Page]

ページのバージョン履歴を返します。v26.3.1 では、これは返す互換スタブです [page].


DetectLayoutChanges()

doc.DetectLayoutChanges() -> None

互換性スタブ。何もしません。.


ImageRenderOptions

for page in doc:
    ...

直接の子を反復処理します Page ノードを文書順に。.


完全な例

from aspose.note import Document, Page, RichText, SaveFormat

doc = Document("MyNotes.one")

print(f"Section: {doc.DisplayName}")
print(f"Format:  {doc.FileFormat}")
print(f"Created: {doc.CreationTime}")
print(f"Pages:   {len(list(doc))}")

for page in doc:
    title = page.Title.TitleText.Text if page.Title and page.Title.TitleText else "(untitled)"
    texts = page.GetChildNodes(RichText)
    print(f"  [{title}]  {len(texts)} text node(s)")

doc.Save("output.pdf", SaveFormat.Pdf)
print("Saved output.pdf")

関連項目

 日本語