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
arunadeveloperarunadeveloper 

Problem with visual force PDF page numbers or page page break

Hi there,

 

when i click a button it will generate the PDF, it is generating pdf,but the problem is I am getting one extra empty page.

content is only 2 page but I am getting one extra  empty page , how to avoid that extra empty page .

 

any an ideas  ?

 

 

Thank you,

firechimpfirechimp

Hi Arunadeveloper,

This depends on how you have constructed your page for this.

The most common reason is you have padding or margin on the final div in the page so the PDF throws in an extra page to fit all the content. Sometimes in can be a random <br/> at the end of your content there are loads of possible reasons.

 

I hope this helps, if not it may be worth posting your page code and any styles you use in it so I can take a better look.

 

arunadeveloperarunadeveloper

ok, here is my code it is component

 

<apex:component controller=some controllert" id="enrollmetnEventLocationData">

<apex:repeat value="{!enrolmentEventLocationList}" var="enrollmentLocationData" >
<div style="page-break-after:always;">

<table style="table-layout: fixed; width:45%" border="0" >

<col width="90" align="left"/>
<col width="850" align="left"/>

<tr valign="baseline">
<td style="color:#27408B" align="left"><b><apex:outputLabel value="Enrollment Event Location:"/></b></td>
<td align="left"><apex:outputLabel value="{!enrollmentLocationData.ENROL_EVENT_LOC_TXT__c}" id="enrollmentLcationNameId"/></td>
</tr>
</table>

<hr/>
<table width="150%" border="0" style="table-layout: fixed;">
<col width="100" align="left"/><!-- Location status -->
<col width="120" align="left"/><!-- Location status value -->
<col width="70" align="left"/><!-- Eligible lives -->
<col width="120" align="left"/><!-- Eligible lives value -->
<col width="100" align="left" /><!-- ContactRoleName -->
<col width="120" align="left" style="word-wrap: break-word"/><!-- ContactRoleName Value -->
<col width="100" align="left" /><!-- ContactRole Phone -->
<col width="120" align="left" style="word-wrap: break-word"/><!-- ContactRole Phone value -->
<col width="100" align="left" /><!-- Address1 -->
<col width="120" align="left" style="word-wrap: break-word" valign="bottom"/><!-- Address1 value -->
<col width="100" align="left"/><!--city -->
<col width="120" align="left" style="word-wrap: break-word"/><!-- city value -->
<col width="100" align="left" /><!-- Address 2 -->
<col width="120" align="left" style="word-wrap: break-word" valign="bottom"/><!-- Address 2 value -->
<col width="100" align="left"/><!-- state -->
<col width="100%" align="left" style="word-wrap: break-word"/><!-- state value -->
<col width="100" align="left"/><!-- postal code -->
<col width="120" align="left" style="word-wrap: break-word"/><!-- postal code value -->

<tr align="left">
<td align="left"><apex:outputLabel value="Location Status:" style="font-weight:bold" /> <apex:outputLabel /></td>
<td style="word-wrap: break-word" align="left"><apex:outputLabel value="{!enrollmentLocationData.LOC_STAT_NM__c}" id="locationStatusId"/></td>
</tr>
<tr align="left">
<td align="left"><apex:outputLabel value="Eligible Lives:" style="font-weight:bold" /> <apex:outputLabel /></td>
<!-- <td style="word-wrap: break-word"><apex:outputLabel value="{!enrollmentLocationData.LOC_ELIG_LVS_QTY__c}" id="EligibleLivesId"/> </td>-->
<td style="word-wrap: break-word">
<apex:outputText value="{0, number, ###,##0}" id="EligibleLivesId">
<apex:param value="{!enrollmentLocationData.LOC_ELIG_LVS_QTY__c}"/>
</apex:outputText>

</td>
</tr>

<apex:repeat value="{!enrollmentLocationData.Contact_Roles__r}" var="enrollmentLocationContactData" id="theRepeat">
<tr align="left">
<td align="left"><apex:outputLabel value="Contact Name: " style="font-weight:bold" /> </td>
<td style="word-wrap: break-word" align="left"><apex:outputLabel value="{!enrollmentLocationContactData.CNTCT_ID__r.Name}" id="contactNameId"/></td>

