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

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

问题描述


可能重复:

将HTML转换为PDF中的HTML

我们的应用程序将html文件作为报告和导出。
但是现在我们的客户想要一个在他们的电脑上保存该文档的按钮。问题是文档包含图像。
您可以使用以下代码创建单词文档:

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似乎是一个很好的选择,有没有人知道一个好的pdf作者的C#?
一个有一些很好的参考,并已经过正确的测试?

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天全站免登陆