Cakephp DomPDF奇怪的分页符

Cakephp DomPDF奇怪的分页符,cakephp,dompdf,page-break,Cakephp,Dompdf,Page Break,我正在使用DomPDF和CakePdf生成pdf。这是一个很好的工具,但有一件事我不明白:CSS中“之前分页”的行为。通常情况下,它工作得很好:当我想要的时候,页面会断开,但有时它会变得疯狂,并在内部或之前导致许多页面断开。难以置信 这是一个使用DomPDF生成的pdf示例,请看第3页,其中有一个空白,但它不应该是空白的(在其他示例中,它运行良好,没有空白): [编辑]以及HTML版本: 现在,代码源代码(每个页面都有注释): @页面{ 边缘:.5cm; } 身体{ 填充顶部:20px;

我正在使用DomPDF和CakePdf生成pdf。这是一个很好的工具,但有一件事我不明白:CSS中“之前分页”的行为。通常情况下,它工作得很好:当我想要的时候,页面会断开,但有时它会变得疯狂,并在内部或之前导致许多页面断开。难以置信

  • 这是一个使用DomPDF生成的pdf示例,请看第3页,其中有一个空白,但它不应该是空白的(在其他示例中,它运行良好,没有空白):
  • [编辑]以及HTML版本:
现在,代码源代码(每个页面都有注释):


@页面{
边缘:.5cm;
}
身体{
填充顶部:20px;
填充底部:80px;
字体系列:“helvetica”,Arial,helvetica,无衬线;
字体大小:100%;
位置:相对位置;
}
李先生{
保证金:0;
填充:0;
}
保险商实验室{
左边距:40px;
}
p、 李{
字体大小:.875em;
线高:1.6em;
保证金:0;
}
#页眉,#页脚{
位置:固定;
/*左:0;
右:0*/
}
#标题{
排名:0;
}
#页脚{
/*顶部:1005px*/
高度:60px;
底部:0;
背景:#E28900;
}
#海德尔迪夫{
边框顶部宽度:6px;
边框顶部样式:实心;
边框顶部颜色:#E28900;
/*填充顶部:20px*/
}
img#标志{
位置:绝对位置;
顶部:26px;
左:0;
宽度:120px;
}
#页脚div{
位置:相对位置;
填充顶部:20px;
}
#页脚分区p{
颜色:#fff;
字体大小:.75em;
文本对齐:居中;
}
#页脚.pagenum{
位置:绝对位置;
颜色:#fff;
字体大小:.75em;
字体大小:粗体;
底部:25px;
右:10px;
}
#footer.pagenum:在{content:counter(page);}之前
h1#公约{
保证金:0自动;
文本对齐:居中;
字号:2.8em;
线高:1米;
填充:250px0;
颜色:#E28900;
文本转换:大写;
字体大小:正常;
字体系列:“titre”;
}
h1#约定跨度{
显示:块;
}
h1#小型会议{
显示:块;
利润率:20px0;
填充:0 100px 0 100px;
字体系列:“helvetica”;
字体大小:粗体;
文本对齐:居中;
字体大小:.4em;
线高:1.2米;
颜色:#006D93;
文本转换:无;
}
#adresse_客户{
位置:绝对位置;
左:70像素;
顶部:680px;
}
#阿雷西欧肖{
位置:绝对位置;
文本对齐:右对齐;
右:70px;
顶部:800px;
}
#adresse_客户p,#adresse_scio p{
字体大小:.9em;
}
#adresse_客户b,#adresse_scio b{
字体大小:正常;
颜色:#006D93;
字体大小:.75em;
}
#地址:a{
文字装饰:无;
颜色:#E28900;
}
.分页符{
前分页符:始终;
}
/*样式页2*/
#客户地址2{
边缘顶端:40px;
边缘底部:70像素;
右边距:70像素;
}
#adresse_客户2 p{
颜色:#006D93;
文本对齐:右对齐;
}
#莱特{
利润率:0.70px;
}
#lettre p{
线高:1.2米;
文本对齐:对齐;
}
#lettre#签名{
边缘顶部:60像素;
}
#lettre#签名p{
文本对齐:右对齐;
}
/*样式第3页*/
#领先表现{
利润率:0.70px 30 px 70 px;
}
#领先表现{
填充:10px0;
边框顶部:1px实心#ddd;
边框底部:1px实心#ddd;
}
#人头绩效h3{
显示:内联;
颜色:#000;
字体大小:.85em;
保证金:0;
填充:0;
}
#当代信息{
利润率:0.70px0;
}
h2#n形态{
字体系列:“共享”;
颜色:#006D93;
字体大小:粗体;
字号:1.6em;
线高:1米;
利润率:10px 70px;
}
/*样式第4页*/
#校长培训{
利润率:0.5px 70像素;
}
#人头置换h2{
颜色:#006D93;
字体系列:“共享”;
字号:2em;
保证金:0;
填充:0;
}
#会议人员{
边缘底部:30px;
}
#会议人员td{
边框顶部:1px实心#ddd;
边框底部:1px实心#ddd;
填充:10px0;
字体大小:.85em;
}
#小型会议人员{
颜色:#006D93;
}
#上下文约定p,#上下文约定li{
字体大小:.85em;
线高:1.4em;
}
#当代公约{
利润率:0.70px0;
}
#第h3号公约{
利润率:20px0.5px0;
填充:0;
字体系列:“helvetica”;
字体大小:.85em;
文本转换:大写;
颜色:#E28900;
}
#ContenuH4{
文本对齐:居中;
字体大小:.75em;
利润率:0 20px 10px 20px;
填充:0;
}
#公约签字{
边缘顶端:40px;
边框:1px实心#ddd;
}
#公约签字{
颜色:#006D93;
}
#公约签署{
填充:10px;
}
#公约第一{
右边框:1px实心#ddd;
}
/*样式第5页*/
#cgv{
利润率:0.70px;
}
#cgv h2{
字体系列:“helvetica”;
字体大小:.85em;
文本转换:大写;
颜色:#006D93;
}
#cgv p,#cgv li{
字体大小:.625em;
}
伊梅布勒市中心3号,巴黎塞德克斯大道75749号,邮编:15/50 000欧元,巴黎皇家骑楼751 962 119

