function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sravana SudheerSravana Sudheer 

Blank last page and blank space in first page between header and text( Converting Vf page as Word doc)

Hi All,

When i am trying to convert Vf page as word document i am getting blank space on the first page between header and start text as well as receving blanlk last page as attached. Any help would be greatly This blank space is coming right after header in first page before document is getting startedThis is blank last page
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<style>


            @page Section1{
                 size:9.0in 11in;
                 mso-page-orientation:landscape;
                 margin:0.5in 0.5in 0.5in 0.5in;
                 mso-header-margin:0.52in;
                 mso-footer-margin:0.5in;
                 mso-header: h1;
                 mso-footer: f1;
                 mso-paper-source:0;
            }
            div.Section1{
             page:Section1;
            }
            table#hrdftrtbl{
                margin:0in 0in 0in 15in;

            }
            p.MyFoot, li.MyFoot, div.MyFoot
            {
                mso-pagination:widow-orphan;
                tab-stops:center 100.0pt right 250.0pt;
                margin:0in;
                margin-top:.0001pt;
                margin-bottom:.0001pt;

            }
            p.MsoHeader,li.MsoHeader,div.MsoHeader
            {
             margin:-8in;
             margin-top:0.1pt;
             mso-pagination:widow-orphan;
             tab-stops:center 3.0in right 6.0in;
            }

            body 
            {
                font-family:DINPro-Light, Verdana, Arial;
                font-size: 11px;        
            }
            th, td 
            {
                padding: 2px;
                border: 1px solid Black;
                width: 40%;

            }
            th.sechead
            {
                text-align: center;
                col-span:1;
                white-space: nowrap;
            }
            table.fixed {border: 1px solid Black; table-layout:fixed;width: 100%;}



            div.breakPageAfter
            {
              page-break-after:always !important;
              page-break-inside:avoid !important;
              overflow:hidden !important;
            }

        </style>
</head>

