PdfSaveOptions — Aspose.Note FOSS Python API Reference
Class: PdfSaveOptions
Package: aspose.note.saving
Import: from aspose.note.saving import PdfSaveOptions
Inherits: SaveOptions
PdfSaveOptions provides PDF-specific export configuration for Document.Save(). All constructor arguments are keyword-only; the constructor takes no positional arguments.
Constructor
opts = PdfSaveOptions(
*,
PageIndex: int = 0,
PageCount: int | None = None,
FontsSubsystem: Any | None = None,
ImageCompression: Any | None = None,
JpegQuality: int | None = None,
PageSettings: Any | None = None,
PageSplittingAlgorithm: Any | None = None,
)Correct usage:
from aspose.note.saving import PdfSaveOptions
opts = PdfSaveOptions() # all defaults
opts_quality = PdfSaveOptions(JpegQuality=85) # JPEG quality overrideIncorrect (raises TypeError):
# Do NOT pass SaveFormat as a positional or keyword argument:
opts = PdfSaveOptions(SaveFormat.Pdf) # TypeError
opts = PdfSaveOptions(SaveFormat=SaveFormat.Pdf) # TypeErrorThe SaveFormat is fixed to SaveFormat.Pdf internally and cannot be overridden.
Properties
All properties are read/write unless noted.
Inherited from SaveOptions
| Property | Type | Default | Description |
|---|---|---|---|
SaveFormat | SaveFormat | SaveFormat.Pdf | Always SaveFormat.Pdf for this class. Read-only. |
PageIndex | int | 0 | Zero-based index of the first page to export. Not forwarded to the PDF exporter in v26.3.1; has no effect. |
PageCount | int | None | None | Number of pages to export. Not forwarded to the PDF exporter in v26.3.1; has no effect. |
FontsSubsystem | Any | None | None | Font substitution configuration. Not used in the current PDF renderer. |
PdfSaveOptions-specific
| Property | Type | Default | Description |
|---|---|---|---|
ImageCompression | Any | None | None | Image compression setting for embedded images in the PDF output. |
JpegQuality | int | None | None | JPEG quality (0–100) for compressed image embedding. None uses the renderer default. |
PageSettings | Any | None | None | Per-page size and orientation settings. |
PageSplittingAlgorithm | Any | None | None | Algorithm used to split content that does not fit on a single page. |
Usage Examples
Basic export to file
from aspose.note import Document, SaveFormat
doc = Document("MyNotes.one")
doc.Save("output.pdf", SaveFormat.Pdf)Export with PdfSaveOptions
from aspose.note import Document
from aspose.note.saving import PdfSaveOptions
doc = Document("MyNotes.one")
opts = PdfSaveOptions()
doc.Save("output.pdf", opts)Export to an in-memory stream
import io
from aspose.note import Document
from aspose.note.saving import PdfSaveOptions
doc = Document("MyNotes.one")
buf = io.BytesIO()
doc.Save(buf, PdfSaveOptions())
pdf_bytes = buf.getvalue()
print(f"PDF size: {len(pdf_bytes)} bytes")Set JPEG quality
from aspose.note import Document
from aspose.note.saving import PdfSaveOptions
doc = Document("MyNotes.one")
opts = PdfSaveOptions(JpegQuality=85)
doc.Save("output.pdf", opts)Notes
PageIndexandPageCountare declared onPdfSaveOptionsfor API compatibility with Aspose.Note for .NET, but theDocument.Save()implementation in v26.3.1 does not read or forward them to the PDF exporter. The entire document is always exported regardless of these values.- PDF export requires the optional ReportLab dependency. Install it with
pip install "aspose-note[pdf]". Without ReportLab, callingDocument.Save()with a PDF target raises anImportError.
See Also
- SaveOptions: base class
- SaveFormat:
SaveFormat.Pdfenum value - Document.Save(): the method that accepts
PdfSaveOptions - PDF Export Developer Guide
- How-to: Export OneNote to PDF