公约信息
<style type="text/css">
    @page {
        margin: .5cm;
    }
    body {
        padding-top: 20px;
        padding-bottom: 80px;
        font-family: 'helvetica', Arial, Helvetica, sans-serif;
        font-size: 100%;
        position: relative;
    }
    ul, li {
        margin: 0;
        padding: 0;
    }
    ul {
        margin-left: 40px;
    }
    p, li {
        font-size: .875em;
        line-height: 1.6em;
        margin: 0;
    }
    #header, #footer {
        position: fixed;
        /*left: 0;
        right: 0;*/
    }
    #header {
        top: 0;
    }
    #footer {
        /*top: 1005px;*/
        height: 60px;
        bottom: 0;
        background: #E28900;
    }
    #headerDiv {
        border-top-width: 6px;
        border-top-style: solid;
        border-top-color: #E28900;
        /*padding-top: 20px;*/
    }
    img#logo {
        position: absolute;
        top: 26px;
        left: 0;
        width: 120px;
    }
    #footerDiv {
        position: relative;
        padding-top: 20px;
    }
    #footerDiv p {
        color: #fff;
        font-size: .75em;
        text-align: center;
    }
    #footer .pagenum {
        position: absolute;
        color: #fff;
        font-size: .75em;
        font-weight: bold;
        bottom: 25px;
        right: 10px;
    }
    #footer .pagenum:before { content: counter(page); }

    h1#convention {
        margin: 0 auto;
        text-align: center;
        font-size: 2.8em;
        line-height: 1em;
        padding: 250px 0 0 0;
        color: #E28900;
        text-transform: uppercase;
        font-weight: normal;
        font-family: 'titre';
    }
    h1#convention span {
        display: block;
    }
    h1#convention small {
        display: block;
        margin: 20px 0 0;
        padding: 0 100px 0 100px;

        font-family: 'helvetica';
        font-weight: bold;
        text-align: center;
        font-size: .4em;
        line-height: 1.2em;
        color: #006D93;
        text-transform: none;
    }

    #adresse_client {
        position: absolute;
        left: 70px;
        top: 680px;
    }
    #adresse_scio {
        position: absolute;
        text-align: right;
        right: 70px;
        top: 800px;
    }
    #adresse_client p, #adresse_scio p {
        font-size: .9em;
    }
    #adresse_client b, #adresse_scio b {
        font-weight: normal;
        color: #006D93;
        font-size: .75em;
    }
    #adresse_scio a {
        text-decoration: none;
        color: #E28900;
    }

    .page-break {
        page-break-before: always;
    }

    /* style page 2 */
    #adresse_client2 {
        margin-top: 40px;
        margin-bottom: 70px;
        margin-right: 70px;
    }
    #adresse_client2 p {
        color: #006D93;
        text-align: right;
    }
    #lettre {
        margin: 0 70px;
    }
    #lettre p {
        line-height: 1.2em;
        text-align: justify;
    }
    #lettre #signature {
        margin-top: 60px;
    }
    #lettre #signature p {
        text-align: right;
    }

    /* style page 3 */
    #headerFormation {
        margin: 0 70px 30px 70px;
    }
    #headerFormation td {
        padding: 10px 0;
        border-top: 1px solid #ddd;
        border-bottom: 1px solid #ddd;
    }
    #headerFormation h3 {
        display: inline;
        color: #000;
        font-size: .85em;
        margin: 0;
        padding: 0;
    }
    #contenuFormation {
        margin: 0 70px 0;
    }
    h2#nomFormation {
        font-family: 'share';
        color: #006D93;
        font-weight: bold;
        font-size: 1.6em;
        line-height: 1em;
        margin: 10px 70px;
    }

    /* style page 4 */
    #headerConvention {
        margin: 0 0 5px 70px;
    }
    #headerConvention h2 {
        color: #006D93;
        font-family: 'share';
        font-size: 2em;
        margin: 0;
        padding: 0;
    }
    #conventionPersonnes {
        margin-bottom: 30px;
    }
    #conventionPersonnes td {
        border-top: 1px solid #ddd;
        border-bottom: 1px solid #ddd;
        padding: 10px 0;
        font-size: .85em;
    }
    #conventionPersonnes small {
        color: #006D93;
    }
    #contenuConvention p, #contenuConvention li {
        font-size: .85em;
        line-height: 1.4em;
    }
    #contenuConvention {
        margin: 0 70px 0;
    }
    #contenuConvention h3 {
        margin: 20px 0 5px 0;
        padding: 0;
        font-family: 'helvetica';
        font-size: .85em;
        text-transform: uppercase;
        color: #E28900;
    }
    #contenuConvention h4 {
        text-align: center;
        font-size: .75em;
        margin: 0 20px 10px 20px;
        padding: 0;
    }
    #conventionSignatures {
        margin-top: 40px;
        border: 1px solid #ddd;
    }
    #conventionSignatures strong {
        color: #006D93;
    }
    #conventionSignatures td {
        padding: 10px;
    }
    #conventionSignatures td.first {
        border-right: 1px solid #ddd;
    }

    /* style page 5 */
    #cgv {
        margin: 0 70px;
    }
    #cgv h2 {
        font-family: 'helvetica';
        font-size: .85em;
        text-transform: uppercase;
        color: #006D93;
    }
    #cgv p, #cgv li {
        font-size: .625em;
    }
