简体   繁体   English

从ASP.NET批量打印PDF

[英]Batch Printing PDFs from ASP.NET

I have a situation where in a web application a user may need a variable list of PDFs to be printed. 我遇到的情况是,在Web应用程序中,用户可能需要打印可变的PDF列表。 That is, given a large list of PDFs, the user may choose an arbitrary subset of that list to print. 也就是说,给定一个很大的PDF列表,用户可以选择该列表的任意子集进行打印。 These PDFs are stored on the file system. 这些PDF存储在文件系统中。 I need a method to allow users to print these batches of PDFs relatively easily (thus, asking the user to click each PDF and print is not an option) and without too much of a hit on performance. 我需要一种方法来允许用户相对容易地打印这些批次的PDF(因此,不要求用户单击每个PDF并进行打印),并且不会对性能造成太大的影响。

A couple of options I've thought about: 我考虑过的几个选择:

1) I have a colleague who uses a PDF library that I could use to take the PDFs and combine them on the fly and then send that PDF to the user for printing. 1)我有一个使用PDF库的同事,我可以使用该库来获取PDF并即时组合它们,然后将该PDF发送给用户进行打印。 I don't know if this method will mess up any sort of page numbering. 我不知道此方法是否会弄乱任何类型的页面编号。 This may be an "ok" method but I worry about the performance hit of this. 这可能是“确定”的方法,但我担心此方法会降低性能。

2) I've thought about creating an ActiveX that I would pass the PDFs off to and let it invoke the printing features. 2)我曾考虑过要创建一个ActiveX,以便将PDF传递给它,并让它调用打印功能。 My concern is that this is needlessly complex and may present some odd user interactions. 我担心的是,这不必要地复杂,并且可能会出现一些奇怪的用户交互。

So, I'm looking for the best option to use in this scenario, which is probably not one of the ones I've gone through. 因此,我正在寻找在这种情况下使用的最佳选择,这可能不是我经历过的选择之一。

The best solution I have for you is number 1. There are plenty of libraries that will merge documents. 我为您提供的最佳解决方案是第1个。有很多可以合并文档的库。 From the one I've used the numbering should not be an issue since all the pages are all ready rendered. 从我使用过的那个开始,编号应该不是问题,因为所有页面都已准备就绪。

If you go with ActiveX you are going to limit yourself to IE which might be acceptable. 如果您使用ActiveX,则将自己限制为IE,这可能是可以接受的。 The only other idea would be to use a smart client so you can have more control...then you could serve up the PDF's via a web service. 唯一的其他想法是使用智能客户端,以便您可以进行更多控制...然后可以通过Web服务提供PDF。

I think concatenating the documents is the way to go. 我认为合并文档是一种方法。 For tools I recommend iText#. 对于工具,我建议使用iText#。 Its free 免费

You can download here iTextSharp 您可以在这里下载iTextSharp

iText# (iTextSharp) is a port of the iText open source java library for PDF generation written entirely in C# for the .NET platform. iText#(iTextSharp)是用于生成PDF的iText开源Java库的端口,该库完全以.NET平台的C#编写。 Use the iText mailing list to get support. 使用iText邮件列表获得支持。

I agree with #1. 我同意#1。 You could do some tests to see what the performance hit would be like. 您可以进行一些测试,以查看性能受到的影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM