Document

Document — Aspose.Note FOSS for Python API Reference

Sınıf: Document

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

Document OneNote belge nesne modelinin kök düğümüdür. Tek bir OneNote bölüm dosyasını temsil eder (.one) Document.


Enumerations

Document(source=None, load_options=None)
EnumerationsEnumerationsEnumerationsEnumerations
source`strPathBinaryIO
load_options`LoadOptionsNone`Enumerations

Enumerations

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()

Yapıcı tarafından yükseltilen istisnalar

EnumerationsEnumerations
FileCorruptedExceptionDosya ayrıştırılamıyor
IncorrectDocumentStructureExceptionDosya yapısı desteklenmiyor
IncorrectPasswordExceptionDosya şifrelenmiş (şifreleme desteklenmiyor)
UnsupportedFileFormatExceptionDosya formatı tanınmıyor

Enumerations

EnumerationsEnumerationsEnumerationsEnumerations
DisplayName`strNone`Enumerations
CreationTime`datetimeNone`Enumerations
FileFormatFileFormatEnumerationsOneNote dosya formatı sürümünün en iyi çaba ile gösterimi

CompositeNode’dan kalıtılmış

EnumerationsEnumerationsEnumerations
FirstChild`NodeNone`
LastChild`NodeNone`

Node’dan miras alındı

EnumerationsEnumerationsEnumerations
ParentNode`NodeNone`
Document`DocumentNone`

Enumerations

Count()

len(list(doc)) -> int

Doğrudan alt öğe sayısını döndürür Page düğümler (yani, bölümdeki sayfa sayısı).

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

Belgeyi bir dosya yoluna kaydeder, pathlib.Path, ya da bir ikili akışa. Yalnızca SaveFormat.Pdf şu anda uygulanmıştır.

EnumerationsEnumerationsEnumerations
target`strPath
format_or_options`SaveFormatSaveOptions

Enumerations:

  • UnsupportedSaveFormatException: herhangi bir şey için yükseltilir SaveFormat dışında Pdf

Not PdfSaveOptions.PageIndex / PageCount: Bu alanlar dataclass içinde var ancak v26.3.1’de PDF dışa aktarıcısına iletilmez ve hiçbir etkisi yoktur. Tam belge her zaman dışa aktarılır.

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

Ziyaretçiyi tüm belge ağacını dolaşması için gönderir. Çağırır visitor.VisitDocumentStart(self), ardından tüm alt düğümleri özyinelemeli olarak ziyaret eder.

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]

Bir sayfanın sürüm geçmişini döndürür. v26.3.1’de, bu, döndüren bir uyumluluk taslağıdır [page].


DetectLayoutChanges()

doc.DetectLayoutChanges() -> None

Uyumluluk taslağı. İşlem yok.


Enumerations

for page in doc:
    ...

Doğrudan alt çocuğu yineleyerek dolaşır Page belge sırasındaki düğümler.


Tam Örnek

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")

Ayrıca Bakınız

 Türkçe