Început rapid

Început rapid

Acest ghid arată cea mai rapidă cale de la instalare la o salvare. .pptx fişier folosind Aspose.Slides FOSS for Python. The library is pure Python, MIT-licensed, and requires nu există Microsoft Office sau binare native.


Condiții prealabile

CerințăDetalii
Python3.10 or later
OSWindows, macOS, Linux, Docker
Paletă de serviciiaspose-slides-foss din PyPI

Instalare

Este necesar să se instaleze pachetul de la PyPI folosind pip. Versiunea 26.3.2 sau mai recentă:

pip install aspose-slides-foss>=26.3.2

Creaţi o prezentare

Construiţi un Presentation fără argumente pentru a crea o punte goală. Biblioteca se adaugă automat o diapozitivă goală. save() cu o cale și SaveFormat.PPTX pentru a scrie dosarul:

from aspose.slides_foss import Presentation
from aspose.slides_foss.export import SaveFormat

prs = Presentation()
prs.save("empty.pptx", SaveFormat.PPTX)

Adăugați o formă cu text

Acces la prima diapozitivă prin: prs.slides[0], apoi introduce un dreptunghi folosind slide.shapes.add_auto_shape().Sună-mă. add_text_frame() să atașeze o cadru de text și setarea proprietăților font prin intermediul: portion_format:

from aspose.slides_foss import Presentation, ShapeType
from aspose.slides_foss.export import SaveFormat

prs = Presentation()
slide = prs.slides[0]
shape = slide.shapes.add_auto_shape(ShapeType.RECTANGLE, 50, 50, 400, 150)
tf = shape.add_text_frame("Hello from Aspose.Slides FOSS!")
tf.paragraphs[0].portions[0].portion_format.font_height = 24
prs.save("with_shape.pptx", SaveFormat.PPTX)

Aplică o umplutură solidă

Setare fill_format.fill_type la … în FillType.SOLID, apoi furnizează o culoare ARGB folosind Color.from_argb().Culoarea este aplicată pe fundalul formei înainte de a salva:

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

prs = Presentation()
shape = prs.slides[0].shapes.add_auto_shape(
    ShapeType.RECTANGLE, 100, 100, 400, 200
)
shape.fill_format.fill_type = FillType.SOLID
shape.fill_format.solid_fill_color.color = Color.from_argb(255, 70, 130, 180)
shape.add_text_frame("Styled shape")
prs.save("styled.pptx", SaveFormat.PPTX)

Încărca un fişier existent

Treci un fişier către … Presentation constructor pentru a deschide o existentă .pptx Dosar. Citeşte numărul de diapozitive, modifică puntea după cum este necesar şi apoi sună la telefon. save() pentru a scrie rezultatul:

from aspose.slides_foss import Presentation
from aspose.slides_foss.export import SaveFormat

prs = Presentation("existing.pptx")
print(f"Slides: {len(prs.slides)}")
prs.save("copy.pptx", SaveFormat.PPTX)

Următoarele paşi

 Română