Alter the default header/footer when printing to PDF

后端 未结 7 1649
攒了一身酷
攒了一身酷 2020-12-14 02:21

I\'m trying to use Google Chrome as a replacement of PhantomJS to render HTML into PDF. So far it\'s been working well for me. The only issue I have that I have not found an

7条回答
  •  太阳男子
    2020-12-14 02:55

    There are two solutions to your problem

    A) Push the chrome-header out by leaving no margin :

     @page { 
         margin: 0;
         size: auto;
     }
    

    or

     @media print {
       @page { margin: 0; }
       body { margin: 1.6cm; }
     }
    

    B) Originally a Firefox solution which should world for Chrome

     
    

    some sample:

    
    
    
    Print PDF without header
    
    
    
    

    Some Text in Paragraph to print!

    Print

提交回复
热议问题