duplicate background image to other pages in the pdf generating with mpdf

930 views Asked by At

i would to create a pdf file from html with mpdf library. i would to set a background image just to 2'nd page of rendered pdf(not all pages). i use the following code:

$html = '
    <body>
    <style>
        body, div, p {
            font-family: \'Tahoma\';
            font-size: 11pt;
        }
        @page second {
            background: url("../mpdf60/bg1.jpg") 40% 0 no-repeat;
        }
        div.second {
             page: second;
        }

   </style>

        <div style="margin-bottom:50px">&nbsp;</div>
        <div align="center" style=" margin-bottom:350px"><img src="../mpdf60/pdffirst1.jpg" height="100" width="190" alt=""></div>
        <div align="center"><img src="../mpdf60/pdffirst2.jpg" alt=""/></div>
         <pagebreak />
        <div class="second">
            page2       
        </div>
        <pagebreak />
         <div>
             page3
         </div> 
    </body>
        ';

but the background image set for all pages that been after second page. i want to set background image just for second page, not ather pages. how can i do this? thanks...

1

There are 1 answers

0
Dharmesh Goswami On

Give some id to the second page div. Like "secondPageDiv". and then change in css.

    #secondPageDiv {
        background: url("../mpdf60/bg1.jpg") 40% 0 no-repeat;
    }