<td align="left"><apex:outputLabel value="Phone: " style="font-weight:bold" /> <apex:outputLabel /></td>
<td style="word-wrap: break-word" align="left"><apex:outputLabel value="{!enrollmentLocationContactData.CNTCT_PHONE_TXT__c}" id="PhoneId"/></td>
</tr>
</apex:repeat>

<tr valign="left">
<td align="left" ><apex:outputLabel value="Physical Address 1: " style="font-weight:bold" /> <apex:outputLabel /></td>
<td style="word-wrap: break-word" align="left" nowrap="wrap" valign="bottom" ><apex:outputLabel value="{!enrollmentLocationData.PHSCL_FIRST_ADDR_LINE_ADR__c} " /></td>
<td align="left"><apex:outputLabel value="Physical City: " style="font-weight:bold" /> <apex:outputLabel /></td>
<td style="word-wrap: break-word" align="left"><apex:outputLabel value="{!enrollmentLocationData.PHSCL_CITY_NM__c} " /></td>
</tr>

<tr valign="left">
<td align="left"><apex:outputLabel value="Physical Address 2: " style="font-weight:bold" /> <apex:outputLabel /></td>
<td style="word-wrap: break-word;vertical-align:bottom" align="left" ><apex:outputLabel value="{!enrollmentLocationData.PHSCL_SECND_ADDR_LINE_ADR__c}" /></td>
<td align="left"><apex:outputLabel value="Physical State:" style="font-weight:bold" /></td>
<td style="word-wrap: break-word" align="left"><apex:outputLabel value="{!enrollmentLocationData.PHSCL_STATE_CD__c}" /></td>
<td align="left"><apex:outputLabel value="Physical Postal Code:" style="font-weight:bold" /> </td>
<td style="word-wrap: break-word" align="left"><apex:outputLabel value="{!enrollmentLocationData.PHSCL_POSTL_CD__c}"/></td>
</tr>
</table>

<apex:repeat value="{!enrollmentLocationData.Location_Activities__r}" var="enrollLocationActivityData" id="locationActivityDataRepeat">
<dl>
<dt><dd><table style="table-layout: fixed; width:45%" border="0" >
<col width="30" align="left"/>
<col width="900" align="left"/>
<tr valign="baseline">
<td style="color:#27408B" align="left"><apex:outputLabel value="Support Type:" style="font-weight:bold" /> <apex:outputLabel /> </td>
<td style="word-wrap: break-word" align="left"><apex:outputLabel value="{!enrollLocationActivityData.SUPRT_TYPE_NM__c}" id="locationStatusId"/></td>
</tr>

</table>

<hr/>
<table width="120%" border="0" style="table-layout: fixed;vertical-align:bottom">
<col width="60" align="left" style="word-wrap: break-word"/><!-- Date -->
<col width="150" align="left" style="word-wrap: break-word"/><!-- Date value -->
<col width="60" align="left" style="word-wrap: break-word"/><!-- start time -->
<col width="160" align="left" style="word-wrap: break-word"/><!-- start timevalue -->
<col width="70" align="left" style="word-wrap: break-word"/><!--end time -->
<col width="50" align="left" style="word-wrap: break-word"/><!--end time value-->
<col width="80" align="left" style="word-wrap: break-word" /><!-- time zone-->
<col width="50" align="left" style="word-wrap: break-word" /><!-- time zone avlue-->
<col width="80" align="left" style="word-wrap: break-word"/><!-- english bc-->
<col width="180" align="left" style="word-wrap: break-word"/><!-- english bc value-->
<col width="80" align="left" style="word-wrap: break-word"/><!-- billing bc -->
<col width="250" align="left" style="word-wrap: break-word"/><!-- billing bc value-->
<col width="130" align="left" style="word-wrap: break-word"/><!-- request bc -->
<col width="350" align="left" style="word-wrap: break-word;vertical-align:bottom;"/><!-- request bc value-->
<col width="120" align="left" style="word-wrap: break-word"/><!-- request reason -->
<col width="250" align="left" style="word-wrap: break-word;vertical-align:bottom;"/><!-- request reason value-->
<col width="50" align="left" style="word-wrap: break-word"/><!-- Cancel BC Request -->
<col width="50" align="left" style="word-wrap: break-word"/><!-- Cancel BC Request value-->

