在 Python 中将 PNG转换为Word

用于将PNG转换为Word的高速软件Python

使用我们的文档转换 API 在 Python 中开发高级、平台独立的软件。这是一个完整的专业软件解决方案,可Python PNG, Word和许多其他文档格式。

查看代码片段

使用 Python 将 PNG 转换为 Word

需要以编程方式将 PNG 图像转换为 Word?借助Aspose.Words for Python via .NET,任何开发人员只需几行 Python 代码即可将 PNG 转换为 Word 文档格式。

现代图像处理 Python API 从具有专业品质的 PNG 图像创建 Word 文档。直接在浏览器中测试最高质量的 PNG 到 Word 转换。强大的 Python 库允许将 PNG 图像转换为几乎所有 Word 格式。

在 Python 中将 PNG 保存为 Word 文档

以下示例演示了如何在 Python 中将 PNG 转换为 Word 文档格式。

按照简单的步骤将 PNG 图像转换为 Word 文档格式。从本地驱动器读取 PNG 文件,然后只需将其保存为文档格式,并通过 Word 文档扩展名指定所需的文件格式。对于 PNG 读取和 Word 文档写入,您可以使用完全限定的文件名。

Python代码示例将PNG转换为DOCX格式
上传您要转换的文件
运行代码
从列表中选择目标格式
import aspose.words as aw

doc = aw.Document()
builder = aw.DocumentBuilder(doc)

builder.insert_image("Input.png")

doc.save("Output.docx")
import aspose.words as aw doc = aw.Document("Input.png") doc.save("Output.docx") import aspose.words as aw doc = aw.Document(Input.png) for page in range(0, doc.page_count): extractedPage = doc.extract_pages(page, 1) extractedPage.save(f"Output_{page + 1}.docx") import aspose.words as aw doc = aw.Document() builder = aw.DocumentBuilder(doc) builder.insert_image("Input.png") doc.save("Output.docx") import aspose.words as aw doc = aw.Document() builder = aw.DocumentBuilder(doc) shape = builder.insert_image("Input.png") shape.get_shape_renderer().save("Output.docx", aw.saving.ImageSaveOptions(aw.SaveFormat.docx))
运行代码
在社交媒体上分享代码:

如何将PNG转换为Word

  1. Aspose.Words for Python via .NET安装 Aspose.Words。
  2. 将库引用(导入库)添加到您的Python项目。.
  3. 在Python打开源PNG文件。.
  4. 调用save()方法,传递带有Word扩展名的输出文件名。.
  5. PNG转换的结果Word 。.

Python库将PNG转换为Word

我们在PyPi存储库中托管我们的 Python 请按照有关如何 "Aspose.Words for Python via .NET" 安装到您的开发人员环境的分步说明进行操作。

系统要求

这个包与 Python ≥3.5 和 <3.12 兼容。如果您为 Linux 开发软件,请查看产品文档中对 gcc 和 libpython 的附加要求。

其他支持的PNG转换

您可以将PNG转换为许多其他文件格式:

5%

订阅 Aspose 产品更新

获取直接发送到您的邮箱的每月通讯和优惠。

© Aspose Pty Ltd 2001-2024. 版权所有。