html - pd4ml 第一页采用默认宽度 (640)

标签 html css pdf-generation markup pd4ml

我遇到了一个问题,我必须使用 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/

相关文章:

需要 PHP HTML5 到 PDF 转换器

javascript - 将鼠标悬停在一个元素上显示 div,并将鼠标悬停在其上时显示第二个 div

zend-framework - 如何使用 Zend_PDF 正确对齐文本?

html - CSS 在一行图像旁边正确对齐

jquery - 嵌套的 jQuery 步骤 - Main Next 上没有任何显示

css - 具有绝对定位的 Chid Div 与父级中的内容重叠

javascript - 使用 Javascript 更改 CSS 值

php - FPDF 错误 : Could not include font metric file

javascript - 在 HTML 或其他 XML 中嵌入 XML(带有 XML 声明)

css - 如何强制我的标题在顶部?