Funktionen und Fähigkeiten

Funktionen und Fähigkeiten

Aspose.Slides FOSS for Python bietet ein breites Spektrum an Funktionen zum programmgesteuerten Arbeiten mit PowerPoint .pptx-Dateien. Diese Seite listet alle unterstützten Funktionsbereiche mit repräsentativen Codebeispielen auf.


Präsentation I/O

Öffnen Sie eine vorhandene .pptx‑Datei oder erstellen Sie eine neue und speichern Sie sie anschließend im PPTX‑Format.

import aspose.slides_foss as slides
from aspose.slides_foss.export import SaveFormat

# Open an existing presentation
with slides.Presentation("input.pptx") as prs:
    print(f"Slide count: {len(prs.slides)}")
    prs.save("output.pptx", SaveFormat.PPTX)

# Create a new presentation (starts with one blank slide)
with slides.Presentation() as prs:
    prs.save("new.pptx", SaveFormat.PPTX)

Hinweis: PPTX ist das einzige unterstützte Speicherformat. Der Export nach PDF, HTML, SVG oder Bildern ist nicht verfügbar.

Unbekannte XML‑Teile in der Quelldatei werden beim Speichern unverändert beibehalten, sodass das Öffnen und erneute Speichern eines .pptx niemals Inhalte entfernt werden, die die Bibliothek noch nicht versteht.


Folienverwaltung

Folien hinzufügen, entfernen, klonen und neu anordnen.

import aspose.slides_foss as slides
from aspose.slides_foss.export import SaveFormat

with slides.Presentation() as prs:
    # Access the first slide
    slide = prs.slides[0]

    # Add an additional blank slide at the end
    prs.slides.add_empty_slide(prs.layout_slides[0])

    print(f"Total slides: {len(prs.slides)}")
    prs.save("multi-slide.pptx", SaveFormat.PPTX)

Formen

Fügen Sie AutoShapes, PictureFrames, Tabellen und Verbinder zu einer Folie hinzu.

AutoShapes

import aspose.slides_foss as slides
from aspose.slides_foss import ShapeType
from aspose.slides_foss.export import SaveFormat

with slides.Presentation() as prs:
    slide = prs.slides[0]
    # Add a rectangle at (x=50, y=50) with width=300, height=100
    shape = slide.shapes.add_auto_shape(ShapeType.RECTANGLE, 50, 50, 300, 100)
    shape.add_text_frame("Aspose.Slides FOSS")
    prs.save("shapes.pptx", SaveFormat.PPTX)

Tabellen

import aspose.slides_foss as slides
from aspose.slides_foss.export import SaveFormat

with slides.Presentation() as prs:
    slide = prs.slides[0]
    # Column widths and row heights in points
    col_widths = [120.0, 120.0, 120.0]
    row_heights = [40.0, 40.0, 40.0]
    table = slide.shapes.add_table(50, 50, col_widths, row_heights)
    table.rows[0][0].text_frame.text = "Product"
    table.rows[0][1].text_frame.text = "Quantity"
    table.rows[0][2].text_frame.text = "Price"
    prs.save("table.pptx", SaveFormat.PPTX)

Connectoren

import aspose.slides_foss as slides
from aspose.slides_foss import ShapeType
from aspose.slides_foss.export import SaveFormat

with slides.Presentation() as prs:
    slide = prs.slides[0]
    box1 = slide.shapes.add_auto_shape(ShapeType.RECTANGLE, 50, 100, 150, 60)
    box2 = slide.shapes.add_auto_shape(ShapeType.RECTANGLE, 350, 100, 150, 60)
    conn = slide.shapes.add_connector(ShapeType.BENT_CONNECTOR3, 0, 0, 10, 10)
    conn.start_shape_connected_to = box1
    conn.start_shape_connection_site_index = 3  # right side
    conn.end_shape_connected_to = box2
    conn.end_shape_connection_site_index = 1    # left side
    prs.save("connector.pptx", SaveFormat.PPTX)

Textformatierung

Formatieren Sie Text auf Absatz‑ und Zeichenebene mit PortionFormat.

import aspose.slides_foss as slides
from aspose.slides_foss import ShapeType, NullableBool, FillType
from aspose.slides_foss.drawing import Color
from aspose.slides_foss.export import SaveFormat

with slides.Presentation() as prs:
    slide = prs.slides[0]
    shape = slide.shapes.add_auto_shape(ShapeType.RECTANGLE, 50, 50, 500, 150)
    tf = shape.add_text_frame("Bold blue heading")

    fmt = tf.paragraphs[0].portions[0].portion_format
    fmt.font_height = 28
    fmt.font_bold = NullableBool.TRUE
    fmt.fill_format.fill_type = FillType.SOLID
    fmt.fill_format.solid_fill_color.color = Color.from_argb(255, 0, 70, 127)

    prs.save("text.pptx", SaveFormat.PPTX)

