在尝试从webview转换为pdf时尝试在多页pdf文件中包含页眉和页脚时遇到了一些问题.以下是我如何构建要在webview中显示的内容:
public String toHtml() {
StringBuilder htmlStr = new StringBuilder("");
htmlStr.append("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html\"; charset=utf-8>");
htmlStr.append("<title>").append("").append("</title>");
htmlStr.append("</head>\n");
htmlStr.append("<body>").append("").append("</body>");
htmlStr.append("<footer>").append("").append("</footer>");
htmlStr.append("</html>");
return htmlStr.toString();
}
Run Code Online (Sandbox Code Playgroud)
我按照本指南从webview生成PDF.它确实设法生成PDF文件.但是,标题只出现在第一页,页脚只出现在PDF文件的最后一页.有关如何在PDF文件中的所有页面中包含页眉和页脚的任何想法?
谢谢!
小智 0
我有同样的问题。
我的工作解决方案: