Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
hi everyone;
i'm looking for source code or sample that get printer data before print (capture printer output) put it in variable and change some values then print it in form.
any idea how to get data and put it into variable for special purpose.
Posted
Updated 11-Jul-15 12:06pm
v2
Comments
[no name] 10-Jul-15 19:02pm    
Okay.... and? Did you have a question related to your code? You say "that virtual printer program" there is only one in the universe and we would have any idea at all what you are talking about. Seems to me that you are way over-complicating this. Read the file, do your substitutions, print file. Repeat for however many time you need to substitute and print. All this copying to clipboard, etc, is unnecessary/
salam_dust_man 11-Jul-15 4:54am    
HI;
YOUR RIGHT but WORKING WITH MOUSE IS EASYER THAN KEYBOARD.I PUT PRINTER BUTTON IN MY PROGRAM .I SIMPLY PASTE THE DATA , CHANGE THEM AND PUSH THE BOTTON OF THE PRINTER.
THUS I AM NOT MAKING FORM MANUALLY .
IF I HAVE SOMETHING THAT CAPTURE PRINTER OUTPUT IT MAKE MY JOB VERY VERY EASY.
and sorry for my english- i am not an impolite person .

BY THE WAY THANKS FOR REPLY
[no name] 11-Jul-15 5:50am    
And.. so? What does that have to do with anything? You are making this way more complicated than it needs to be. You don't need to make any kind of printer driver at all.

And stop screaming at people. It doesn't help you and it pisses people off.

1 solution

Well, you're going to have to write your own Notepad then.

"Intercepting" the print job and editing it is an extraordinarily complex way to do what amounts to Mail Merge.

The application describes what the page image looks like to the print driver. The driver takes that "image" and translates it into code that the printer understands.

You would have to write a printer driver that takes a configuration to send a job to another printer driver. I've never seen one.

Also, you're not going to write a printer driver in C#. C/C++ is a much better choice because you won't be rewriting large parts of the Windows DDK in managed code.

You're not going to find and example of this because it's so overkill for the problem you describe.


This is nothing more than field replacement, or Mail Merge in Word. This is something you write into a line of business application, not a printer driver.
 
Share this answer
 
Comments
salam_dust_man 11-Jul-15 5:06am    
HI;
ok,FIRST I HAVE TO MAKE PRINTER DRIVER AND THEN GETTING DATA WITH THAT THEN SEND THE DATA TO THE OCR PROGRAM THAT EXTRACT TEXT DATA THEN PUT IT INTO VARIABLE IN MY PROGRAM.
SOUNDS VERY VERY HARD.
DO YOU HAVE ANY RESOURCE OR SAMPLE, IT WOULD BE GREAT HELP.
and sorry my english is not good.i am not an impolite person
BY THE WAY THANKS FOR THE REPLY :)
Dave Kreskowiak 11-Jul-15 10:53am    
First, STOP YELLING AT PEOPLE!

No, I don't have any sample or source. It's just too easy. This is simple string manipulation. Your code looks for whatever you define as a replaceable tag in the text and uses String.Replace() to do the replacements. Then you print the document.

You really don't even need any code if you know how Microsoft Word works. It does what you describe right out of the box. Take a look at that before you go diving into code.

Part of the process of writing code is knowing when you really need to write it.
salam_dust_man 11-Jul-15 17:51pm    
ok sorry for my english writing- i am not bad person at all.
my reply was a little comlicated and my friend got wrong idea-
first i should say thank you for noticing me for my bad writing.
-----------------------------------------------------------------------
working with ms-word is not quick way for me.i'm looking for quick way.
any other idea would be so good.
thanks for the reply.
Dave Kreskowiak 11-Jul-15 19:58pm    
You haven't provided enough detail about exactly your process flow and what applications are involved.

The best answer you're going to get with what you've provided is that you need to write your own text editor with replacemnet field support. It's really not hard to do.

Try to do this is a printer driver will take you forever to write.
salam_dust_man 14-Jul-15 10:19am    
ok.
i'm working with program that generate report and after generating report it print all data.most of the text is fix. also it is like text editor.
i mean i can copy text and paste text and...
if i want to change the text i have to load it and edit it in other program and make pdf files and send it to the printer.
now i'm looking for sample that get data when program send data to my virtual printer and extract data ,input needed and then send it to the printer.
ok let me explain more.
think of note pad.(the program looks like that)
i just enter code of recipt .the program load the recipt .i copy the recipt and edit and print.
an other way is print it directly.
in program when i print the code recipt it is automatically load the recipt and then print it.
i want the second way for doing my job.
thanks for the reply

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