1

我正在使用https://github.com/Xportability/css-to-pdf将 HTML 表格加载到 PDF 中。除了能够在表格之间插入分页符之外,一切正常。使用此代码:

<!doctype html>
<html lang="us">
<head>
   <meta charset="utf-8">
   <title>XEPjqPlugin</title> 
   <style>
       @media print {
           .noprint {display:none;}
           .print {width:100%; display:table-header-group;}
           body, article {width: 100%; margin: 0; padding: 0; font-size: 10pt; font-family:'Times New Roman',Times,serif;}
           table { page-break-after: always;}
       }
   </style>
   <script src="js/jquery-1.11.1.min.js"></script>
   <script src="js/xepOnline.jqPlugin.js"></script>
</head>
<body>
    <div class="report">
        <div id="tablePage">
           <input class="noprint" name="tablepage" type="checkbox">
               <a class="noprint nodec" id="printit" href="#"
                   onclick="return xepOnline.Formatter.Format('tablePage',{pageMargin:'0.5in'});"
                   ><img src="css/Images/button-print.png" />
           <div>
                <table id="table1" border="1">
                   <tr>
                        <th>Column 1</th>
                        <th>Column 2</th>
                        <th>Column 3</th>
                   </tr>
                   <tr>
                        <td rowspan="2">Row 1 Cell 1</td>
                        <td>Row 1 Cell 2</td><td>Row 1 Cell 3</td>
                   </tr>
                   <tr>
                        <td>Row 2 Cell 2</td>
                        <td>Row 2 Cell 3</td>
                   </tr>
                   <tr>
                        <td colspan="3">Row 3 Cell 1</td>
                   </tr>
               </table>
           </div>
           <div>
                <table id="table2" border="1">
                   <tr>
                        <th>Column 1</th>
                        <th>Column 2</th>
                        <th>Column 3</th>
                   </tr>
                   <tr>
                        <td rowspan="2">Row 1 Cell 1</td>
                        <td>Row 1 Cell 2</td><td>Row 1 Cell 3</td>
                   </tr>
                   <tr>
                        <td>Row 2 Cell 2</td>
                        <td>Row 2 Cell 3</td>
                   </tr>
                   <tr>
                        <td colspan="3">Row 3 Cell 1</td>
                   </tr>
               </table>
           </div>
        </div>
    </div>   
</body>
</html>

@media 打印样式没有任何效果。.noprint 和分页符无效。

4

1 回答 1

1

An update to the source has been posted. There was a bug reading the embeded @media style from the current document. I've tested this issue and it is now resolved. For future bug reports, please report in Git. Thanks. Git project located here: https://github.com/Xportability/css-to-pdf

于 2014-11-17T15:25:45.233 回答