在 Python 中将 图片转换为Word

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

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

查看代码片段

使用 Python 将图像转换为 图片

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

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

将图像保存为 Python 中的 图片 文档

以下示例演示如何在 Python 中将图像转换为 图片 文档格式。

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

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))
运行代码
在社交媒体上分享代码:

如何将图片转换为Word

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

Python库将图片转换为Word

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

系统要求

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

5%

订阅 Aspose 产品更新

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

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