</style>

<!-- HEADER, FOOTER -->
<div id="header">
  <div id="headerDiv"></div>
</div>

<div id="footer">
    <div id="footerDiv">
        <p>Immeuble CIT 3 rue de l'Arrivée 75749 Paris Cedex 15 / SAS au capital de 50 00 0 € - RCS de Paris 751 962 119</p>
    </div>
    <div class="pagenum"></div>
</div>

<!-- PAGE 1 -->
<?php echo $this->Html->image('/home/scio/app/webroot/img/scio-conseil-et-formation.png', array('alt' => 'Scio conseil & formation', 'id' => 'logo')); ?>
<h1 id="convention">
    <span>Convention de formation</span>
    <small><?php echo $stage['Formation']['libelle']; ?></small>
</h1>

<div id="adresse_client">
    <p><b>Pour :</b></p>
    <p><strong><?php echo strtoupper($client['SocietesEtablissement']['name']); ?></strong></p>
    <p><?php echo $client['SocietesEtablissement']['adresse1']; ?></p>
    <?php
    if(!empty($client['SocietesEtablissement']['adresse2']))
        echo '<p>'. $client['SocietesEtablissement']['adresse2'] .'</p>';
    ?>
    <p><?php echo $client['SocietesEtablissement']['code_postal'] . ' ' . $client['SocietesEtablissement']['ville']; ?></p>
