从出口到HTML PDF(C#) [英] Export from HTML to PDF (C#)

查看:174
本文介绍了从出口到HTML PDF(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  将HTML转换为PDF在.NET

在我们的应用中,我们让HTML文档报表和出口。
但是,现在我们的客户需要一个按钮,节省了他们的电脑,文件。问题是,该文件包括图像。
您可以创建具有以下code的Word文档:

In our applications we make html documents as reports and exports. But now our customer wants a button that saves that document on their pc. The problem is that the document includes images. You can create a word document with the following code:

private void WriteWordDoc(string docName)
{
    Response.Buffer = true;
    Response.ContentType = "application/msword";
    Response.AddHeader("content-disposition", String.Format("attachment;filename={0}.doc", docName.Replace(" ", "_")));
    Response.Charset = "utf-8";
}

但问题是,图像只是一个链接因此没有嵌入到Word文档中

But the problem is that the images are just links an thus not embedded in the word document.

所以我在寻找一种替代
PDF似乎是一个很好的选择,没有人知道C#一个很好的PDF格式的作家?
一说有一些很好的参考,并得到很好的测试?

Therefore I'm looking for an alternative PDF seems to be a good alternative, does anyone know a good pdf writer for C#? One that has some good references and has been tested properly?

推荐答案

我会选择在服务器上创建一个PDF文件。有迹象表明,这么多的产品​​,但你应该研究效果最好你的情况考虑下列之一:

I would opt for creating a PDF file on the server. There are many products that do so but you should research the one that works best in your case considering the following:


  • 要创建PDF所需的计算机资源。如果它是一个复杂的文档可能耗时太久,或减慢其他用户的响应。

  • 并发用户的数量,这将需要相同功能

  • 成本(有免费的解决方案,以及重量级的商业产品)。

我不会依赖Word格式为PDF格式会给你一些更多的保证,这将是在未来的可读性。

I would not rely on Word format for that as PDF will give you some more guarantee that it will be readable in the future.

此外,嵌入硬的选项链接到的图像似乎不是一个好主意给我。如果什么用户想打开该文档,服务器无法访问?

Also, the option of embedding hard links to the images don't seem a good idea to me. What if the user wants to open the document and the server is not accessible?

这篇关于从出口到HTML PDF(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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