Newbie
VENKAT32
Posts: 2
How to break a visual force PDF containing a table of Line items

 

hi 
i got the similar problem to break a PDF page , i have a quote with line items table, when the line items are more the table automatically going to second page but its is overlapping with the header on the second page , i want the table to be continued after the header ,

 

 the following is my vf code:

 

 

<apex:page Controller="MyController32" RenderAs="pdf" >
<html>
<head>
<style type="text/css" media="print">

@media print
{
table {page-break-inside:auto }
 tr    { page-break-inside:avoid; page-break-after:auto }
 
 thead { display:table-header-group }
}
 
@page {

@PageBreak{
page-break:always;
page-break-inside:avoid;
} 

size:landscape;

@bottom-right {
 content: "Page " counter(page) "of " counter(pages);
}
@top-center {

content: element(header);

}

@bottom-center {

  content: element(footer);

}

}

 

div.header {

padding: 10px;

position: running(header);

}

div.footer {

display: block;

padding: 1px;

position: running(footer);

}

 




</style>

</head>

<!--header-->
<div class="header">
<table border='0'>
<tr>
<td height = '100'>
<apex:image id="theImage" value="{!$Resource.harlanlogo}" width="136" height="65"/>
</td>
</div>

<!--table-->
<body>
<div>
<table border ='1'>
<thead>
<tr>
<th>Number</th>
<th>M/F</th>
<th>Product</th>
<th>Description</th>
<th>Purpose</th>
<th>Item Price </th>
<th>Final Price </th>
<th>Packing Costs</th>
<th>Freight Costs </th>
<th>Total Costs</th>
</tr>

</thead>
<tbody>

<tr>
      <apex:repeat value="{!Quoteproduct}" var="a">
      
     
     
<tr style="page-break-after:auto;">

<td>{!FLOOR(a.Quantity__c)}</td>
<td>{!a.Sex__c}</td>
<td>{!a.Product__r.Description}</td>
<td>{!a.Product__r.Name } {!a.Age_Weight__c }</td>
<td>{!a.Purpose__c}</td>
<td>{!IF((a.Product__r.Family =='Package'||a.Product__r.Family=='Freight'),0,a.Sales_Price__c)} </td>
<td>{!IF((a.Product__r.Family =='Package'||a.Product__r.Family=='Freight'), 0 ,a.Discounted_Price__c)} </td>
<td>{!IF((a.Product__r.Family =='Package'),a.Sales_Price__c,0)}</td>
<td>{!IF((a.Product__r.Family =='Freight'),a.Sales_Price__c,0)} </td>
<td>€ {!a.Total_Price_QP__c}</td>
</tr>

      
</apex:repeat>
</tr>
</tbody>
</table>
</div>









</body>

</html>
</apex:page>

 

 

Super Contributor
Pradeep_Navatar
Posts: 1,450
Re: How to break a visual force PDF containing a table of Line items

Under the @ page{ } use the margin-top:10%; style :

 

@page

  {

    size:landscape;

    margin-top:10%;

    .

    .

    .

 

    }

 

Hope this helps.

Pradeep Bhatnagar
Navatar Group
Regular Contributor
venkatasubhashk
Posts: 54
Re: How to break a visual force PDF containing a table of Line items

Thanks Pradeep, i got that, Is there a way to get the Table column headings on the second page also..

Regular Contributor
emilyjones
Posts: 13
Re: How to break a visual force PDF containing a table of Line items

I need the answer to this also. 

 

thead { display : table-header-group;}  is not working

Regular Contributor
venkatasubhashk
Posts: 54
Re: How to break a visual force PDF containing a table of Line items

Hi

 

I have done a Work around for that,i wrote  multiple SOQL queries in my controller  for getting 10 opp lines and 20 opp lines ,and i used the apex tag  as follows

 

count_line__c is rollup count of quotelines on quote

 

controller:

QP1 = [select id,name,Quantity__c,product__c, Product__r.Name,S_no__c, Product__r.Family ,Product__r.Description , Age_Weight__c ,Purpose__c,sales_Price__c ,Discounted_Price__c,Sex__c, Total_Price_QP__c 
  from Quote_Product__c  where Quote__c =:Q.Id and (S_no__c >= 16 and S_no__c<35)];
   
QP2 = [select id,name,Quantity__c,product__c, Product__r.Name,S_no__c, Product__r.Family ,Product__r.Description , Age_Weight__c ,Purpose__c,sales_Price__c ,Discounted_Price__c,Sex__c, Total_Price_QP__c 
  from Quote_Product__c  where Quote__c =:Q.Id and (S_no__c >= 35 and S_no__c<=53)];

 

paeg:

 <apex:outputPanel rendered="{!QUOTE.Count_line__c >15}"> "