如何在asp.net mvc中将htlm视图转换为pdf [英] how to convert a htlm view to pdf in asp.net mvc

查看:77
本文介绍了如何在asp.net mvc中将htlm视图转换为pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个视图,它带来数据库中的数据,并以html格式显示,我想要一个按钮,如果你按下它将转换为pdf ..什么是在asp中转换为pdf的代码。 net mvc rozer file

i have a view that brings the data from the database and show it in html format ,i want a button so that if u press on that it will convert to pdf ..what is the code for converting to pdf in asp.net mvc rozer file

推荐答案

请参阅我对该问题的评论;为什么PDF?



首先,你不能只是转换到另一个。 HTML和PDF概念完全不同,因此没有任何一对一的对应关系,也不可能。 HTML是内容流畅,其呈现取决于页面的大小,PDF呈现完全固定的布局,非常像纸质打印输出。您只能根据某些特定要求创建一些特定的PDF映射。 PDF将只修复一个特定纸张尺寸的特定渲染。



要使用PDF,您可以使用iText或其.NET端口,iTextSharp:

http://en.wikipedia.org/wiki/IText [ ^ ],

http://itextpdf.com/ [ ^ ],

http://sourceforge.net/projects/itextsharp/ [ ^ ]。



包括在内也参考了Java iText网站,因为大多数文档都在那里。如果您了解C#,那么理解基于Java的API文档并不困难。



以防万一:PDF不是W3标准的一部分,可能或可能在客户端的浏览器上不受支持。这种支持基于一些可能或可能不可用的插件实现。此外,您不应该假设本地系统有任何PDF支持。这不是问题,因为浏览器总是可以回退到在本地文件系统中保存文件。



-SA
Please see my comment to the question; why PDF?

First of all, you cannot just "convert" one to another. HTML and PDF concepts are totally different, so there is no any one-to-one correspondence and cannot be. HTML is content is fluid, its rendering depends on the size of the page, and PDF presents totally fixed layout, much like a paper printout. You can only create some particular mapping onto PDF based on some particular requirement. PDF will fix only one particular rendering with one particular paper size.

To work with PDF, you can use iText, or its .NET port, iTextSharp:
http://en.wikipedia.org/wiki/IText[^],
http://itextpdf.com/[^],
http://sourceforge.net/projects/itextsharp/[^].

In included the reference to Java iText site as well, because most documentation is there. If you understand C#, it would not be difficult to understand Java-bases API documentation.

Just in case: PDF is not a part of W3 standards and may or may not be supported on client's browser. Such support is based on some plug-in implementation which may or may not be available. Moreover, you should not make an assumption that a local system has any PDF support at all. This is not a problem, because the browser can always fall back to saving a file in a local file system.

—SA


令人惊讶的是,谷歌将会想出什么。



http://www.c-sharpcorner.com/Blogs/9666/convert-html-to- pdf-in-Asp-Net-mvc-razor.aspx [ ^ ]
It's amazing what a little Googling will come up with.

http://www.c-sharpcorner.com/Blogs/9666/convert-html-to-pdf-in-Asp-Net-mvc-razor.aspx[^]


这篇关于如何在asp.net mvc中将htlm视图转换为pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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