简体   繁体   English

python - 如何将形状复制到python-pptx中的其他幻灯片中?

[英]How to copy a shape into other slide in python-pptx?

I have a Power-Point presentation with 2 slides (first with some shapes like circle and rectangle and the second is empty).我有一个带有 2 张幻灯片的 PowerPoint 演示文稿(第一个是圆形和矩形等一些形状,第二个是空的)。

How can I copy a shape from the first slide into the second slide using python-pptx?如何使用 python-pptx 将第一张幻灯片中的形状复制到第二张幻灯片中?

If you use Aspose.Slides for Python via .NET , you will easily copy shapes from a slide to another.如果您通过.NET 为 Python 使用 Aspose.Slides ,您可以轻松地将形状从一张幻灯片复制到另一张。 The following code example shows how to copy the first shape from the first slide to the second slide:以下代码示例显示如何将第一个形状从第一张幻灯片复制到第二张幻灯片:

import aspose.slides as slides

with slides.Presentation(fileName) as presentation:
    firstShape = presentation.slides[0].shapes[0]
    presentation.slides[1].shapes.add_clone(firstShape)

You can also evaluate Aspose.Slides Cloud for presentation manipulating.您还可以评估Aspose.Slides Cloud以进行演示操作。 This REST-based API allows you to make 150 free API calls per month for API learning and presentation processing.这个基于 REST 的 API 允许您每月为 API 学习和演示处理进行 150 次免费的 API 调用。 The following code example demonstrates how to do the same with Aspose.Slides Cloud:以下代码示例演示了如何对 Aspose.Slides Cloud 执行相同操作:

import asposeslidescloud

from asposeslidescloud.configuration import Configuration
from asposeslidescloud.apis.slides_api import SlidesApi

configuration = Configuration()
configuration.app_sid = 'myClientId'
configuration.app_key = 'myClientKey'

slidesApi = SlidesApi(configuration)

shape = slidesApi.get_shape(fileName, 1, 1)
slidesApi.create_shape(fileName, 2, shape)

I work at Aspose.我在 Aspose 工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM