为有中文需求的客户提供多渠道中文技术支持.

Thu Sep 12, 2024 9:42 am

world中的图片很清晰,但是通过spire.doc 转换成html格式后图片变得很模糊
我的代码如下
Code: Select all
from spire.doc import *


document = Document()
document.LoadFromFile("ceshi1.docx")


document.HtmlExportOptions.ImageEmbedded = False
document.HtmlExportOptions.ImagesPath = "Images/"


document.SaveToFile("ceshi1.html", FileFormat.Html)
document.Close()


zhangwei0001
 
Posts: 2
Joined: Thu Sep 12, 2024 9:35 am

Fri Sep 13, 2024 8:09 am

您好,

感谢您的留言。我已经复现了你的问题,但是我们需要根据客户的实际文档进行优化,所以请你向我们提供你的原始word文档进行调查。您可以在此处上传或通过电子邮件(support@e-iceblue.com)发送给我们. 提前感谢。

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 281
Joined: Mon Jul 15, 2024 5:40 am

Fri Sep 13, 2024 8:37 am

好的,我已经通过邮件反馈给你了

zhangwei0001
 
Posts: 2
Joined: Thu Sep 12, 2024 9:35 am

Fri Sep 13, 2024 10:40 am

你好,

感谢你的反馈。我们的产品转换word 到Html 是依据微软标准的,你的原文档直接在微软word中转换到html,打开时第一张图片也是很模糊的。但是通过我们产品转之前,你可以先针对图片高宽进行修改设置,然后再转html,例如下面示例代码设置。
Code: Select all
document = Document()
document.LoadFromFile("../ceshi3.docx")
# Get the first secion
section = document.Sections[0]
# Get the first paragraph
paragraph = section.Paragraphs[0]

# Reset the image size of the first paragraph
for i in range(paragraph.ChildObjects.Count):
    docObj = paragraph.ChildObjects.get_Item(i)
    if isinstance(docObj, DocPicture):
        picture = DocPicture(docObj)
        picture.Width = 500
        picture.Height = 500

document.HtmlExportOptions.ImageEmbedded = False
document.HtmlExportOptions.ImagesPath = "Images/"

document.SaveToFile("result_html.html", FileFormat.Html)
document.Close()

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 281
Joined: Mon Jul 15, 2024 5:40 am

Return to 中文技术支持