</div>
<div id="adresse_scio">
    <p><b>Scio, Conseil & Formation</b></p>
    <p><strong>Joël NICOLAS</strong></p>
    <p>Associé Dirigeant</p>
    <p>Tel. 01 83 94 79 05</p>
    <p><a href="mailto:joel.nicolas@scio.fr">joel.nicolas@scio.fr</a></p>
</div>


<!-- PAGE 2 -->
<div class="page-break">
    <div id="adresse_client2">
        <p><strong><?php echo strtoupper($client['SocietesEtablissement']['name']); ?></strong></p>
        <p><?php echo $client['SocietesEtablissement']['adresse1']; ?></p>
        <?php
        if(!empty($client['SocietesEtablissement']['adresse2']))
            echo '<p>'. $client['SocietesEtablissement']['adresse2'] .'</p>';
        ?>
        <p><?php echo $client['SocietesEtablissement']['code_postal'] . ' ' . $client['SocietesEtablissement']['ville']; ?></p>
    </div>
    <div id="lettre">
        <p>Paris,<br />
        <?php
        $listeJours = array(
            1 => "lundi",
            2 => "mardi",
            3 => "mercredi",
            4 => "jeudi",
            5 => "vendredi",
            6 => "samedi",
            7 => "dimanche"
        );
        $listeMois = array(
            "01"    =>  "janvier",
            "02"    =>  "février",
            "03"    =>  "mars",
            "04"    =>  "avril",
            "05"    =>  "mai",
            "06"    =>  "juin",
            "07"    =>  "juillet",
            "08"    =>  "août",
            "09"    =>  "septembre",
            "10"    =>  "octobre",
            "11"    =>  "novembre",
            "12"    =>  "décembre"
        );
        $dateHisto = strtotime($histo['CommandeHisto']['histo_date']);
        $jourDateHisto = date('d', $dateHisto);
        $journeeDateHisto = date('N', $dateHisto);
        $moisDateHisto = date('m', $dateHisto);
        $anneeDateHisto = date('Y', $dateHisto);
        ?>
        <?php echo 'Le ' . $listeJours[$journeeDateHisto] . ' ' . $jourDateHisto . ' ' . $listeMois[$moisDateHisto] . ' ' . $anneeDateHisto . '</p>'; ?>
        <br />
        <p>Objet : Convention de Formation</p>
        <br />
        <p>Madame, Monsieur,</p>
        <br />
        <p>Nous vous prions de bien vouloir trouver ci-joint notre offre concernant :</p>
        <br />
        <?php if(empty($stage['Commande']['formation_id']) && empty($stage['Commande']['event_group_id'])) { ?>
            <p><strong><?php echo $stage['Commande']['intitule']; ?></strong></p>
            <br />
            <p>Ainsi que les éléments cités en annexe ci-dessous :</p>
            <br />
            <ul>
                <li>la Convention de formation </li>
                <li>les conditions générales de vente SCIO Conseil & Formation</li>
            </ul>
            <br />
            <p>Pour accord de votre part, nous vous remercions de bien vouloir nous retourner complété, daté et paraphé l’exemplaire de la "Convention de formation".</p>
        <?php } else { ?>
            <p><strong><?php echo $stage['Formation']['libelle'] . ' - réf. ' . $stage['Formation']['reference']; ?></strong></p>
            <br />
            <p>Ainsi que les éléments cités en annexe ci-dessous :</p>
            <br />
            <ul>
                <li>le programme de formation</li>
                <li>la Convention de formation </li>
                <li>les conditions générales de vente SCIO Conseil & Formation</li>
            </ul>
            <br />
            <p>Pour accord de votre part, nous vous remercions de bien vouloir nous retourner complété, daté et paraphé l’exemplaire de la "Convention de formation".</p>
            <br />    
            <p>Si le coût de la prestation est pris en charge par un organisme collecteur, veuillez cocher le libellé prévu à cet effet et préciser ses coordonnées sur le feuillet "Convention de formation".</p>
            <br />
        <?php } ?>
        <p>Nous espérons que notre offre répondra à vos attentes, et restons à votre disposition pour toute information complémentaire,</p>
        <br />
        <p>Nous vous prions d’agréer, Madame, Monsieur, l’expression de nos salutations distinguées.</p>

        <div id="signature">
            <p>Joël NICOLAS </p>
            <p><i>Dirigeant</i></p>
        </div>
    </div>
