如何使用C#代码将Asp.Net页面转换为PDF而不包含任何dll? [英] How to convert Asp.Net page to PDF using C# code with out any dll?

查看:92
本文介绍了如何使用C#代码将Asp.Net页面转换为PDF而不包含任何dll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将ASP.NET网页转换成pdf,只需点击一下按钮就可以使用任何dll

Is there any way to convert ASP.NET webpage to convert as a pdf with one button click with out using any dll

推荐答案

理想情况下你真的需要说服别人买一个好的pdf转换器库。



如果没有,有办法。



在服务器上,您可以设置打印机队列,打印到PDF文件。那里有打印机驱动程序可以做到这一点。



您可以将呈现的HTML发送到该打印机队列,并返回由此产生的文档。你必须看看你的CSS和posible提供打印媒体查询来修复大纲。



并试验使用什么打印机驱动程序。结果范围从可接受到可怕。



另外因为HTML文档是流文档而PDF文档是固定文档。您将遇到断线问题。你需要通过HTML / CSS来解决这个问题。这不是为了做到这一点。





显然还有另外一种方式那就是自己硬编码PDF。

然而,这需要多年的经验,这就是为什么你应该来自有经验的公司的dll
Ideally you'd really need to convince someone to buy a good pdf converter libary.

If not, there is a way.

On the server you could setup a printer queue that prints to a PDF file. There are printerdrivers out there that can do this.

You could than send the rendered HTML to that printer queue en return the document that comes out of that. You do have to look at you're CSS and posible provide print media queries to fix outlining.

And experiment with what printer driver to use. The results range from acceptable to horrible.

Also because an HTML document is a flow document en and a PDF document is a fixed document. You will get issues with line breaking. You'll need to adress this through HTML/CSS which wasn't build to do that.


Obviously there is another way and that is to hardcode the PDF yourself.
However this would take years of experience, which why you should by a dll from a company that has that experience


为什么你不想使用dll的?有几个库可以做到这一点。
Why don't you want to use a dll? There are several libraries that can do this.


这篇关于如何使用C#代码将Asp.Net页面转换为PDF而不包含任何dll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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