<apex:repeat value="{!oplist}" var="op"> 
     <div class="breakPageAfter">
            <h1 style="color:Red;font-size: 140%;">
                       {!op.Account.name}({!op.name}) 
            </h1>

                <div class="column" overflow="hidden" >
                    <div class="Row">
                        <table class="fixed" border="none" >
                             <!--<tr>
                                  <th> Account Name</th>
                                  <td>{!op.Account.name}({!op.name})</td>
                             </tr>-->
                             <tr> 
                                  <th> Submitted By: </th>
                                  <td>{!op.owner.name}</td>
                             </tr>
                             <tr> 
                                  <th> Owner Title </th>
                                  <td>{!op.owner.title}</td>
                             </tr>
                             <tr>
                                  <th> Region</th>
                                  <td>{!op.Primary_Region__r.name}
                                  </td>
                             </tr>
                             <tr> 
                                  <th> Report Date </th>
                                  <td><apex:outputText value="{0,date,MM/dd/yyyy}"> <apex:param value="{!TODAY()}" /> </apex:outputText>
                                  </td>
                             </tr>
                         </table>
                    </div>&nbsp;

                    <div class="Row">
                     <table class="fixed" border="none">
                            <tr Style ="background: #df7d26;">
                                <th class="sechead" colspan="1" Style ="color:rgb(255, 255, 255);">Document Objective</th>
                             </tr>
                             <td><p><b>The purpose of this plan is to document information about the account 
                                in a single document and to identify opportunities for a long-term relationship 
                                with the client that will bring in continuous sales opportunities.</b></p>
                             </td>
                     </table>
                    </div><br/><br/><br clear="all" style="page-break-inside:avoid;" />
                    <div class="Row">
                      <table class="fixed" border="1">
                        <tr Style ="background: #df7d26;">
                                <th class="sechead" colspan="2" Style ="color:rgb(255, 255, 255);">Account Background</th>
                        </tr>
                        <tr>
                           <th> Annual Spend</th>
                           <td><apex:outputText value="{0,Number,Currency}"> <apex:param value="{!op.Est_Client_Spend__c}" /></apex:outputText>
                           </td>
                        </tr>
                        <tr>
                           <th> Revenue </th>
                           <td><apex:outputText value="{0,Number,Currency}"> <apex:param value="{!op.Amount}" /></apex:outputText>
                           </td>
                        </tr>
                        <tr>
                           <th> Fee </th>
                           <td><apex:outputText value="{0,number,0}%"> <apex:param value="{!op.Est_MSP_fee__c}" /></apex:outputText>
                           </td>
                        </tr>
                        <tr>
                            <th> Partner Providers </th>
                           <!--<td><apex:outputText value="{0,number,0}%"> <apex:param value="{!op.Est_MSP_fee__c}" /></apex:outputText>
                           </td>-->
                        </tr>
                      </table>          
                    </div><br/>
                    <div class="Row">
                        <table class="fixed" border="1">
                            <tr Style ="background: #df7d26;">
                                <th class="sechead" colspan="1" Style ="color:rgb(255, 255, 255);">Client Company Overview</th>
                             </tr>
                             <td><p><b>{!op.Account.Description}</b></p>
                             </td>
                        </table>
                    </div><br/><br/>
                </div>
                <div class="column" overflow="hidden">
                    <div class="row">
                        <table class="fixed" border="1" cellspacing="0" cellpadding="0" 
                           style='border-collapse:collapse;border:none;mso-border-alt:solid windowtext .5pt;'>
                            <tr Style ="background: #df7d26;">
                                <th class="sechead" colspan="2" Style ="color:rgb(255, 255, 255);">Opportunity Details</th>
                            </tr>
                            <tr>
                                  <th>Client Relationship Background</th>
                                  <td>{!op.Brief_Description_of_the_Opportunity__c}</td>
                            </tr>
                            <tr>
                                  <th>Client Business Objectives and Initiatives</th>
                                  <td>{!op.Client_Expected_Outcomes__c} </td>
                             </tr>     

                            <tr>
                                  <th>Problem Statement</th>
                                  <td>{!op.Customer_Pain_Points__c}</td>
                            </tr>
                            <tr>
                                  <th>Actions Taken</th>
                                  <td></td>
                            </tr>
                            <tr>
                                  <th>Next Steps</th>
                                  <td>{!op.NextStep}</td>
                            </tr>
                            <tr>
                                  <th>Type</th>
                                  <td>{!op.Type}</td>
                            </tr>
                            <tr>
                                  <th>Time Frame</th>
                                  <td><apex:outputText value="{0,date,MM/dd/yyyy}"> <apex:param value="{!op.createddate}"/> 
                                        </apex:outputText>&nbsp;-&nbsp;<apex:outputText value="{0,date,MM/dd/yyyy}"><apex:param value="{!op.Expected_Go_Live_Date__c }"/></apex:outputText>
                                   </td>
                            </tr>
                            <tr>
                                   <th> Revenue </th>
                                   <td><apex:outputText value="{0,Number,Currency}"> <apex:param value="{!op.ExpectedRevenue}" /></apex:outputText>
                                   </td>
                            </tr>
                            <tr>
                                   <th> Gross Profit($) </th>
                                   <td><apex:outputText value="{0,Number,Currency}"> <apex:param value="{!op.Gross_Profit__c}" /></apex:outputText>
                                   </td>
                            </tr>
                            <tr>
                                   <th> Probability </th>
                                   <td><apex:outputText value="{0,Number,0}%"> <apex:param value="{!op.Probability}" /></apex:outputText>
                                  </td>
                           </tr>
                            </table>
                    </div>
                </div><br/><br/>
                <div class="column" overflow="hidden">
                    <div class="row">
                        <table class="fixed" border="1">
                            <tr Style ="background: #df7d26;">
                                <th class="sechead"   colspan="4" Style ="color:rgb(255, 255, 255);">Client Contact List/Org Chart</th>
                            </tr>

                           <tr>
                                  <th>Name</th>
                                  <th>Title</th>
                                  <th>Phone</th>
                                  <th>Email</th>

                            </tr>
                            <apex:repeat value="{!op.OpportunityContactRoles}" var="ct">
                            <tr>
                                  <td>{!ct.contact.name}</td>
                                  <td>{!ct.contact.Title}</td>
                                  <td>{!ct.contact.Phone}</td>
                                  <td>{!ct.contact.Email}</td>
                            </tr>

                           </apex:repeat>
                          </table>
                        </div>
                </div><br/><br/>

                <div class="column" overflow="hidden">
                    <div class="row">
                        <table class="fixed" border="1">
                            <tr Style ="background: #df7d26;">
                                <th class="sechead"   colspan="4" Style ="color:rgb(255, 255, 255);">Internal Account Team</th>
                            </tr>

                           <tr>
                                  <th>Name</th>
                                  <th>Title</th>
                                  <th>Level Of Relationship</th>
                                  <th>Company</th>

                            </tr>
                            <apex:repeat value="{!op.OpportunityTeamMembers}" var="optm">
                            <tr>
                                  <td>{!optm.user.name}</td>
                                  <td>{!optm.user.Title}</td>
                                  <td>{!optm.TeamMemberRole}</td>
                                  <td>{!optm.user.Email}</td>
                            </tr>

                           </apex:repeat>
                          </table>
                        </div>
                </div><br/><br/>

                <div class="column" overflow="hidden">
                    <div class="row">
                        <table class="fixed" border="1">
                            <tr Style ="background: #df7d26;">
                                <th class="sechead"   colspan="4" Style ="color:rgb(255, 255, 255);">OpCo Relationships</th>
                            </tr>

                           <tr>
                                  <th>Name</th>
                                  <th>Title</th>
                                  <th>Phone</th>
                                  <th>Email</th>

                            </tr>
                            <apex:repeat value="{!op.OpportunityContactRoles}" var="opct">
                            <tr>
                                  <td>{!opct.contact.name}</td>
                                  <td>{!opct.contact.Title}</td>
                                  <td>{!opct.contact.Phone}</td>
                                  <td>{!opct.contact.Email}</td>
                            </tr>

                           </apex:repeat>
                          </table>
                        </div>
                    </div><br/><br/>          

                    <div class="column" overflow="hidden" >
                        <div class="row">
                          <table class="fixed" border="1">
                             <tr Style ="background: #df7d26;">
                                <th class="sechead"   colspan="1" Style ="color:rgb(255, 255, 255);">Risk Points</th>
                             </tr>
                             <td>{!op.Strategic_Risk__c}</td>
                          </table>
                        </div>
                    </div><br/><br/>

                    <div class="column" overflow="hidden">
                        <div class="row">
                          <table class="fixed" border="1">
                             <tr Style ="background: #df7d26;">
                                <th class="sechead"   colspan="1" Style ="color:rgb(255, 255, 255);">Action Plan (Next Steps)</th>
                             </tr>
                             <td>{!op.NextStep}</td>
                          </table>

                        </div>
                    </div>
                    <br clear="all" style='mso-special-character:line-break;page-break-before:always'/>
     </div>            

</apex:repeat>

.
NagendraNagendra (Salesforce Developers) 
Hi Sudheer,

The suggestion from How to deal with page breaks seems applicable: Note: when using the page-break-after:always for the tag, it will create a page break after the last bit of the table, creating an entirely blank page at the end every time! To fix this just change it to page-break-after:auto. It will break correctly and not create an extra blank page.

So, try changing your footer style from page-break-after:always; to page-break-after:auto;

Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra
 
Sravana SudheerSravana Sudheer
Hi Nagendra,

Thank you for your response .Even though if i comment that div (74 line) i am getting this. I think line 314 is what is causing page breaks in my Page. If i change that to auto i am not getting page breaks after each record. The second record is following the first record withough having and page breaks between them.
Thanks,
Sravan