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
Harrison M.Harrison M. 

I am creating pdf file from VF page. I have a requirement to show data of different month on a separate page. I am getting data in a single list from the controller. How can I break the page for a different month? Please help.

Best Answer chosen by Harrison M.
Ajay K DubediAjay K Dubedi
Hi Harrison,

You can use the page-break property of the CSS. You can add 'page-break-after: always;' in your code where you want to break the page.

For more information please refer the below link:
https://www.w3schools.com/cssref/pr_print_pageba.asp

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi

All Answers

Deepali KulshresthaDeepali Kulshrestha
Hi Harrison,

Greetings to you!

I have also face some similar type of problem and I solve it through the page break.
If your data is coming in a list according to the months you simply add a page break after a month record and it will show the next record on the next page.

Please try the below code as it may help you in solving your problem.
<apex:repeat value="{!template}" var="temp" >
    <apex:outputText value="{!temp}" id="theValueOfTemplate" escape="false" style="align:left"/>    
    <p clear="all" style="page-break-before:always" />        
    </apex:outputText>
</apex:repeat>
Change it according to your needs. and you can also put page break after also Like (<p clear="all" style="page-break-after:always" />    ).

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
Ajay K DubediAjay K Dubedi
Hi Harrison,

You can use the page-break property of the CSS. You can add 'page-break-after: always;' in your code where you want to break the page.

For more information please refer the below link:
https://www.w3schools.com/cssref/pr_print_pageba.asp

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
This was selected as the best answer
Harrison M.Harrison M.
Thanks, Ajay and Deepali. You both have the same answer that really helped me a lot. Thanks for saving my time.
ghd sport 2ghd sport 2
I think it was help you more and follow the given link... https://salesforce.stackexchange.com/questions/216525/how-to-save-renderas-pdf-in-files-folder best regards - Latest Sports TV (https://ghd-sports.com/)
Noel WilliamsNoel Williams
Thank You Deepali and Ajay. This answer has saved my time a lot.. I will ask everyone to follow your answers. (https://allstarcagefighting.com/)