</div>

<?php if(!empty($stage['Commande']['formation_id'])) { ?>
    <!-- PAGE 3 -->
    <div class="page-break"></div>
    <!-- Si on met un page-break à un élément qui fait plusieurs pages, il y a des sauts de pages bizarres -->
    <div>
        <h2 id="nomFormation"><?php echo $stage['Formation']['libelle'] ; ?></h2>
        <div id="headerFormation">
            <table cellpadding="0" cellspacing="0" border="0" width="100%">
                    <tr>
                      <td width="50%" align="left"><h3><small style="font-weight: normal;">Programme de formation : </small> <?php echo 'réf. ' . $stage['Formation']['reference']; ?></h3></td>
                      <td width="50%" align="right"><h3><small style="font-weight: normal;">Sous-gamme</small> <?php echo $gamme['Gamme']['libelle']; ?></h3></td>
                </tr>
            </table>
        </div>
        <div id="contenuFormation">
            <p><span style="color: #E28900;">Personnes concernées :</span> <?php echo $stage['Formation']['cible']; ?></p>
            <br />
            <p><span style="color: #E28900;">Objectifs pédagogiques :</span></p>
            <?php echo $stage['Formation']['objectifs']; ?>
            <br />
            <p><span style="color: #E28900;">Programme détaillé :</span></p>
            <div id="programme">
                    <?php echo $stage['Formation']['programme']; ?>
            </div>
        </div>
    </div>
<?php } ?>

