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
AvanxoColAvanxoCol 

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?

 

TRF

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

 

</div>

 

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

prageethprageeth
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;
   }
 }

Page
 
<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 -->
    </div>
  </apex:repeat>
</apex:page>
Goodluck123Goodluck123

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.

WizradWizrad

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