我遇到了一个问题,我必须使用 pd4ml 工具生成 pdf。它适用于除第一页以外的所有页面。
我使用了以下代码行。
Page2 和 Page3 工作正常,没有任何问题。但是第一页不接受 htmlwidth="1335"(而是需要 640,这是默认值)。
注意:这适用于 Windows 中的 pd4ml.jar。使用 linux 服务器生成 pdf 时出现问题。
如有任何帮助,我们将不胜感激。
<!DOCTYPE html>
<html>
<head>
<title>TITLE</title>
<style type="text/css" media="all">
* {margin: 0;padding: 0;}
body{margin:0;padding:0;font-family:Arial,Helvetica,sans-serif;color:#333;width: 1335px;}
table{border:0; border-spacing:0;width: 100%;}
table td{vertical-align: top;-webkit-text-size-adjust: none;}
img{border: 0;page-break-inside: avoid;}
</style>
</head>
<body>
<pd4ml:page.footer>
footer text goes here
</pd4ml:page.footer>
<pd4ml:page.header>
header text goes here
</pd4ml:page.header>
<div class="container" style="margin: 0;">
<pd4ml:page.break htmlwidth="1335"/>
Page 1 content
</pd4ml:page.break>
</div>
<div class="container" style="margin: 0;">
<pd4ml:page.break htmlwidth="1335"/>
page 2 content
</pd4ml:page.break>
</div>
<div class="container" style="margin: 0;">
<pd4ml:page.break htmlwidth="1335"/>
page 3 content
</pd4ml:page.break>
</div>
</body>
</html>
</pd4ml:transform>
最佳答案
You can define htmlWidth for the entire document (including the first page) with pd4ml.setHtmlWidth() API call.
<pd4ml:page.break htmlwidth="1335"/>
impacts htmlWidth of subsequent pages only. So with a page break directive it is not possible to define htmlWidth for the first page.
(已找到答案 here.)
关于html - pd4ml 第一页采用默认宽度 (640),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33430074/