我目前正在使用 asp.NET 将 .doc 文件生成为 html。
我想在页面中插入一个分页符,但不知道如何。
我试过使用 css style='page-break-before:always' 但它什么都不做。
这是分配给按钮点击事件的代码:
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Charset ="";
HttpContext.Current.Response.ContentType ="application/msword";
string strFileName = "GenerateDocument"+ ".doc";
HttpContext.Current.Response.AddHeader("Content-Disposition","inline;filename=" + strFileName);
StringBuilder strHTMLContent = new StringBuilder();
strHTMLContent.Append("<p align='Center'>Content Before Page Break</p>".ToString());
strHTMLContent.Append("<br><br>".ToString());
strHTMLContent.Append("<p class='pageBreak' style='mso-special-character:line-break;'>meh</p>".ToString());
strHTMLContent.Append("<br><br>".ToString());
strHTMLContent.Append("<p align='Center'>Content After Page Break</p>".ToString());
HttpContext.Current.Response.Write(strHTMLContent);
HttpContext.Current.Response.End();
HttpContext.Current.Response.Flush();
最佳答案
Word 有自己的特殊类。 mso-特殊字符:分页符;正如 Pekka 所提到的,在这种情况下确实有效,但是缺少的是这应该在
标签上。所以下面的代码将起作用:
<br clear=all style='mso-special-character:line-break;page-break-before:always'>
这不是特别好的解决方案,但就我而言,我别无选择(我没有编写原始代码,更改它的工作量更大)。
关于html - 在生成的 HTML .doc 中插入分页符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4896863/