我从幻灯片中提取数据,所以对于有文本框的表格、图表和法线形状,我可以得到文本并替换它。
但是当涉及到SmartArt时,我无法获取文本enter code here
for shape in slide.shapes:
print(shape.element.xml)是否有任何元素或形状的属性,我们可以从SmartArt中提取数据?
发布于 2022-04-26 11:20:11
Aspose.Slides for Python使从SmartArt对象的节点中提取文本变得非常容易。下面的代码示例向您展示了如何做到这一点:
import aspose.slides as slides
import aspose.slides.smartart as smartart
# Load a presentation.
with slides.Presentation("example.pptx") as presentation:
# Get the first shape from the first slide, for example.
shape = presentation.slides[0].shapes[0]
if type(shape) is smartart.SmartArt:
# Extract text from all nodes.
for node in shape.all_nodes:
for node_shape in node.shapes:
if node_shape.text_frame is not None:
print(node_shape.text_frame.text)这是一个付费产品,但您可以获得评估库所有功能的临时许可证。
或者,您可以使用用于Python的Aspose.Slides Cloud来提供基于REST的API来管理演示文稿.它也是一个付费产品,但是你可以每月进行150个免费的API调用,用于实验、学习和任何其他目的。下面的代码示例使用SmartArt云从Aspose.Slides节点提取所有文本:
import asposeslidescloud
from asposeslidescloud.apis.slides_api import SlidesApi
slides_api = SlidesApi(None, "my_client_id", "my_client_secret")
# Get the first shape from the first slide, for example.
shape = slides_api.get_shape("example.pptx", 1, 1)
if shape.type == "SmartArt":
# Extract text from all nodes.
for node in shape.nodes:
print(node.text)我是Aspose的一个支持开发人员。
https://stackoverflow.com/questions/60245696
复制相似问题