NullableBool.TRUE setzt die Eigenschaft explizit; NullableBool.NOT_DEFINED erbt vom Folienmaster.


Fülltypen

Wenden Sie einfarbige, Farbverlauf-, Muster- oder Bildfüllungen auf Formen an.

import aspose.slides_foss as slides
from aspose.slides_foss import ShapeType, FillType
from aspose.slides_foss.drawing import Color
from aspose.slides_foss.export import SaveFormat

with slides.Presentation() as prs:
    slide = prs.slides[0]
    shape = slide.shapes.add_auto_shape(ShapeType.RECTANGLE, 50, 50, 300, 150)

    # Solid fill
    shape.fill_format.fill_type = FillType.SOLID
    shape.fill_format.solid_fill_color.color = Color.from_argb(255, 30, 120, 200)

    prs.save("fill.pptx", SaveFormat.PPTX)

Visuelle Effekte

Wenden Sie äußeren Schatten, Leuchten, weiche Kante, Unschärfe, Spiegelung und inneren Schatten auf Formen an.

Die Effekt‑Eigenschaften sind über shape.effect_format zugänglich. Setzen Sie outer_shadow_effect, glow_effect, soft_edge_effect, blur_effect, reflection_effect oder inner_shadow_effect, um jede einzeln zu konfigurieren.


3D Formatierung

Wenden Sie 3D‑Fase, Kamera, Lichtanlage, Material und Extrusionstiefe über shape.three_d_format an. Dies steuert die visuelle Tiefe und das Beleuchtungsmodell für die Formdarstellung in PPTX‑Betrachtern, die 3D‑Effekte unterstützen.


Sprecher-Notizen

Fügen Sie Notizen zu einer beliebigen Folie hinzu, indem Sie notes_slide_manager verwenden.

import aspose.slides_foss as slides
from aspose.slides_foss.export import SaveFormat

with slides.Presentation() as prs:
    notes = prs.slides[0].notes_slide_manager.add_notes_slide()
    notes.notes_text_frame.text = "Key talking point: emphasize the ROI benefit."
    prs.save("notes.pptx", SaveFormat.PPTX)

Kommentare

Fügen Sie verschachtelte Kommentare mit Autoreninformationen und Folienposition hinzu.

import aspose.slides_foss as slides
from aspose.slides_foss.drawing import PointF
from aspose.slides_foss.export import SaveFormat
from datetime import datetime

with slides.Presentation() as prs:
    author = prs.comment_authors.add_author("Jane Smith", "JS")
    slide = prs.slides[0]
    author.comments.add_comment(
        "Please verify this data before the presentation.",
        slide,
        PointF(2.0, 2.0),
        datetime.now()
    )
    prs.save("comments.pptx", SaveFormat.PPTX)

Eingebettete Bilder

Betten Sie ein Bild aus einem Dateipfad in die Präsentation ein und fügen Sie es einer Folie als PictureFrame hinzu.

import aspose.slides_foss as slides
from aspose.slides_foss.export import SaveFormat

with slides.Presentation() as prs:
    with open("logo.png", "rb") as f:
        image_data = f.read()
    image = prs.images.add_image(image_data)
    slide = prs.slides[0]
    slide.shapes.add_picture_frame(
        slides.ShapeType.RECTANGLE, 50, 50, 200, 150, image
    )
    prs.save("with-image.pptx", SaveFormat.PPTX)

Dokumenteigenschaften

Kern-, App- und benutzerdefinierte Dokumenteigenschaften lesen und schreiben.

import aspose.slides_foss as slides
from aspose.slides_foss.export import SaveFormat

with slides.Presentation() as prs:
    props = prs.document_properties

    # Core properties
    props.title = "Q1 Results"
    props.author = "Finance Team"
    props.subject = "Quarterly Review"
    props.keywords = "Q1, finance, results"

    # Custom property
    props.set_custom_property_value("ReviewedBy", "Legal Team")

    prs.save("deck.pptx", SaveFormat.PPTX)

Bekannte Einschränkungen

Die folgenden Bereiche lösen NotImplementedError aus und sind in dieser Ausgabe nicht verfügbar:

BereichStatus
DiagrammeNicht implementiert
SmartArtNicht implementiert
Animationen und ÜbergängeNicht implementiert
PDF / HTML / SVG / BildexportNicht implementiert (nur PPTX)
VBA-MakrosNicht implementiert
Digitale SignaturenNicht implementiert
Hyperlinks und Aktions‑EinstellungenNicht implementiert
OLE-ObjekteNicht implementiert
Mathematischer TextNicht implementiert

Siehe auch

 Deutsch