请问下,将word转为html时,如何保留word中的标题信息呢?我试了一下,某些word转成html时,可以保留标题信息,会通过h1 h2等标签标识出来。但是附件中的这个word文件却不可以,标题信息是通过<p>
和标签括出来的,而没有h1 h2等标签了,请问,是什么原因造成的呢?如何解决?谢谢
word.docx (325.1 KB)
非常感谢您的回复。但是我这边还是不行。我把我的代码贴出来,麻烦您再看一下,我的aspose-words的版本号为:22.3
String filePath = "C:\\Users\\info\\Desktop\\word\\word.docx";
String html = "C:\\Users\\info\\Desktop\\word\\word.html";
getLicense();
Document doc = new Document(filePath);
// 创建HTML保存选项
HtmlSaveOptions saveOptions = new HtmlSaveOptions();
saveOptions.setExportImagesAsBase64(true);
// 将Word文档保存为HTML
doc.save(html, saveOptions);
以下是我的转换结果,并没有 h1-h6的标签
@zzm628 在我这边,使用最新的 23.10 版本的 Aspose.Words 无法重现该问题。 这是我这边生成的 HTML 输出:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="Aspose.Words for Java 23.10.0" />
<title>
</title>
</head>
<body style="text-align:justify; line-height:150%; font-family:仿宋; font-size:14pt">
<div>
<p style="margin-top:0pt; margin-bottom:0pt; text-align:center; line-height:150%; font-size:26pt">
<span style="font-weight:bold">河北省介绍00</span>
</p>
<h1 style="margin-top:17pt; margin-bottom:16.5pt; page-break-inside:avoid; page-break-after:avoid; line-height:241%; font-size:22pt">
<span>历史沿革</span>
</h1>
.........................
非常感谢。我用23.10版本的Aspose.Words试了一下,确实可以,转成的html中带有h1 - h6标签。但是我们的license最高支持到22.9,22.9却不行。请问下,这个问题该如何解决?
@zzm628 每个 Aspose 许可证都提供 1 年期订阅,可免费升级到任何新发布的 Aspose.Words 版本。
您可以通过在记事本中打开许可证文件(但注意不要修改并保存许可证文件,否则它将不再起作用)并检查“SubscriptionExpiry”字段来检查许可证到期日期。
<SubscriptionExpiry>20220218</SubscriptionExpiry>
这意味着您可以免费升级到2022年2月18日之前发布的Aspose.Words版本。
22.9 是您的许可证允许更新到的最后一个版本吗?
不幸的是,我们不提供针对旧版本 Aspose.Words 的修复。 新版本的 Aspose.Words 提供了所有修复和改进。 所以我建议您更新到最新版本。
我们的license中是20220913
<SubscriptionExpiry>20220913</SubscriptionExpiry>
请问这个license可以升级吗?还是需要重新购买呢?