How to display page breaks in PDF generated by Rotativa

ぐ巨炮叔叔 提交于 2019-12-03 05:16:09
Eric Brown - Cal

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

The answer is correct but you have to do it in a different manner like:

<div style="page-break-after: always;">Content before page breaks</div>
<div>Content after page breaks<div>

This does the trick!

Hope that helps!

Sobin Sunny

You can use any of this three CSS code to set the page break for an element,

page-break-after
page-break-before
page-break-inside

According to your situation.

This works every time for me and in all browsers. My application is ASP.NET MVC3 Razor.

In your style sheet (.css) or in a style tag put this:

@media all {    .page-break { display: none; } }

@media print {  .page-break { display: block; page-break-before: always; } }

Where you want your page to break put this:

<div class="page-break"></div>

Works perfect in all browsers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!