Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display page breaks in PDF generated by Rotativa

In my ASP.NET MVC 4 app, I have an index view that has several partial views embedded in it. I installed latest version 1.6.1 of Rotativa via NuGet. Now I can print the index page to a PDF using Rotativa. I would like to have a page break in the PDF after every partial view. How can this be achieved using Rotativa?

I tried to follow this example to use CustomSwitches but there does not seem to be one for page break. I used this article to generate the PDF

like image 587
nam Avatar asked Mar 10 '14 15:03

nam


Video Answer


1 Answers

If you are using 1.6.1 you can just add the page breaks in the CSS (this does not work consistently in 1.5.0, I have not tested 1.6.0)

So add this style, not to a specific element like p.breakhere{...} but as shown below (some folks had issues on a specific element)

<STYLE TYPE="text/css">
 .breakhere { page-break-after: always }
</STYLE>

Then in your html just do this

<P CLASS="breakhere">

And it should break nicely. Do be aware that 1.6.1 has a bug with Ghosted images, intermittently... See this SO entry Link

like image 67
Eric Brown - Cal Avatar answered Sep 20 '22 19:09

Eric Brown - Cal