Inici ràpid
Inici ràpid
Aquesta pàgina explica els passos mínims necessaris per llegir un fitxer OneNote .one i exportar-lo a PDF utilitzant Aspose.Noate FOSS per Python.
Condicions previes
| Requirement | Detail |
|---|---|
| Python | 3.10 or later |
| Package | aspose-note >= 26.3.2 |
| OS | Windows, macOS, or Linux |
| Microsoft Office | Not required |
Pas 1 Instal·lar
pip install aspose-note>=26.3.2Pas 2 Carregar un fitxer d’ OneNote
Document és el punt d’entrada root. Passa una ruta de fitxer ̋.one∂ per carregar-lo:
from aspose.note import Document
doc = Document("notebook.one")
print(f"Format : {doc.FileFormat}")
print(f"Pages : {len(list(doc))}")Pas 3 Llegir pàgines i text
`GetChildNodes ((()⌒ retorna tots els descendents directes d’un tipus donat. Utilitza-ho en ̋Document∂ per a pàgines, i en cada ̨Page∂ pels nodes de fulles amb text ric:
from aspose.note import Document, Page, RichText
doc = Document("notebook.one")
for page in doc.GetChildNodes(Page):
if page.Title and page.Title.TitleText:
print(f"Page: {page.Title.TitleText}")
for rt in page.GetChildNodes(RichText):
text = "".join(rt)
if text.strip():
print(f" {text[:120]}")Pas 4 Exportació a PDF
Document.Save() amb ̋SafeFormat.Pdf⌒ genera un PDF sense cap renderer extern:
from aspose.note import Document, SaveFormat
doc = Document("notebook.one")
doc.Save("output.pdf", SaveFormat.Pdf)Primiers passos
- Instal·lació
- Licència
- Característiques de la seva visió general
- KB Articles
- Referència a l’API