简体   繁体   English

防止在打印网页的 pdf 时打印白色空页

[英]Prevent to print white empty sheets while printing pdf of a webpage

I used @media query to override css properties of my webpage and create a good-for-me print layout.我使用@media 查询来覆盖我网页的 css 属性并创建一个对我有用的打印布局。

But I have a problem: even if what I want to print "stays" entirely inside a single A4 sheet, if I click "print" (no matter if print pdf or normal paper print) it's printed also a white and empty additional sheet.但我有一个问题:即使我想打印的内容“完全保留”在一张 A4 纸内,如果我点击“打印”(无论是打印 pdf 还是普通纸打印),它也会打印一张白色和空的附加纸。

How to prevent this?如何防止这种情况?

My code:我的代码:

@media print {
           
      .noPrint{
        display: none;
      }

      section{         
        display:block;   
        background-color: white;
        height: 100%;
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        margin:0;
        padding: 1em;  

        /*settings */    
        color-adjust: exact !important;  
        -webkit-print-color-adjust: exact !important;
      }

      a{
        display:none;
      }
      button{
        display:none;
      }
      h1{
        font-size: 3vw;
      }
 }

You could use :你可以使用:

page-break-after: auto;

or :或者 :

@media print {
    html, body {
        height: 99%;    
    }
}

as mentioned in how to avoid extra blank page at end while printing?如在打印时如何避免在末尾出现额外的空白页中所述?

But since I haven't worked with print all that much I can't help anymore than this.但是因为我没有那么多的打印工作,所以我无能为力了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM