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 

Page Break when visual force PDF is rendered dynamically content

Hi There,

 

I am generating a pdf .

the content on  the pdf is dynamic from different objects and different products.

i want to fit the content of one page , but in my pdf content is going to other page .

if the product information is not fit into one page i want to move to other page , which should happen when page rendered .

 

Thanks 

Best Answer chosen by Admin (Salesforce Developers) 
arunadeveloperarunadeveloper

got the solution 

 

<div style="page-break-after:always;"> put here your content </div>

All Answers

souvik9086souvik9086

See if this helps

 

http://mindfiresfdcprofessionals.wordpress.com/2013/08/10/page-break-functionality-for-printing-record-detail-page/

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

Ajay_SFDCAjay_SFDC

Hi There ,

 

If you put your Data content in Div and set style of div as  "page-break-after:always;"  the contents will be automatically reflect on next page .

 

But if you want everything on the same page then you have to style  @page in your css .  You can give height and width of your page using size property . 

 

For example :

You can set size of First page 

 

@page:first {
margin-top: 0.5cm;
margin-bottom: 0.5cm;
margin-left: 0.5cm;
margin-right: 0.5cm;
size: 220mm 300mm; 
/* page-break-after:always; */
/* page-break-after:auto; */
/*border :1px solid black;*/
/*border-bottom :1px solid black;*/

}

 

(For second page )


@page{
margin-top: 0.5cm;
margin-bottom: 0.5cm;
margin-left: 0.5cm;
margin-right:0.5cm;
size: 220mm 300mm;
/* border :1px solid black; */

 

 

Thanks ,

 

Ajay

 

arunadeveloperarunadeveloper

Hi Ajay,

 

Actually what i want is each location details i want to in different page , when ever the locaions starts it should stars in diffetent page not on the same page.

 

if frst location is not having any data leave the empty plave and put the 2 nd location in different page .

can we do this kind of page break in PDF.

 

as you please suggest it is possible to do that or not  ?

               

arunadeveloperarunadeveloper

got the solution 

 

<div style="page-break-after:always;"> put here your content </div>

This was selected as the best answer
souvik9086souvik9086

Great !! That is what I pointed you in the above link.

Anyways good that you find it.

arunadeveloperarunadeveloper

Hi, i got one more problem , i am able to break the page and display page numbers but the problem is that  the pdf is displaying after 2 pages content 3 or last page is empty. I don't want to display that last page as epty page with page number.

can you please suggest how can remove last page as empty page.

 

thank you,

Nitin SehgalNitin Sehgal
There would be somthing that is going out of the page which is generating the last page as empty. I would suggest to make the font size a bit smaller.
Nitin SehgalNitin Sehgal
I also have a question :

As I saw above, we have @page:first page rule but we don't have @page:last in this.

Actually i have put footers in the PDF that i am generating and i don't want to show the footer at the last page of the pdf.

Is there anythink that can solve this problem?

Thanks in Advance
umesh atryumesh atry
this css  page-break-inside: avoid;, page-break-before: avoid; works only when you need to iterate on componet. if you are using inline pre-built css into page then you have to check following css related to body tag. like this:

body { box-sizing: border-box; height: 11in; margin: 0 auto; overflow: hidden; padding: 0.5in; width: 8.5in; }

here  i am using width and height with auto value.