Free Support Forum - aspose.com

Aspose.Words for Java word转html,落款日期不显示

原文件、转换结果见附件:word落款日期不显示.zip (77.7 KB)

转换代码如下:
private void document2Html(String sourceFileName, String targetFileName) throws Exception {
Document document = new Document(sourceFileName);

document.getBuiltInDocumentProperties().setTitle("");
document.setWarningCallback(new com.aspose.words.IWarningCallback() {
	@Override
	public void warning(WarningInfo info) {
		String description = info.getDescription();
		if(info.getWarningType() == com.aspose.words.WarningType.FONT_SUBSTITUTION) {
			String key = currentFile.get();
			if(key != null) {
				int start = description.indexOf("Font");
				int end = description.indexOf(" has ");
				if(start > -1 && end > -1) {
					String font = description.substring(start+4, end).replaceAll("'", "");
					Set<String> set = missingFonts.get(key);
					if(set!=null) {
						set.add(font.trim());
					}
				}
			}
		}
	}
});


NodeCollection nodeCollection = document.getChildNodes(NodeType.COMMENT, true);
if(nodeCollection!=null){
	for (com.aspose.words.Comment comment : (Iterable<com.aspose.words.Comment>) nodeCollection){
		comment.remove();
	}
}


try {
	document.getLayoutOptions().setTextShaperFactory(com.aspose.words.shaping.harfbuzz.HarfBuzzTextShaperFactory.getInstance());
} catch (Throwable e) {
	LOG.warn("HarfBuzzTextShaperFactory fail");
}
RevisionCollection rc = document.getRevisions();
if (rc!=null && rc.getCount()>0){
	document.acceptAllRevisions();
	com.aspose.words.SectionCollection sections = document.getSections();
	if (sections!=null && sections != null) {
		for (com.aspose.words.Section section : sections) {
			if (section != null) {
				com.aspose.words.TableCollection tables = section.getBody().getTables();
				if (tables != null) {
					for (com.aspose.words.Table table : tables) {
						if (table != null) {
							table.autoFit(com.aspose.words.AutoFitBehavior.AUTO_FIT_TO_CONTENTS);
						}
					}
				}
			}
		}
	}
}

HtmlFixedSaveOptions options = new HtmlFixedSaveOptions();
options.setUseTargetMachineFonts(false);
options.setUseHighQualityRendering(true);
options.setEncoding(Charset.forName("UTF-8"));
options.setExportEmbeddedFonts(true);
options.setShowPageBorder(OfficeTransUtil.wordShowPageBorder);
document.acceptAllRevisions();
document.save(targetFileName, options);

}

@xiangma

我们已经测试了这种情况,并设法在我们身边重现了同样的问题。 为了更正,我们已在问题跟踪系统中将此问题记录为 WORDSNET-21872。 解决此问题后,将通过此论坛主题通知您。

对于给您带来的不便,我们深表歉意。