如何将 MemoryStream 中的 PDF 发送到 .Net 中的打印机?

发布于 2024-08-03 23:05:31 字数 354 浏览 4 评论 0原文

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

我过去曾使用报表服务器将页面呈现为打印机格式,但我无法将其用于此项目。

有没有一种原生的 .Net 方法可以做到这一点?例如,如果 GhostScript 是 .Net 程序集,那就没问题,但我不想将任何非 .Net 内容与我的安装程序捆绑在一起。

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

有什么好的提示吗?

预先感谢

瑞安

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.

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

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.

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.

Any good hints?

Thanks in advance

Ryan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吾家有女初长成 2024-08-10 23:05:31

另一种更简单的方法是将 pdf 保存到临时文件中,并在 Process.Start 中给出以下命令,该命令将直接打印 pdf,如 [Adobe Reader Print Through Command Line][1] 中提到的,

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

我想说这是最好的方法,因为 Adob​​e 肯定会以正确的方式打印它,而不是依赖任何其他工具,它们很好,但不是 100% 正确。
[1]: http://support.adobe.com/devsup/ devsup.nsf/docs/52080.htm

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 Through Command Line][1]

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

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.
[1]: http://support.adobe.com/devsup/devsup.nsf/docs/52080.htm

箜明 2024-08-10 23:05:31

您将需要像 GhostScript 这样的 RIP 来解释 PDF。我可以为您提供 C# 包装器,它包装 dll 调用以直接打印到打印机,但有与 GhostScript 相关的重新分发许可证。

我已经使用 LeadTools Raster Imaging Pro for .Net 来解释 PDF,但您需要检查其打印功能。这是一个昂贵的选项,并且不是免版税的(这实际上在内部使用 GhostScript,但非常包裹在 LeadTools dll 中。这个库运行良好并且绕过了许可。

不确定 Acrobat Reader 是否有可以使用的 API?您可以调查一下

You will need a RIP like GhostScript to interpret the PDF. I can give you C# wrapper tha wraps dll calls to print directly to a printer, but there are redistribution licenses associated with GhostScript.

I have used the leadTools Raster Imaging Pro for .Net to interpret PDF's, you will need to check its printing capabilities though. This is an expensive option and is not royalty free (this actually uses GhostScript internally, but is very wrapped up amongst the LeadTools dlls. This library works well and gets around the licensing.

Not sure Acrobat Reader has an API that can be used? You could investigate that.

HTH

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文