Css 无法删除打印特定div时添加的额外空白页

Css 无法删除打印特定div时添加的额外空白页,css,jsf,printing,primefaces,Css,Jsf,Printing,Primefaces,我正在尝试使用PrimeFaces打印组件打印对话框内部的div,如下所示: 1-Page.xhtml <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xml

我正在尝试使用PrimeFaces打印组件打印对话框内部的div,如下所示:

1-Page.xhtml

 <ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui" template="/WEB-INF/templateTest.xhtml">


<ui:define name="title">Test Page</ui:define>

<ui:define name="viewname">Test Page</ui:define>



<ui:define name="content">
        <h:form id="form">

            <div>
                <div>
                    <div>

<p:commandButton value="Print" type="button" onclick="PF('printDialog').show();" />
<p:dialog resizable="true" dir="rtl" closeOnEscape="true" modal="true"  id="printDialog"  
               header="print" widgetVar="printDialog" width="1400" height="500" 
               position="center top" style="height: 600px;max-height: 600px;overflow: hidden;margin-top:100px;">


    <p:commandButton value="print"  type="button"  icon="ui-icon-print" style="display:block;margin-bottom: 20px;width:150px;">
              <p:printer target="printDiv" />
    </p:commandButton>             
    <h:panelGroup layout="block" id="printDiv"   style="direction:rtl;width:95%;margin-top:50px;">
       <h:panelGroup id="letterTitle">
            <p dir="rtl"><strong><span style="font-size:18px"><span style="font-family:times new roman,times,serif"> detail <span id="peaseUponHim" style="margin-right:100px;"> detail </span> </span></span></strong></p>

            <p dir="rtl"><strong><span style="font-size:18px"><span style="font-family:times new roman,times,serif"> detail </span></span></strong></p>

            <p dir="rtl"><span style="font-size:18px"><span style="font-family:times new roman,times,serif">detail2 </span></span></p>

            <p dir="rtl"><span style="font-size:18px"><span style="font-family:times new roman,times,serif">detail</span></span></p>

            <p dir="rtl" style="text-align:center"><span style="font-size:18px"><span style="font-family:times new roman,times,serif"><span style="font-family:times new roman,times,serif">greeting</span></span></span></p>

            <p dir="RTL" style="margin-left:0in; margin-right:0in; text-align:left"><strong><span style="font-size:18px"><span style="font-family:Calibri,sans-serif"><span style="font-family:&quot;PT Bold Heading&quot;">detail </span></span></span></strong></p>

            <p dir="RTL" style="margin-left:0in; margin-right:0in; text-align:left"><strong><span style="font-size:18px"><span style="font-family:Calibri,sans-serif"><span style="font-family:&quot;PT Bold Heading&quot;">detail</span></span></span></strong></p>


       </h:panelGroup>




       <p:panelGrid style="width:800px;margin:0 auto">

          <f:facet name="header">
            <p:row>
                <p:column style="font-weight: bold;" colspan="4">title</p:column>
            </p:row>
         </f:facet>

          <p:row>
            <p:column style="font-weight: bold;">col1</p:column>
            <p:column  colspan="3" style="font-weight: bold;"></p:column>
          </p:row>

          <p:row>
            <p:column style="font-weight: bold;width:100px;">col2</p:column>
            <p:column style="font-weight: bold;"></p:column>

            <p:column style="font-weight: bold;width:100px;">col3</p:column>
            <p:column  style="font-weight: bold;"></p:column>                               
          </p:row>

          <p:row>
            <p:column style="font-weight: bold;">col4</p:column>
            <p:column  style="font-weight: bold;"></p:column>

            <p:column style="font-weight: bold;">col5</p:column>
            <p:column  style="font-weight: bold;"></p:column>                                                                   
          </p:row>

          <p:row>
            <p:column  style="font-weight: bold;">col6</p:column>
            <p:column   style="font-weight: bold;"></p:column>

            <p:column style="font-weight: bold;">col7</p:column>
            <p:column style="font-weight: bold;"></p:column>


          </p:row>

          <p:row>
            <p:column style="font-weight: bold;">col8</p:column>
            <p:column   style="font-weight: bold;"></p:column>

            <p:column style="font-weight: bold;">col9</p:column>
            <p:column style="font-weight: bold;"></p:column>


          </p:row>

          <p:row>                                  

            <p:column style="font-weight: bold;">col10</p:column>
            <p:column style="font-weight: bold;"></p:column>

             <p:column style="font-weight: bold;">col11</p:column>
            <p:column   style="font-weight: bold;"></p:column>


          </p:row>

       </p:panelGrid>

       <p:panelGrid style="width:800px;margin:0 auto;margin-top:50px;">
          <f:facet name="header">
            <p:row>
                <p:column style="font-weight: bold;" colspan="7">table2</p:column>
            </p:row>
         </f:facet>

          <p:row>

            <p:column rowspan="2" style="font-weight: bold;">col1</p:column>
            <p:column colspan="2" style="font-weight: bold;text-align:center">col2</p:column>


            <p:column rowspan="2" style="font-weight: bold;">col3</p:column>
            <p:column rowspan="2" style="font-weight: bold;">col4</p:column>

            <p:column rowspan="2" style="font-weight: bold;">col5</p:column>
            <p:column rowspan="2" style="font-weight: bold;">col6</p:column>


          </p:row>

          <p:row>
            <p:column style="font-weight: bold;text-align:center">col1 group1</p:column>
            <p:column  style="font-weight: bold;text-align:center">col1 group2</p:column>
          </p:row>




          <p:repeat value="#{myBean.myList}" varStatus="loopVar" var="materialPrint">   
              <p:row>                                   
                    <p:column style="font-weight: bold;">#{loopVar.index+1}</p:column>
                    <p:column  style="font-weight: bold;">#{materialPrint.arabicName}</p:column>
                    <p:column style="font-weight: bold;">#{materialPrint.englishName}</p:column>
                    <p:column  style="font-weight: bold;">#{materialPrint.commercialName}</p:column>
                    <p:column style="font-weight: bold;">#{materialPrint.code}</p:column>
                    <p:column  style="font-weight: bold;">#{materialPrint.code2}</p:column>
                    <p:column style="font-weight: bold;">
                        <h:outputText value="#{materialPrint.quantity}">
                                <f:convertNumber pattern="#0.#" />
                        </h:outputText>
                       (#{materialPrint.quantityWords})
                   </p:column>                                      
              </p:row>
          </p:repeat>




       </p:panelGrid>

       <p:panelGrid style="width:800px;margin:0 auto;margin-top:50px;">
          <f:facet name="header">
            <p:row>
                <p:column style="font-weight: bold;" colspan="2">table3</p:column>
            </p:row>
         </f:facet>

          <p:row>                                   
            <p:column  style="font-weight: bold;width:250px;">col1</p:column>
            <p:column  style="font-weight: bold;"></p:column>                                                       
          </p:row>

          <p:row>                                   
            <p:column  style="font-weight: bold;">col2</p:column>
            <p:column  style="font-weight: bold;"></p:column>
          </p:row>

          <p:row>                        
            <p:column  style="font-weight: bold;">col3</p:column>
            <p:column  style="font-weight: bold;"></p:column>                                                       
          </p:row>

         <p:row>                                    
            <p:column  style="font-weight: bold;">col4</p:column>
            <p:column  style="font-weight: bold;"></p:column>                                                           
          </p:row>

       </p:panelGrid>

       <p dir="rtl"><span style="font-size:16px"><span style="font-family:times new roman,times,serif">notes here </span></span></p>
    </h:panelGroup>                         
</p:dialog>                         

</div>
</div>
</div>
</h:form>   
</ui:define>

</ui:composition>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <h:head>
        <f:facet name="first">
            <meta http-equiv="X-UA-Compatible" content="IE=edge" />
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
            <meta name="apple-mobile-web-app-capable" content="yes" />
        </f:facet>
        <title><ui:insert name="title">PrimeFaces California</ui:insert></title>
        <h:outputScript name="js/nanoscroller-rtl.js" library="california-layout" />
        <h:outputScript name="js/layout.js" library="california-layout" />
        <h:outputStylesheet name="css/layout-blue.css" library="california-layout" />
        <ui:insert name="head"/>
    </h:head>

    <h:body styleClass="main-body">

        <div class="layout-wrapper #{guestPreferences.menuLayout == 'overlay' ? 'layout-wrapper-overlay-sidebar': null}">

            <div class="layout-main">
                <div class="route-bar">
                    <div class="route-bar-breadcrumb">
                        <i class="fa fa-home"></i> <span>/ </span>
                        <ui:insert name="viewname" />
                    </div>

                </div>

                <div class="layout-main-content">
                    <ui:insert name="content"/>
                </div>


            </div>
        </div>

    </h:body>

</html>

测试页
测试页

详细信息

详细信息

详细信息2

详细信息

问候语

详细信息

详细信息

 <ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui" template="/WEB-INF/templateTest.xhtml">


<ui:define name="title">Test Page</ui:define>

<ui:define name="viewname">Test Page</ui:define>



<ui:define name="content">
        <h:form id="form">

            <div>
                <div>
                    <div>

<p:commandButton value="Print" type="button" onclick="PF('printDialog').show();" />
<p:dialog resizable="true" dir="rtl" closeOnEscape="true" modal="true"  id="printDialog"  
               header="print" widgetVar="printDialog" width="1400" height="500" 
               position="center top" style="height: 600px;max-height: 600px;overflow: hidden;margin-top:100px;">


    <p:commandButton value="print"  type="button"  icon="ui-icon-print" style="display:block;margin-bottom: 20px;width:150px;">
              <p:printer target="printDiv" />
    </p:commandButton>             
    <h:panelGroup layout="block" id="printDiv"   style="direction:rtl;width:95%;margin-top:50px;">
       <h:panelGroup id="letterTitle">
            <p dir="rtl"><strong><span style="font-size:18px"><span style="font-family:times new roman,times,serif"> detail <span id="peaseUponHim" style="margin-right:100px;"> detail </span> </span></span></strong></p>

            <p dir="rtl"><strong><span style="font-size:18px"><span style="font-family:times new roman,times,serif"> detail </span></span></strong></p>

            <p dir="rtl"><span style="font-size:18px"><span style="font-family:times new roman,times,serif">detail2 </span></span></p>

            <p dir="rtl"><span style="font-size:18px"><span style="font-family:times new roman,times,serif">detail</span></span></p>

            <p dir="rtl" style="text-align:center"><span style="font-size:18px"><span style="font-family:times new roman,times,serif"><span style="font-family:times new roman,times,serif">greeting</span></span></span></p>

            <p dir="RTL" style="margin-left:0in; margin-right:0in; text-align:left"><strong><span style="font-size:18px"><span style="font-family:Calibri,sans-serif"><span style="font-family:&quot;PT Bold Heading&quot;">detail </span></span></span></strong></p>

            <p dir="RTL" style="margin-left:0in; margin-right:0in; text-align:left"><strong><span style="font-size:18px"><span style="font-family:Calibri,sans-serif"><span style="font-family:&quot;PT Bold Heading&quot;">detail</span></span></span></strong></p>


       </h:panelGroup>




       <p:panelGrid style="width:800px;margin:0 auto">

          <f:facet name="header">
            <p:row>
                <p:column style="font-weight: bold;" colspan="4">title</p:column>
            </p:row>
         </f:facet>

          <p:row>
            <p:column style="font-weight: bold;">col1</p:column>
            <p:column  colspan="3" style="font-weight: bold;"></p:column>
          </p:row>

          <p:row>
            <p:column style="font-weight: bold;width:100px;">col2</p:column>
            <p:column style="font-weight: bold;"></p:column>

            <p:column style="font-weight: bold;width:100px;">col3</p:column>
            <p:column  style="font-weight: bold;"></p:column>                               
          </p:row>

          <p:row>
            <p:column style="font-weight: bold;">col4</p:column>
            <p:column  style="font-weight: bold;"></p:column>

            <p:column style="font-weight: bold;">col5</p:column>
            <p:column  style="font-weight: bold;"></p:column>                                                                   
          </p:row>

          <p:row>
            <p:column  style="font-weight: bold;">col6</p:column>
            <p:column   style="font-weight: bold;"></p:column>

            <p:column style="font-weight: bold;">col7</p:column>
            <p:column style="font-weight: bold;"></p:column>


          </p:row>

          <p:row>
            <p:column style="font-weight: bold;">col8</p:column>
            <p:column   style="font-weight: bold;"></p:column>

            <p:column style="font-weight: bold;">col9</p:column>
            <p:column style="font-weight: bold;"></p:column>


          </p:row>

          <p:row>                                  

            <p:column style="font-weight: bold;">col10</p:column>
            <p:column style="font-weight: bold;"></p:column>

             <p:column style="font-weight: bold;">col11</p:column>
            <p:column   style="font-weight: bold;"></p:column>


          </p:row>

       </p:panelGrid>

       <p:panelGrid style="width:800px;margin:0 auto;margin-top:50px;">
          <f:facet name="header">
            <p:row>
                <p:column style="font-weight: bold;" colspan="7">table2</p:column>
            </p:row>
         </f:facet>

          <p:row>

            <p:column rowspan="2" style="font-weight: bold;">col1</p:column>
            <p:column colspan="2" style="font-weight: bold;text-align:center">col2</p:column>


            <p:column rowspan="2" style="font-weight: bold;">col3</p:column>
            <p:column rowspan="2" style="font-weight: bold;">col4</p:column>

            <p:column rowspan="2" style="font-weight: bold;">col5</p:column>
            <p:column rowspan="2" style="font-weight: bold;">col6</p:column>


          </p:row>

          <p:row>
            <p:column style="font-weight: bold;text-align:center">col1 group1</p:column>
            <p:column  style="font-weight: bold;text-align:center">col1 group2</p:column>
          </p:row>




          <p:repeat value="#{myBean.myList}" varStatus="loopVar" var="materialPrint">   
              <p:row>                                   
                    <p:column style="font-weight: bold;">#{loopVar.index+1}</p:column>
                    <p:column  style="font-weight: bold;">#{materialPrint.arabicName}</p:column>
                    <p:column style="font-weight: bold;">#{materialPrint.englishName}</p:column>
                    <p:column  style="font-weight: bold;">#{materialPrint.commercialName}</p:column>
                    <p:column style="font-weight: bold;">#{materialPrint.code}</p:column>
                    <p:column  style="font-weight: bold;">#{materialPrint.code2}</p:column>
                    <p:column style="font-weight: bold;">
                        <h:outputText value="#{materialPrint.quantity}">
                                <f:convertNumber pattern="#0.#" />
                        </h:outputText>
                       (#{materialPrint.quantityWords})
                   </p:column>                                      
              </p:row>
          </p:repeat>




       </p:panelGrid>

       <p:panelGrid style="width:800px;margin:0 auto;margin-top:50px;">
          <f:facet name="header">
            <p:row>
                <p:column style="font-weight: bold;" colspan="2">table3</p:column>
            </p:row>
         </f:facet>

          <p:row>                                   
            <p:column  style="font-weight: bold;width:250px;">col1</p:column>
            <p:column  style="font-weight: bold;"></p:column>                                                       
          </p:row>

          <p:row>                                   
            <p:column  style="font-weight: bold;">col2</p:column>
            <p:column  style="font-weight: bold;"></p:column>
          </p:row>

          <p:row>                        
            <p:column  style="font-weight: bold;">col3</p:column>
            <p:column  style="font-weight: bold;"></p:column>                                                       
          </p:row>

         <p:row>                                    
            <p:column  style="font-weight: bold;">col4</p:column>
            <p:column  style="font-weight: bold;"></p:column>                                                           
          </p:row>

       </p:panelGrid>

       <p dir="rtl"><span style="font-size:16px"><span style="font-family:times new roman,times,serif">notes here </span></span></p>
    </h:panelGroup>                         
</p:dialog>                         

</div>
</div>
</div>
</h:form>   
</ui:define>

</ui:composition>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <h:head>
        <f:facet name="first">
            <meta http-equiv="X-UA-Compatible" content="IE=edge" />
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
            <meta name="apple-mobile-web-app-capable" content="yes" />
        </f:facet>
        <title><ui:insert name="title">PrimeFaces California</ui:insert></title>
        <h:outputScript name="js/nanoscroller-rtl.js" library="california-layout" />
        <h:outputScript name="js/layout.js" library="california-layout" />
        <h:outputStylesheet name="css/layout-blue.css" library="california-layout" />
        <ui:insert name="head"/>
    </h:head>

    <h:body styleClass="main-body">

        <div class="layout-wrapper #{guestPreferences.menuLayout == 'overlay' ? 'layout-wrapper-overlay-sidebar': null}">

            <div class="layout-main">
                <div class="route-bar">
                    <div class="route-bar-breadcrumb">
                        <i class="fa fa-home"></i> <span>/ </span>
                        <ui:insert name="viewname" />
                    </div>

                </div>

                <div class="layout-main-content">
                    <ui:insert name="content"/>
                </div>


            </div>
        </div>

    </h:body>

</html>
标题 可乐 可乐 可乐 可乐 可乐 可乐6 可乐 可乐 可乐 可乐 col11 表2 可乐 可乐 可乐 可乐 可乐 可乐6 col1组1 col1组2 #{loopVar.index+1} #{materialPrint.arabicName} #{materialPrint.englishName} #{materialPrint.commercialName} #{materialPrint.code} #{materialPrint.code2} (#{materialPrint.quantityWords}) 表3 可乐 可乐 可乐 可乐

此处有注释

2-templateTest.xhtml

 <ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui" template="/WEB-INF/templateTest.xhtml">


<ui:define name="title">Test Page</ui:define>

<ui:define name="viewname">Test Page</ui:define>



<ui:define name="content">
        <h:form id="form">

            <div>
                <div>
                    <div>

<p:commandButton value="Print" type="button" onclick="PF('printDialog').show();" />
<p:dialog resizable="true" dir="rtl" closeOnEscape="true" modal="true"  id="printDialog"  
               header="print" widgetVar="printDialog" width="1400" height="500" 
               position="center top" style="height: 600px;max-height: 600px;overflow: hidden;margin-top:100px;">


    <p:commandButton value="print"  type="button"  icon="ui-icon-print" style="display:block;margin-bottom: 20px;width:150px;">
              <p:printer target="printDiv" />
    </p:commandButton>             
    <h:panelGroup layout="block" id="printDiv"   style="direction:rtl;width:95%;margin-top:50px;">
       <h:panelGroup id="letterTitle">
            <p dir="rtl"><strong><span style="font-size:18px"><span style="font-family:times new roman,times,serif"> detail <span id="peaseUponHim" style="margin-right:100px;"> detail </span> </span></span></strong></p>

            <p dir="rtl"><strong><span style="font-size:18px"><span style="font-family:times new roman,times,serif"> detail </span></span></strong></p>

            <p dir="rtl"><span style="font-size:18px"><span style="font-family:times new roman,times,serif">detail2 </span></span></p>

            <p dir="rtl"><span style="font-size:18px"><span style="font-family:times new roman,times,serif">detail</span></span></p>

            <p dir="rtl" style="text-align:center"><span style="font-size:18px"><span style="font-family:times new roman,times,serif"><span style="font-family:times new roman,times,serif">greeting</span></span></span></p>

            <p dir="RTL" style="margin-left:0in; margin-right:0in; text-align:left"><strong><span style="font-size:18px"><span style="font-family:Calibri,sans-serif"><span style="font-family:&quot;PT Bold Heading&quot;">detail </span></span></span></strong></p>

            <p dir="RTL" style="margin-left:0in; margin-right:0in; text-align:left"><strong><span style="font-size:18px"><span style="font-family:Calibri,sans-serif"><span style="font-family:&quot;PT Bold Heading&quot;">detail</span></span></span></strong></p>


       </h:panelGroup>




       <p:panelGrid style="width:800px;margin:0 auto">

          <f:facet name="header">
            <p:row>
                <p:column style="font-weight: bold;" colspan="4">title</p:column>
            </p:row>
         </f:facet>

          <p:row>
            <p:column style="font-weight: bold;">col1</p:column>
            <p:column  colspan="3" style="font-weight: bold;"></p:column>
          </p:row>

          <p:row>
            <p:column style="font-weight: bold;width:100px;">col2</p:column>
            <p:column style="font-weight: bold;"></p:column>

            <p:column style="font-weight: bold;width:100px;">col3</p:column>
            <p:column  style="font-weight: bold;"></p:column>                               
          </p:row>

          <p:row>
            <p:column style="font-weight: bold;">col4</p:column>
            <p:column  style="font-weight: bold;"></p:column>

            <p:column style="font-weight: bold;">col5</p:column>
            <p:column  style="font-weight: bold;"></p:column>                                                                   
          </p:row>

          <p:row>
            <p:column  style="font-weight: bold;">col6</p:column>
            <p:column   style="font-weight: bold;"></p:column>

            <p:column style="font-weight: bold;">col7</p:column>
            <p:column style="font-weight: bold;"></p:column>


          </p:row>

          <p:row>
            <p:column style="font-weight: bold;">col8</p:column>
            <p:column   style="font-weight: bold;"></p:column>

            <p:column style="font-weight: bold;">col9</p:column>
            <p:column style="font-weight: bold;"></p:column>


          </p:row>

          <p:row>                                  

            <p:column style="font-weight: bold;">col10</p:column>
            <p:column style="font-weight: bold;"></p:column>

             <p:column style="font-weight: bold;">col11</p:column>
            <p:column   style="font-weight: bold;"></p:column>


          </p:row>

       </p:panelGrid>

       <p:panelGrid style="width:800px;margin:0 auto;margin-top:50px;">
          <f:facet name="header">
            <p:row>
                <p:column style="font-weight: bold;" colspan="7">table2</p:column>
            </p:row>
         </f:facet>

          <p:row>

            <p:column rowspan="2" style="font-weight: bold;">col1</p:column>
            <p:column colspan="2" style="font-weight: bold;text-align:center">col2</p:column>


            <p:column rowspan="2" style="font-weight: bold;">col3</p:column>
            <p:column rowspan="2" style="font-weight: bold;">col4</p:column>

            <p:column rowspan="2" style="font-weight: bold;">col5</p:column>
            <p:column rowspan="2" style="font-weight: bold;">col6</p:column>


          </p:row>

          <p:row>
            <p:column style="font-weight: bold;text-align:center">col1 group1</p:column>
            <p:column  style="font-weight: bold;text-align:center">col1 group2</p:column>
          </p:row>




          <p:repeat value="#{myBean.myList}" varStatus="loopVar" var="materialPrint">   
              <p:row>                                   
                    <p:column style="font-weight: bold;">#{loopVar.index+1}</p:column>
                    <p:column  style="font-weight: bold;">#{materialPrint.arabicName}</p:column>
                    <p:column style="font-weight: bold;">#{materialPrint.englishName}</p:column>
                    <p:column  style="font-weight: bold;">#{materialPrint.commercialName}</p:column>
                    <p:column style="font-weight: bold;">#{materialPrint.code}</p:column>
                    <p:column  style="font-weight: bold;">#{materialPrint.code2}</p:column>
                    <p:column style="font-weight: bold;">
                        <h:outputText value="#{materialPrint.quantity}">
                                <f:convertNumber pattern="#0.#" />
                        </h:outputText>
                       (#{materialPrint.quantityWords})
                   </p:column>                                      
              </p:row>
          </p:repeat>




       </p:panelGrid>

       <p:panelGrid style="width:800px;margin:0 auto;margin-top:50px;">
          <f:facet name="header">
            <p:row>
                <p:column style="font-weight: bold;" colspan="2">table3</p:column>
            </p:row>
         </f:facet>

          <p:row>                                   
            <p:column  style="font-weight: bold;width:250px;">col1</p:column>
            <p:column  style="font-weight: bold;"></p:column>                                                       
          </p:row>

          <p:row>                                   
            <p:column  style="font-weight: bold;">col2</p:column>
            <p:column  style="font-weight: bold;"></p:column>
          </p:row>

          <p:row>                        
            <p:column  style="font-weight: bold;">col3</p:column>
            <p:column  style="font-weight: bold;"></p:column>                                                       
          </p:row>

         <p:row>                                    
            <p:column  style="font-weight: bold;">col4</p:column>
            <p:column  style="font-weight: bold;"></p:column>                                                           
          </p:row>

       </p:panelGrid>

       <p dir="rtl"><span style="font-size:16px"><span style="font-family:times new roman,times,serif">notes here </span></span></p>
    </h:panelGroup>                         
</p:dialog>                         

</div>
</div>
</div>
</h:form>   
</ui:define>

</ui:composition>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <h:head>
        <f:facet name="first">
            <meta http-equiv="X-UA-Compatible" content="IE=edge" />
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
            <meta name="apple-mobile-web-app-capable" content="yes" />
        </f:facet>
        <title><ui:insert name="title">PrimeFaces California</ui:insert></title>
        <h:outputScript name="js/nanoscroller-rtl.js" library="california-layout" />
        <h:outputScript name="js/layout.js" library="california-layout" />
        <h:outputStylesheet name="css/layout-blue.css" library="california-layout" />
        <ui:insert name="head"/>
    </h:head>

    <h:body styleClass="main-body">

        <div class="layout-wrapper #{guestPreferences.menuLayout == 'overlay' ? 'layout-wrapper-overlay-sidebar': null}">

            <div class="layout-main">
                <div class="route-bar">
                    <div class="route-bar-breadcrumb">
                        <i class="fa fa-home"></i> <span>/ </span>
                        <ui:insert name="viewname" />
                    </div>

                </div>

                <div class="layout-main-content">
                    <ui:insert name="content"/>
                </div>


            </div>
        </div>

    </h:body>

</html>

PrimeFaces加利福尼亚
/ 
我正在使用加州主题primefaces,其css如下:

我的问题是,我在打印时会得到一个额外的空白页。我尝试了以下链接中的所有解决方案,但没有成功:

更新:我注意到,当我删除模板css文件时:layout blue.css
问题已经解决,因此存在冲突样式,但我不知道可能是哪种样式?

首先,我将要求您在
@页面中设置一些默认规则,如下所示:

@media print{
@页面{
尺寸:A4人像景观;
边缘:12毫米10毫米;
}
html,正文{
身高:99%;
}
正文{
-webkit打印颜色调整:精确;
颜色调整:精确;
溢出:可见;
}

}
您是否尝试过在p:outputPanel中包装您希望打印的内容?我在Chrome中单击了生成的html上的“打印”,并且没有额外的空白页(至少在打印预览中没有)。@YvonaBurrow:但之后您打印的是整个文档/页面,而不是像这里的panelGroup那样的“片段”。您可以制作一个(一个完整但最小的页面,如果你删除它,请删除页面中所有不“使其工作”的内容)@Kukeltje,完成,我更新了帖子,我希望当前的例子是清楚的