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: 이 필드들은 dataclass에 존재하지만 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")

참고

 한국어