如何显示PDF由Rotativa产生分页 [英] How to display page breaks in PDF generated by Rotativa

查看:258
本文介绍了如何显示PDF由Rotativa产生分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的ASP.NET MVC应用程序4,我有一个嵌入了几个局部视图索引视图。我通过安装的NuGet最新Rotativa的1.6.1版本。现在我可以打印索引页使用Rotativa PDF文件。我想每一个局部视图后,已在PDF分页符。如何才能实现这一使用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?

我试图按照<一个href=\"http://stackoverflow.com/questions/15250505/displaying-headers-and-footers-in-a-pdf-generated-by-rotativa\">this例如的使用CustomSwitches,但似乎并没有成为一个分页符。我用<一个href=\"http://letsfollowtheyellowbrickroad.blogspot.com/2012/02/rotativa-how-to-print-pdf-in-aspnet-mvc.html\">this文章生成PDF

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

推荐答案

如果您使用的是1.6.1你可以添加分页符在CSS(这不1.5.0工作始终,我没有测试过1.6 .0)

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)

所以,添加这种风格,不喜欢p.breakhere {...}一个特定的元素,但是,如下图所示(有些人有一个特定的元素上的问题)

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>

然后在你的HTML只是做到这一点。

Then in your html just do this

<P CLASS="breakhere">

和它应该很好地打破。请注意,1.6.1与幻影图像中的错误,间歇...
请参阅本SO输入<一个href=\"http://stackoverflow.com/questions/23071227/rotativa-1-6-1-image-ghosting-but-only-on-qa-not-dev-or-integration-server\">Link

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

这篇关于如何显示PDF由Rotativa产生分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