Introduction

Aspose.Note FOSS for Python is now available on PyPI as aspose-note: ฟรี, ห้องสมุดที่มีลิซเซนส์ MIT สําหรับการอ่านและบันทึกไฟล์ Microsoft OneNote ในภาษา Python เฉพาะ, โดยไม่ต้องใช้ Microsoft Office, การอัตโนมัติ COM หรือการขยายพื้นฐานใดๆ.

ติดตั้งมันด้วยคําสั่งเดียว และเริ่มการโหลด .one เผยแพร่ทันที:

pip install aspose-note

อะไรคือ Aspose.Note FOSS สำหรับ Python?

OneNote ของ .one การพรรณรูปแบบเป็นขวดไบนารีที่ได้รับสิทธิพิเศษ การวิเคราะห์มันโดยไม่ต้อง Microsoft’s ห้องสมุดของตัวเองที่ต้องการเครื่องมือวิเคราะห์กลับ หรือ COM ของ Windows โดยเฉพาะ หน่วยงานที่ใช้บริการ Aspose.Note FOSS ให้การดําเนินการ Python ที่เรียกว่า รูปแบบและส่งออกเป็น PDF บนแพลตฟอร์มใดที่รองรับ Python 3.10 หรือหลังกว่านั้น.

ห้องสมุดเปิดตัวแบบวัตถุเอกสาร: a Document รากที่มี Page ค้อนของ ธ อร์, แต่ละตัวสามารถถือได้ Title, Outline, RichText, Image,และ AttachedFile เด็กๆ. คุณข้ามต้นไม้ด้วย GetChildNodes(), ปรับเปลี่ยนโน้ตด้วย AppendChildLast(),และ นําผลออกเป็น PDF ด้วย Document.Save().


เริ่มต้นอย่างรวดเร็ว

from aspose.note import Document, SaveFormat

# Load a .one file
doc = Document("notebook.one")
print(f"Format: {doc.FileFormat}")

# Save to PDF
doc.Save("notebook.pdf", SaveFormat.Pdf)
print("Saved notebook.pdf")

การ อ่าน หน้า และ ข้อความ

หน้าคือ Page ค้อนใน Document.ทุกคน Page มีการ Title ทรัพย์สินและสามารถ มีอยู่ Outline มีองค์ประกอบ RichText เนื้อหา การใช้งาน GetChildNodes() การเดินต้นไม้:

from aspose.note import Document, Page, RichText

doc = Document("notebook.one")
for page in doc.GetChildNodes(Page):
    title = page.Title
    if title and title.TitleText:
        print(f"Page: {title.TitleText}")
    for rt in page.GetChildNodes(RichText):
        text = "".join(rt)
        if text.strip():
            print(f"  Text: {text[:80]}")

การบันทึกเป็น PDF

Document.Save() รับการเดินทางไฟล์หรือ a BytesIO ธารน้ําและ a SaveFormat ค่าค่านิยม. SaveFormat.Pdf เปลี่ยนแปลงเอกสารเป็น PDF โดยไม่มีการพึ่งพาภายนอกใด ๆ:

import io
from aspose.note import Document, SaveFormat

doc = Document("notebook.one")

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

# Save to an in-memory buffer
buf = io.BytesIO()
doc.Save(buf, SaveFormat.Pdf)
pdf_bytes = buf.getvalue()
print(f"PDF size: {len(pdf_bytes)} bytes")

รูปแบบที่สนับสนุน

FormatExtensionReadWrite
OneNote 2010.one
OneNote 2007.one
OneNote ออนไลน์.one
PDF.pdf

หลักสูตรและใบอนุญาต

Aspose.Note FOSS for Python is released under the MIT License. The package is published ใน PyPI เป็น aspose-note และการใช้งานทางพาณิชย์ การปรับปรุงและการกระจายใหม่ทั้งหมดคือ ได้รับอนุญาตตามเงื่อนไข MIT.


เริ่มต้น