xiangma
December 22, 2025, 9:27am
1
边框问题.zip (238.1 KB)
HtmlFixedSaveOptions options = new HtmlFixedSaveOptions();
options.setUseTargetMachineFonts(false);
options.setUseHighQualityRendering(true);
options.setEncoding(Charset.forName("UTF-8"));
options.setExportEmbeddedFonts(true);
options.setShowPageBorder(true);
document.acceptAllRevisions();
document.save(targetFileName, options);
使用的25.12版本也存在问题
@xiangma
HtmlFixedSaveOptions.ShowPageBorder 用来决定在生成的 HTML Fixed 页面中是否绘制页面边框。该属性默认值为 false ,当设为 true 时,Aspose.Words 会在每页外层添加一个 <div>(或类似的容器)并绘制边框,无论源 Word 文档本身是否有边框【5】。
在您提供的代码中明确调用了 options.setShowPageBorder(true);,因此即使原始 Word 文档没有任何边框,生成的 HTML 仍会出现页面边框【1】。
解决办法
将该属性设为 false (或直接删除该调用),即可让输出的 HTML 与源文档保持一致,不再出现多余的边框【4】:
HtmlFixedSaveOptions options = new HtmlFixedSaveOptions();
options.setUseTargetMachineFonts(false);
options.setUseHighQualityRendering(true);
options.setEncoding(Charset.forName("UTF-8"));
options.setExportEmbeddedFonts(true);
// 关闭页面边框
options.setShowPageBorder(false); // 或者直接删除此行
document.acceptAllRevisions();
document.save(targetFileName, options);
这样生成的 HTML 将不再包含不必要的页面边框。若仍有异常,请确认未在其他位置(如自定义 CSS)手动添加了边框样式。
@xiangma
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies .
Issue ID(s): WORDSNET-28945
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@xiangma 我们会及时向您汇报最新进展,一旦问题解决或我们有更多信息,我们会立即通知您。
@xiangma 该问题目前正在排队等待分析。一旦问题解决或我们有更多信息,我们会及时通知您。
@xiangma 很遗憾,问题尚未解决,目前正在分析中。一旦问题解决或有更多信息,我们会立即通知您。