不使用iTextSharp / RazorPdf将MVC Razor View导出为pdf [英] Export MVC Razor View to pdf without iTextSharp / RazorPdf

查看:88
本文介绍了不使用iTextSharp / RazorPdf将MVC Razor View导出为pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有MVC Razor View,其上应用了Bootstrap CSS +自定义CSS以及许多数据,如Logo(图像格式),页眉,页脚等。

如何将MVC Razor视图导出为pdf在MVC中没有iTextSharp / RazorPdf?

让我知道建议。 pdf应该与View相同。

I have MVC Razor View with Bootstrap CSS + Custom CSS applied on it & many data like Logo(in image format), Header, Footer etc.
How can I Export MVC Razor View to pdf without iTextSharp / RazorPdf in MVC?
Let me know suggestion. The pdf should look like same as a View.

推荐答案

如果您不想使用任何第三方工具,那么您需要学习PDF格式以及如何自己创建PDF文档。 .net没有内置的PDF,因为它是一种专有格式,所以你将不得不使用某种形式的第三方工具或自己动手。
If you don't want to use any third-party tools then you'll need to learn the PDF format and how to create PDF documents yourself. .net has no in-built for PDF as it is a proprietary format so you're going to have to use some form of third party tool or do it yourself.


HTML5和PDF有关于文件概念的两种不同观点。请注意,该PDF基于PostScript,后者是一种复杂的可编程描述性语言,适用于打印机。 html5,css3和其他东西引导依赖的网络生活在一个完全不同的世界。

因此,在html和pdf之间映射一些内容和格式是一个你必须决定的常规问题,最终实施。您引用的工具或 MvcRazorToPdf [ ^ ]以自己的方式执行此操作。无论哪种方式,他们都会阅读html内容,解释格式并生成pdf原语。 Bootstrap很复杂,太具有动力性,而且太新了,无法使用现成的映射器。所以你要么自己做,要么接受现有工具的约束。



你也要读这些:

http://daveaglick.com/posts/using-aspnet-mvc-and-razor- to-generate-pdf-files [ ^ ]

使用Rotativa在ASP.NET MVC中生成PDF [ ^ ]
HTML5 and PDF have two different view on the concept of "document". Please note, that PDF is based on PostScript, which is a complex programmable descriptive language for printers. The web for which html5, css3 and other things bootstrap relies on are living in a totally different world.
So mapping some content and format between html and pdf is a matter of convention you have to decide, and eventually implement. The tools you have referred to or MvcRazorToPdf[^] are doing this in their own way. Either way, they read the html content, interprete the format and generate pdf primitives. Bootstrap is to complex, too dynamci and too new to have a ready-made mapper to use. So you either do it yourself, or accept the constraits of the existing tools.

You shoudl read these too:
http://daveaglick.com/posts/using-aspnet-mvc-and-razor-to-generate-pdf-files[^]
Generate PDF in ASP.NET MVC Using Rotativa[^]


这篇关于不使用iTextSharp / RazorPdf将MVC Razor View导出为pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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