首页 > 解决方案 > How to print a BMP from file or HDC

问题描述

I am trying to add printing capability to my Windows app. So far, I have succeeded in (1) painting the image into an HDC; (2) saving it as a BMP file; (3) creating a BITMAPINFOHEADER and pixmap in memory; and (4) creating an HBITMAP object.
How can I send any of these to my laser printer? (I don't want to use any third-party app, but rather do it using API calls).
Any suggestions?

标签: printingbmpgdi

解决方案


看起来您需要使用 XPS Document API,除非您的打印机驱动程序接受 bmp 文件作为输入(这似乎不太可能)。另一种选择是将输出生成为 postscript 文件(许多打印机接受 .ps 文件作为输入;至少,他们曾经这样做过。检查打印机的文档)。

如果您选择 XPS 文档路径,请在此处查看文档:https ://docs.microsoft.com/en-us/windows/win32/printdocs/documents 显然,在 Windows 中,您现在可以将 XPS 文档发送到您的打印后台处理程序,它应该可以工作。我没有测试过这个。


推荐阅读