Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have been searching for an answer for a month now but i am unable to find the exact solution or a method or from where to start.

I want to create an application that logs the data printed. for example if I print "abcd" from notepad I want to capture this "abcd" from my software.

I want to ask that from where should i start or what tools should I use. I want to develop this application in C#.

I can access the Job ID , queue name etc using the PrintQueue class. but i am unable to access the data that is to be printed.

I dont have any experience developing port monitors or print monitors. Is there a simple way to achieve this task ? Like any built in C# functions or if i can just capture the raw prn file that will be ok as well but i dont want to user know that the prn file is being saved.

Any help or sample code will be highly appreciated.

[If there is a similar post already please post a link to that thanks]
Posted

1 solution

If you set the print spooler setting "Keep printed documents" then the spool file will be stored after the print completes and (if you also choose to spool EMF files) this can be read with this EMF Printer Spool File Viewer[^]

There are some complexities as this is not an easy task - for example you need to make sure the print job is completed before you try to read the spool file, and if the spool file is using embedded fonts you need to find the offset to apply to get the real text characters..
 
Share this answer
 
Comments
Aitizaz Khan 8-Sep-14 11:36am    
is there a general method to do this that applies to all types of print jobs?
in my case the print data is only text but when i read the the .spl file i dont find my text inside the spl file.
Duncan Edwards Jones 8-Sep-14 11:50am    
Are you using the above referenced spool file viewer code to view the spool file?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900