<!-- PAGE 4 -->
<div class="page-break">
    <div id="headerConvention">
        <h2>Convention de formation</h2>
    </div>
    <div id="contenuConvention">
        <table cellpadding="0" cellspacing="0" border="0" width="100%" id="conventionPersonnes">
            <tr>
                <td width="50%" valign="top">
                    <p><small>Entre :</small></p>
                    <p><strong>SCIO Conseil & Formation</strong><br />
                    Immeuble CIT<br />
                    3 rue de l’Arrivée<br />
                    75015 PARIS<br />
                  <i>RCS de Paris : 751 962 119</i></p>
                </td>
                <td width="50%" valign="top">
                    <p><small>Et :</small></p>
                    <p><strong><?php echo strtoupper($client['SocietesEtablissement']['name']); ?></strong><br />
                    <?php echo $client['SocietesEtablissement']['adresse1']; ?><br />
                    <?php
                    if(!empty($client['SocietesEtablissement']['adresse2']))
                        echo $client['SocietesEtablissement']['adresse2'] .'<br />';
                    ?>
                    <?php echo $client['SocietesEtablissement']['code_postal'] . ' ' . $client['SocietesEtablissement']['ville']; ?><br />
                  <?php echo '<i>SIRET : ' . $client['SocietesEtablissement']['siret'] . '</i>'; ?></p>
                </td>
            </tr>
        </table>
        <?php if(empty($stage['Commande']['formation_id']) && empty($stage['Commande']['event_group_id'])) { ?>
            <?php
            echo '<h3>Objet de la prestation : '. $stage['Commande']['intitule'] .'</h3>';
            echo html_entity_decode($stage['Commande']['commentaires']);
            echo '<h3>Conditions tarifaires & facturation</h3>';
            echo '<ul>';
                echo '<li>Coût de la prestation : <strong>'. number_format($stage['Commande']['montant'],2,',',' ').' € HT *</strong></li>';
                if(isset($remise) && !empty($remise)) {
                    echo '<li>';
                        echo 'Remise : <strong>-'. number_format($remise['Invoice']['montant'],2,',',' ') .' €</strong>';
                    echo '</li>';
                }
            echo '</ul>';
            ?>
        <?php } else { ?>
            <h3>1. Objet de la prestation</h3>
            <h4><?php echo $stage['Formation']['libelle'] . ' (' . $stage['Formation']['reference'] . ')'; ?></h4>
            <p><small style="font-size: .8125em; line-height: 1.2em; color: #888;">Cette prestation s’inscrit dans les actions de formation professionnelle mentionnées à l’article L6313-1 du code du travail  Le client reconnaît avoir pris connaissance des conditions particulières relatives aux prestations de formation et déclare en accepter les termes.</small></p>

            <h3>2. Conditions d'exécution de la prestation</h3>
            <ul>
                    <li>Nombre de participants : <strong><?php echo $stage['Commande']['participants']; ?></strong></li>
                <li>Nombre de jours : 
                    <strong>
                                            <?php
                                            $duree = explode('.', $stage['Formation']['duree']);
                                            if($duree[1] == 5) {
                                                    echo number_format($stage['Formation']['duree'],'1',',',' ');
                                            } else {
                            echo $duree[0];
                                            }
                                            ?> jours
                    </strong>
                </li>
                <li>Nombre de sessions : <strong><?php echo $stage['Formation']['duree_nb']; ?></strong></li>
            </ul>

            <h3>3. Dates d'exécution</h3>
            <ul>
                    <li>
                    Date(s) de session(s) : 
                    <strong>
                        <?php
                        if(empty($stage['Commande']['event_group_id']) && $stage['Formation']['type'] == 'interentreprise') {
                            echo 'à définir';
                        } else {
                            if($dates[0]['debut'] == $dates[0]['fin']) {
                                echo 'le ' . date('d/m/Y', strtotime($dates[0]['debut']));
                            } else {
                                echo 'du ' . date('d/m/Y', strtotime($dates[0]['debut'])) . ' au ' . date('d/m/Y', strtotime($dates[0]['fin']));
                            }
                        }
                        ?>
                    </strong>
                </li>
                <li>
                    Lieu : 
                    <strong>
                        <?php
                        if(empty($stage['Commande']['event_group_id']) && $stage['Formation']['type'] == 'interentreprise') {
                            echo 'à définir';
                        } else {
                            echo $dates['EventPlace']['adresse'] . ' ' . $dates['EventPlace']['code_postal'] . ' ' . $dates['EventPlace']['ville'];
                        }
                        ?>
                    </strong>
                </li>
            </ul>

            <h3>4. Éléments pédagogiques</h3>
            <ul>
                    <li><?php echo strip_tags($stage['Formation']['moyens']); ?></li>
            </ul>

            <h3>5. Conditions tarifaires & facturation</h3>
            <ul>
                <li>Coût de la session de formation : <strong><?php echo number_format($stage['Commande']['montant'],2,',',' '); ?> € HT *</strong></li>
                <?php
                if(isset($remise) && !empty($remise)) {
                    echo '<li>';
                        echo 'Remise : <strong>'. number_format($remise['Invoice']['montant'],2,',',' ') .' €</strong>';
                    echo '</li>';
                    echo '<li>';
                        echo 'Montant après remise : <strong>'. number_format(($stage['Commande']['montant']+$remise['Invoice']['montant']),2,',',' ') .' €</strong>';
                    echo '</li>';
                }
                ?>
                <li>Facturation : <strong><?php echo $stage['Commande']['info_paiement']; ?></strong></li>
                <li>Prise en charge OPCA : <strong>................................. € HT</strong></li>
                <li>Prise en charge Client : <strong>................................. € HT</strong></li>
                <li>Autre : .....................................................................................................................................</li>
            </ul>
        <?php } ?>

        <table cellpadding="0" cellspacing="0" border="0" width="100%" id="conventionSignatures">
            <tr>
                <td width="50%" height="100" class="first" valign="top">
                    <p><strong>Pour SCIO Conseil & Formation</strong></p>
                    <p><small>À ................................. le .................................</small></p>
                    <p><small>Signature :</small></p>
                    <?php echo $this->Html->image('/home/scio/app/webroot/img/manager/signature-joel-nicolas.jpg', array('alt' => 'Joël Nicolas pour : SCIO Conseil & Formation')); ?>
                </td>
                <td width="50%" valign="top">
                    <p><strong>Pour le client</strong></p>
                    <p><small>À ................................. le .................................</small></p>
                    <p><small>Signature & cachet :</small></p>
                </td>
            </tr>
        </table>
        <br />
        <p><small style="font-size: .8125em; line-height: 1.2em; color: #888;">* Les conditions proposées dans la présente convention sont valables 3 mois à compter de la date de signature apposée par SCIO Conseil & Formation</small></p>
    </div>

</div>