+ Start a Discussion

Page Break Control

We are generating for printing some PDF templates using visualforce.

We have a question.. when the end of the page is reached, we need to control the break page in order to print in the second page a complete section, in this moment when the end of the page is reached the section is been broken and half of the section is printed on the first page and the second half in the second page.

We appreciate your help on this, as this is urgent for us to be able to print "nicely"


In case there is no posible to do this in visualforce , Is there any workaround for this?



Rajesh ShahRajesh Shah

The section you want to put in new page, you can add div tag to that section of the following type:


<div style="page-break-after:always;"> 

 your section




I think it will display in new page, so that while printing it will print on new page. Hope this helps

I have no idea about the layout of your template. But you can do something like this.. 

Controller(I assume that your controller returns a list):
  global class A{
    global List<String> getCount(){
      List<String> s = new List<String>();
      for (Integer i = 0; i < 10; i++) {
        s.add(i + '');
      return s;

<apex:page Controller="A" renderAs="pdf">
  <apex:repeat value="{!count}" var="v">
    <div style="page-break-inside:avoid;height:200px;width:300px;border:solid red 1px;">
      <!-- your content here -->

I am using repeat tag in my VF page, and I am getting extra blank page in  my PDF page.Any Ideas why it is coming.


Probably getting a blank page from the last page-break-after:always;