本文介绍了如何将MemoryStream中的PDF发送到.Net中的打印机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用iTextSharp在内存中创建的PDF,并包含在MemoryStream中.现在,我需要将该MemoryStream PDF转换为打印机可以理解的内容.

I have a PDF created in memory using iTextSharp and contained in a MemoryStream. I now need to translate that MemoryStream PDF into something the printer understands.

我过去曾经使用Report Server将页面呈现为打印机格式,但是我不能在该项目中使用它.

I've used Report Server in the past to render the pages to the printer format but I cant use it for this project.

是否存在本机.Net方法?例如,如果GhostScript是.Net程序集,则可以,但我不想将任何非.Net内容与安装程序捆绑在一起.

Is there a native .Net way of doing this? For example, GhostScript would be OK if it was a .Net assembly but I don't want to bundle any non .Net stuff along with my installer.

.Net中的PrintDocument类非常适合将内容发送到打印机,但是我仍然需要在页面级别将其从PDF流转换为GDI.

The PrintDocument class in .Net is great for sending content to the printer but I still need to translate it from a PDF stream into GDI at the page level.

有什么好的提示吗?

预先感谢

瑞安

推荐答案

另一种简便的方法是将pdf保存到临时文件中,并在Process中给出以下命令. Adob​​e Reader打印通过命令行

Alternate and easier way to do would be save your pdf into temp file and give following command in Process.Start that will take pdf straight to printing as mentioned in this Adobe Reader Print Throough Command Line

Process.Start("AcroRd32.exe /t \"C:\test.pdf\"");

我会说这是最好的方法,因为Adobe肯定会以正确的方式打印它,而不是依赖于其他任何工具,它们虽然很好,但并非100%正确.

I would say this is the best way because Adobe surely will print it in right manner, rather then depending upon any other tools, they are good but they are not 100% correct.

这篇关于如何将MemoryStream中的PDF发送到.Net中的打印机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 04:47