首页 > 解决方案 > 使用速度从 html 到 pdf 的分页后更改为横向

问题描述

为了将数据提取到一个 pdf 文档中,我正在使用openhtmltopdf,velocity和一个css样式表。到目前为止它工作正常,但在某些时候我想将页面方向更改为横向,因为我想显示一个包含几列的表格。我尝试<div class="landscape">使用以下属性创建一个,transform: rotate(270deg);translate(-296mm, 0);但它不起作用。该表克服了忽略页面格式的几个页面。你能帮忙指出我的错误吗?提前致谢。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8"/>
        <style>#include("style.css") </style>
        <style>
            @page {
                size: A4;
            }
            @page {
                margin-left: 10mm;
                margin-right: 10mm;
                margin-top: 10mm;
                margin-bottom: 10mm;
            }
        </style>
    </head>
    <body class="fontmmMedium">
        <div style="padding-top: 5mm"></div> 

            [...]
            
            ## Tableau des Données **
            <div class="landscape" style="page-break-before:always;transform: rotate(270deg);translate(-296mm, 0);transform-origin: 0 0;">
                <table class="borderGrooveGrey print-page_new" style="width: 100%; padding: 5px; margin-top: 5mm;">
                    <thead>
                        <tr>
                            <th class="borderGrooveGrey" colspan="3" >Données</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr></tr>
                        #foreach ($donnee in $traitementBean.donnees)
                        <tr>
                            <td>
                                $donnne.typeDeDonnees.libelle
                            </td>
                            <td>
                                $donnne.nom 
                            </td>
                            <td>
                                $donnne.description 
                            </td>
                        </tr>
                        #end
                    </body>
                </table>
            </div>
        </div>
        #end
        #end        
    </body>
</html>

标签: csspdfvelocitylandscapeopenhtmltopdf

解决方案


推荐阅读