dompdf - set page margin only after first page

Adersh

I am converting an HTML to pdf file using dompdf. It is working fine. But the problem is that I need to have page margin for all the pages except the first page. The first page should have an image covering the whole page. But now the margin is coming for all pages including the first one.

I am not able to disable margin for the first page. Any help is greatly appreciated. Thanks in advance.

Below is my css

  <style type="text/css">
    body { margin: 0px; }
    @page { margin: 50px; }
    #header { 
      position: fixed; 
      left: 0px; 
      top: -52px;
      height: 50px; 
      border-bottom: 2px solid #797979;
      margin: 0; 
    }
    #footer { 
      position: fixed; 
      left: 0px; 
      bottom: -52px;
      height: 50px; 
      border-top: 2px solid #797979;
      margin: 0; 
    }
    #footer .page:after { content: counter(page); }
    .firstpage { 
      position: absolute;
      page-break-after: always; 
      top: -50px;
      width: 100%;
      margin: 0;
    }
    .otherpages{ margin: 0; }
  </style>

And here's my html

  <div class="firstpage">
     <img src="pdf-bg.jpg" style="width:100%; height:auto;/>
  </div>

  <div id="header">
    <p><?php echo date("F j, Y"); ?></p>
  </div>

  <div id="footer">
    <p class="page">Page <?php $PAGE_NUM ?></p>
  </div>    

  <div class="otherpages">
      some content
  </div>
user2077911

Try this,

    @page { margin: 50px 0; }
    .firstpage { 
      position: absolute;
      page-break-after: always; 
      top: -50px; // compensating for @page top margin
      width: 100%;
      margin: 0;
    }
    .otherpages{ margin: 0 50px; }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

dompdf HTML to PDF - can't set margin of page

From Dev

dompdf: top-margin after page break not working

From Dev

Mpdf : Set 0 margin for page 1 only

From Dev

Dompdf: how to get background image to show on first page only

From Dev

DomPDF {PAGE_NUM} not on first page

From Dev

Make an image in dompdf cover all of the first page

From Dev

Keep only the first directory/page after the address

From Dev

Keep only the first directory/page after the address

From Dev

Title on only first page

From Dev

Margin not working only in Safari (element is at the bottom of the page)

From Dev

Ajax not function on first submit, after page refresh only result will refresh

From Dev

HTML/PHP page div showing margin although margin set to 0

From Dev

HTML/PHP page div showing margin although margin set to 0

From Dev

Only first page opens up after the nav bar on one-page fixed nav website

From Dev

ABCpdf only rendering first page

From Dev

JavaScript works only on first page

From Dev

iTextSharp: Header on only First Page

From Dev

Cookie is only set on the initial page

From Dev

dompdf page_script() variables

From Dev

How to render DOMPDF within a page

From Dev

reportlab - cannot set top margin to zero in physically printed page

From Dev

Submenu exceeds margin of the page

From Dev

Ghostscript and page margin

From Dev

Remove page margin/border

From Dev

Weird margin on html page

From Dev

jQuery code works the first time and the second time works only after page refresh

From Dev

python Scrapy CrawlSpider: Rule doesn't apply after logged in, only crawled the first page

From Dev

python Scrapy CrawlSpider: Rule doesn't apply after logged in, only crawled the first page

From Dev

Logo image showing only in the first page on page header in Jasper Reports

Related Related

  1. 1

    dompdf HTML to PDF - can't set margin of page

  2. 2

    dompdf: top-margin after page break not working

  3. 3

    Mpdf : Set 0 margin for page 1 only

  4. 4

    Dompdf: how to get background image to show on first page only

  5. 5

    DomPDF {PAGE_NUM} not on first page

  6. 6

    Make an image in dompdf cover all of the first page

  7. 7

    Keep only the first directory/page after the address

  8. 8

    Keep only the first directory/page after the address

  9. 9

    Title on only first page

  10. 10

    Margin not working only in Safari (element is at the bottom of the page)

  11. 11

    Ajax not function on first submit, after page refresh only result will refresh

  12. 12

    HTML/PHP page div showing margin although margin set to 0

  13. 13

    HTML/PHP page div showing margin although margin set to 0

  14. 14

    Only first page opens up after the nav bar on one-page fixed nav website

  15. 15

    ABCpdf only rendering first page

  16. 16

    JavaScript works only on first page

  17. 17

    iTextSharp: Header on only First Page

  18. 18

    Cookie is only set on the initial page

  19. 19

    dompdf page_script() variables

  20. 20

    How to render DOMPDF within a page

  21. 21

    reportlab - cannot set top margin to zero in physically printed page

  22. 22

    Submenu exceeds margin of the page

  23. 23

    Ghostscript and page margin

  24. 24

    Remove page margin/border

  25. 25

    Weird margin on html page

  26. 26

    jQuery code works the first time and the second time works only after page refresh

  27. 27

    python Scrapy CrawlSpider: Rule doesn't apply after logged in, only crawled the first page

  28. 28

    python Scrapy CrawlSpider: Rule doesn't apply after logged in, only crawled the first page

  29. 29

    Logo image showing only in the first page on page header in Jasper Reports

HotTag

Archive