<tr>
<td align="left"><apex:outputLabel value="Date:" style="font-weight:bold" /> </td>
<td style="word-wrap: break-word" align="left">
<apex:outputText value="{0,date,MM/dd/yy}" >
<apex:param value="{!enrollLocationActivityData.ACVTY_DT__c}" />
</apex:outputText>
</td>

<td align="left"><apex:outputLabel value="Start Time:" style="font-weight:bold" /> <apex:outputLabel /> </td>
<td style="word-wrap: break-word" align="left"><apex:outputLabel value="{!enrollLocationActivityData.ACVTY_START_TM__c }" /> </td>

<td align="left"><apex:outputLabel value="End Time:" style="font-weight:bold" /> </td>
<td style="word-wrap: break-word" align="left" ><apex:outputLabel value="{!enrollLocationActivityData.ACVTY_END_TM__c}" /> </td>
</tr>
<tr>
<td align="left"><apex:outputLabel value="Time Zone:" style="font-weight:bold" /> </td>
<td style="word-wrap: break-word" align="left"><apex:outputLabel value="{!enrollmentLocationData.TIME_ZONE_NM__c}" /> </td>
</tr>
<tr>
<td align="left"><apex:outputLabel value="# English BCs:" style="font-weight:bold" /> </td>
<td style="word-wrap: break-word" align="left"><apex:outputLabel value="{!enrollLocationActivityData.EN_BENFT_CONSL_QTY__c}" /> </td>

<td align="left"><apex:outputLabel value="# Bilingual BCs:" style="font-weight:bold" /> </td>
<td style="word-wrap: break-word" align="left"><apex:outputLabel value="{!enrollLocationActivityData.BILGL_BENFT_CONSL_QTY__c}" /> </td>
</tr>
<tr>
<td align="left"><apex:outputLabel value="Requested BC(s):" style="font-weight:bold" /> </td>
<td style="word-wrap: break-word;vertical-align:bottom;" align="left" ><apex:outputLabel value="{!enrollLocationActivityData.REQST_BENFT_CONSL_TXT__c}" /> </td>

<td align="left"><apex:outputLabel value="Request Reason:" style="font-weight:bold" /> </td>
<td style="word-wrap: break-word;vertical-align:bottom;" align="left" ><apex:outputLabel value="{!enrollLocationActivityData.REQST_RSN_TXT__c}" /> </td>

<td align="left"><apex:outputLabel value="Cancel BC Request?:" style="font-weight:bold" /></td>
<td style="word-wrap: break-word" align="left" ><apex:outputLabel value="{!enrollLocationActivityData.CANCL_BENFT_CONSL_IND__c}"> </apex:outputLabel></td>

</tr>
</table>
</dd>
</dt>
</dl>
</apex:repeat>
</div>

</apex:repeat>

</apex:component>

 

Below is my page where component is called

<apex:page renderAs="pdf" Controller="some controller" sidebar="false" showHeader="false" cache="false">


<head>
<apex:stylesheet value="{!$Resource.PDFCSS}" />
</head>
<apex:pageBlock >

<apex:pageBlockSection columns="6" >

<table>
<tr>
<th style="color:#27408B" align="right">ENROLLMENT EVENT:</th>
<td align="right">{!enrollmentEventName}</td>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
<th style="color:#27408B" align="right">DISPACH REP:</th>
<td align="right">{!enrollmentEventDispacherName}</td>
</tr>
</table>

</apex:pageBlockSection>
<br/>
<apex:pageBlockSection columns="1" >

<c:EnrollmentEventLocationSummaryComponent />

</apex:pageBlockSection>

</apex:pageBlock>
</apex:form>

</apex:page>

 

please let me know what is the mistake i am doing for page break , and one in table i need to wrap the content and when the content s is wrapped it should display bottom .

firechimpfirechimp

Hi, sorry for the delayed response it has been a busy week.

There is quite a lot of code there, so may not get chance to have a good look at it until tomorrow.

But one thing I noticed at a glance was you have a '</apex:form>' without ever opening a form, I am guessing this is a copy and paste issue as it would probably not compile with this in there.

 

I will get back to you as soon as I get chance to take a proper look at this.

 

Another thing to note is you use 'page-break-after:always;' in your component, this will force a page break after this div. So if your page is currently displaying an entry from the 'enrolmentEventLocationList' list then you will have a page break even if it only has one item.