I want to know that, is there any way to access the file that is going to print.
Suppose i have a software that has a print button. If i click the print button it will call the printer to print. Can i get the file from printer driver or from any other source during these process.
Regards
Ansif
Programs don't send "files" to a printer. In the case of PostScript and PCL printers, programs send commands to the printer, such as "draw text "foobar" at point (10,23)".
Modern (especially cheaper) printers in the past 17 years or so, are often GDI printers, where programs use Windows' GDI functions to "draw" the printed page to a raster buffer which is then sent to the printer, which makes the printers cheaper as they don't need a command interpreter and processor built-in.
So to answer your question, "no", you cannot access files that are going to print, because they don't exist.
Related
I want a graphical application for Linux that displays the contents of CD/DVD/blu-ray drives and allows play or eject, and I'd like the solution to be general, so that I can donate it to Linux Mint, that is any drive type and any number of drives. In my system I have three dvd drives and a blu-ray drive.
I'd like to write it in bash using the dialog functions inside a terminal window but I need to have the dialog displayed in perpitude therefore, I need an interrupt to signal when the drive is opened or closed - what signal could I trap? Also, how can I include logic to select a program to play the media depending on the media type.
Also, should I consider writing it in java, python, C++, or other language and if so how to get hardware information (such as the number and capability of drives, and the type and title of optical media in drive)?
Ignoring the side of "I want to donate this to Linux Mint", which I believe is a bit pretentious, there is a eject utility in Linux.
The source code of that can be found here:
https://git.kernel.org/cgit/utils/util-linux/util-linux.git/tree/sys-utils/eject.c
In that code, there is also code to sense if the drive is open, closed, has no disk, etc.
To do CD or DVD playback is a whole other kettle of fish. To write a audio-player is not entirely trivial (even in the simple case of a straightforward PCM encoding, obviously MP3 is a fair bit more complex again), and a video-player is a lot more than that.
To "select a program", you'd have to know what the available players may be called, and, if you want to be fancy, check which ones are actually installed. I'm not aware of any really clever way of achieving that, beyond having a list of players in your code (which needs to be updated). In fact, I know that is how the photo viewer geeqie works when you want to edit a shot: it has a list of "known editors", and it scans the PATH to find which ones are available.
I am interested in writing a program for linux that will read ALL keystrokes, process it and THEN output to the rest of the running processes. Essentially, ALL keyboard input must go into this program and this program alone...Then the program will act as the keyboard for the rest of the computer. I basically want to do something like predictive text on android devices, so my program will act as a filter.
What i'm asking is basically how to direct all keyboard events to my program. While i am not looking for code, i would like to know what part of linux programming/ linux system do i have to learn to be able to complete this task? this, because i am doing this in an attempt to better learn linux.
You shouldn't modify keyboard drivers since this will require you to have a solution for every keyboard manufacturer.(and there are quite a lot of these..)
Instead you should patch a kernel function that is called by all drivers before passing the input further up the stack.
To start with, you could patch input_event which is usually called by all input drivers see documentation here (not only keyboard but also mouse and other devices)
In any case you will have to "decode" the input scan code where you might find this documentation useful.
For more information on kernel patching read here and here.
I am writing an C++ Application and have to read if an arrow key is pressed or not.
I only found some function that are only working on Windows.
You have such problem because you just ask the wrong question. If you application is a command line tool and is accessible from a terminal, than it's just impossible to know which keys are pressed at the moment because the terminal can be far away from the machine where your application runs and which is more important, there is no reason for terminal to send you the arrow key presses because terminal can use them for text navigation.
So you may search how to make the terminal to send you key presses. Not every terminal will support it, but, I think, most of modern terminals in modern OS do.
If you has a gui application that is for running locally and assuming that you control it from the keyboard that is plugged in. Than you should search for the documentation for your gui toolkit. (Qt, wxWidgets, raw xorg, windows API, etc.)
So there are just no native C++ solution for this problem because you question just has no sense in many situations.
So you can use some console library like ncurses or gui toolkit like Qt or search for a native solution in your particular situation, but don't expect this last way will work without any additional code on other machines.
Or just search for other libraries that can allow you to do it.
As you say you only found material for Windows, I assume you are looking for a Linux-Unix way. Old dinosaurs like me remember the time when we only had true consoles (only a keyboard and a 80x25 display). And in these early times existed low-level libraries to interpret keypad transmitted keys and position cursor on screen on almost any terminal, and higher level ones to use the screen as a (text only) GUI.
You should look for curses or ncurses for high level libraries, and terminfo for the low-level capabilities.
The problem
I have a Windows XP pc connected to a printer. This pc runs a piece of software from where i create and send print jobs to the printer. Recently, the printer died and there is no way i can get a new one. The program is configured to print to this specific printer, which is now a problem.
The question
Is there a way to catch the data send to windows print spooler? From what i've found, i have to develop a print monitor (.dll file which will be read by spooler.exe, correct me if i'm wrong), however this seems pretty overcomplicated for such a matter. I've been searching the Print Spooler API, but the GetJob method returns, from what i can see, only informations about the print job, and not the actual data of the print.
I would like to catch this data and then process it in a another program that I will make myself. This is not really the issue, I am more concerned to know if it is possible to catch the data from the print spooler, and if possible some hints to how i could do it.
Thank you.
Your problem is more serious than you might realise. The task of transmitting spooled printer data to a specific printer is calls a Print Processor, which sits in the printer chain preceding the Print Monitor. Documentation here: http://msdn.microsoft.com/en-us/library/windows/hardware/ff551771%28v=vs.85%29.aspx
The spooled data can be in one of several different formats, and for some of them it may not be possible to redirect to a printer of a different type. You didn't mention what types of printers you are dealing with.
This is fairly serious stuff: writing and debugging one of these babies takes significant low level skills and understanding of Windows tech.
Edit: There's a good chance the data is in Enhanced Metafile format, and you need to take advantage of the built-in converters to turn that into commands for your new printer.
Is there any possibility to print document in Linux to standard output, formed for later sending directly to printer's queue and is there any generic format, suitable for all network printers?
Indeed, I do need to do the following process:
1. Print doc to the above mentioned formatted output (or file).
2. Transfer this to the remote device.
3. Send this to the Printer.
Some more details: Document is printed on one hardware Server, being sent to some Device with no printer Driver (so, it Detects printer as a Network device) and then send the Document to queue as a TCP client.
I would recommend that you print to PostScript or PDF. For example, here is a CUPS PDF printer. Another way to do it would be to write your own backend. Here is an example of how to write a CUPS backend in a shell script.
There is no format all printers understand, other than plain text of course. Which has nothing to do with Linux, really. But if you're willing to include some processing in step 3, sure, just write pdf or postscript and send that through the standard printer queue.
is there any generic format, suitable for all network printers?
No. Some printers will understand PostScript, others will understand PCL, and others will require other specific formats. There is no "lingua franca" in the printer world as far as hardware is concerned, which is why you must go through a print manager.
Is there any possibility to print document in Linux to standard output, formed for later sending directly to printer's queue
Since there is no common printing format, you can't make such a document. The simplest thing on Linux is to print either to PostScript or to PDF, and feed that again to CUPS (or any other print manager you use) when you want to output on a specific printer.