Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add a dummy printer to print data into a file in linux #6090

Open
alicetan01 opened this issue Nov 24, 2022 · 3 comments
Open

How to add a dummy printer to print data into a file in linux #6090

alicetan01 opened this issue Nov 24, 2022 · 3 comments

Comments

@alicetan01
Copy link

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:https:///dev/null

We had also check the printer is successfully added.
image

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.

@jsmeix
Copy link

jsmeix commented Nov 24, 2022

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:https:///...

will set up a so called "raw" queue (a queue
without any print job data processing)
but a DeviceURI like file:https:///tmp/output.prn
does not work for "raw" queues, see
#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

@alicetan01
Copy link
Author

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:https:///...

will set up a so called "raw" queue (a queue without any print job data processing) but a DeviceURI like file:https:///tmp/output.prn does not work for "raw" queues, see #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

Thanks for the advise. We will try it out.

@bisegni
Copy link

bisegni commented May 8, 2024

hi @jsmeix i tryed your tofile backend it seems works from the cups log but the /tmp/tofile.out is empty...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants