How to add a dummy printer to print data into a file in linux
We are develop a report that we want to print into a file in linux server, instead of export to the printer.
We try to add the dummy printer using the command below. lpadmin -p excelprt -E -v file:///dev/null
We had also check the printer is successfully added.

But when we try to use the command "-P SPOOLER" or "-Q excelprt" to print the report, we do not found anything generated in the folder, or the null latest date and time is not the updated date and time after we run the printing.
Is anyone have any idea can share with me how we can achieve to create the printer that allow us to print the data into a file(not pdf)?
Thank You.
First and foremost /dev/null is not a regular file
but a device node that discards all input, see
https://en.wikipedia.org/wiki/Null_device
Then (as far as I understand it)
lpadmin -p excelprt -E -v file:///...
will set up a so called "raw" queue (a queue
without any print job data processing)
but a DeviceURI like file:///tmp/output.prn
does not work for "raw" queues, see
https://github.com/apple/cups/issues/5117
Finally to make a "file" DeviceURI work you need to enable it via "FileDevice Yes" in /etc/cups/cups-files.conf for current CUPS versions or in /etc/cups/cupsd.conf for older CUPS versions and restart the cupsd after you changed its configuration.
To send print job data into a file with a "raw" queue I think it is better to use an appropriate CUPS backend. For example have a look at the section "A backend that sends its input into a file for debugging" in https://en.opensuse.org/SDB:Using_Your_Own_Backends_to_Print_with_CUPS
Perhaps the section "Background Information regarding Print as PDF versus Save as PDF" in https://en.opensuse.org/SDB:Printing_to_PDF might be somehow related to what you like to achieve in the end (I don't know what you actually like to achieve in the end).
By the way: When you use a current CUPS version on Linux the right place at GitHub is meanwhile https://github.com/OpenPrinting there in particular https://github.com/OpenPrinting/cups
First and foremost
/dev/nullis not a regular file but a device node that discards all input, see https://en.wikipedia.org/wiki/Null_deviceThen (as far as I understand it)
lpadmin -p excelprt -E -v file:///...will set up a so called "raw" queue (a queue without any print job data processing) but a DeviceURI like
file:///tmp/output.prndoes not work for "raw" queues, see #5117Finally to make a "file" DeviceURI work you need to enable it via "FileDevice Yes" in /etc/cups/cups-files.conf for current CUPS versions or in /etc/cups/cupsd.conf for older CUPS versions and restart the cupsd after you changed its configuration.
To send print job data into a file with a "raw" queue I think it is better to use an appropriate CUPS backend. For example have a look at the section "A backend that sends its input into a file for debugging" in https://en.opensuse.org/SDB:Using_Your_Own_Backends_to_Print_with_CUPS
Perhaps the section "Background Information regarding Print as PDF versus Save as PDF" in https://en.opensuse.org/SDB:Printing_to_PDF might be somehow related to what you like to achieve in the end (I don't know what you actually like to achieve in the end).
By the way: When you use a current CUPS version on Linux the right place at GitHub is meanwhile https://github.com/OpenPrinting there in particular https://github.com/OpenPrinting/cups
Thanks for the advise. We will try it out.
hi @jsmeix i tryed your tofile backend it seems works from the cups log but the /tmp/tofile.out is empty...