+ -
当前位置:首页 → 问答吧 → 如何提取本地打印机打印的文字?

如何提取本地打印机打印的文字?

时间:2011-12-21

来源:互联网

操作系统为Windows XP
需要在本地打印机打印文字的时候提取它打印的文字。目前想到的方案有:
1)使用虚拟打印机,让虚拟打印机打印txt文件,完成后再将打印任务转移(Redirect)到本地打印机。
使用这个方案,不知道有没有免费的SDK可供使用?
2)监控打印机端口
据我监控的结果看起来像是乱码,应该是并口发送给打印机的指令集,不知道如何从这些指令集中提取打印文字?

另外其它简单可行的方法也希望大家提供。

作者: silverbullet007   发布时间: 2011-12-21

如果往打印机送的是字符的像素或图片,你能保证正确识别出对应啥文字吗?

作者: zhao4zhong1   发布时间: 2011-12-21

引用 1 楼 zhao4zhong1 的回复:

如果往打印机送的是字符的像素或图片,你能保证正确识别出对应啥文字吗?


首先可以肯定打印的是文字,不是图片,因为使用虚拟打印机后输出的是文字

作者: silverbullet007   发布时间: 2011-12-21

不知道可不可以从打印缓冲池中提取文字?

作者: silverbullet007   发布时间: 2011-12-21

没有人帮忙解决吗?

作者: silverbullet007   发布时间: 2011-12-22

Windows下Hook打印文字相关API?
Printer: Printing Sample

Click to open or copy the files for the Printer sample.

The Printer sample shows how to print using both the CreateDC and the PrinterDlg methods for acquiring a printer HDC. The user is allowed to print different graphical objects, as well as a complete device font set. An "Abort" dialog box is also implemented. 

The Printer sample also does the following: 

Provides complete device capabilities for all printers and the display.


Provides information (levels 1 and 2) returned by a call to EnumPrinters.


Shows how to enumerate fonts for a particular DC.


Illustrates differences among the various mapping modes.


Demonstrates GDI features. 
Building SDK Samples 

This sample uses the following keywords:

createdc; deletedc; errmsgbox; getlasterror; getstringres; getstringres2; isdbcsleadbyte; mainwndproc; makeintresource; my_mbslen; outnum; outstr; outstr2; outstr3; printdlg; printthread; registerclass; strcat; winmain; wsprintf

作者: zhao4zhong1   发布时间: 2011-12-22