LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Cups-pdf filename from printer (https://www.linuxquestions.org/questions/linux-general-1/cups-pdf-filename-from-printer-4175518154/)

wpflum 09-10-2014 02:40 PM

Cups-pdf filename from printer
 
I'm trying to get cups-pdf to save the filename as the printer name so I can use the filename to determine how to handle the printjob in the postprocessing script. What I want to do is set up a bunch of cups-pdf printers like staffpdf, managerpdf, etc and then use the post processing script to determine the target email group by the printer name and then email the pdf to them. This way I can send reports generated by the server automatically to the intended recipients just by having them printed to a specific printer. My problem is that I do not see any way of getting the printer name into a variable and through cups-pdf/cups. Anyone done something like this or have any idea how I could do it? It doesn't have to be cups-pdf but right now I have that working and can run the reports to it and I have the post processing script working just to rename the file with the date/time so they don't overwrite each other when I print several at a time.

Thoughts???

michaelk 09-11-2014 08:11 AM

How many reports? Is this everyday, week or month?
Are they created on a windows or linux PC?
Are you using some batch process or just a GUI application?

For a small number of reports generated by a GUI application I might just use print to PDF file. Copy or save them to your specific directory then run your email post processing script.

If using some batch process using lpr then you can specify a user on the command line. Then cups-pdf will save that to that user directory as specified in the cups-pdf.conf file. You can then run your post processing script per specific directory.

There are various ways to create a cups filter/dummy printer or a samba printer via LPRNG. GUI apps will print as PS or PDF so writing a script is fairly easy and cups-pdf uses ghostscript to convert. Include your post processing and email.

wpflum 09-11-2014 08:35 AM

The reports are monthly and quarterly and I generate them from an access database using wine to run a macro in access from the command line to just print the report while using a null screen for the graphics.

Unfortunately these go to different groups so dumping them all to a single user then running an email script wont work unless I can label the files like I want to anyway.

These reports are run from cron so they are automatically run each month and each quarter but right now they print to a printer and are then copied and distributed. What I want to do is be able to skip the physical part and just send an email with a pdf of each report.

The wine/access combo prints to the default printer of the server, currently a physical printer on the old server and right now the cups-pdf printer on the new. The reports are generated fine but without being able to tell them apart I can't write any kind of script to seperate them up and email them.

wpflum 09-11-2014 09:51 AM

It looks like I can specify different cups-pdf.conf files per printer?? I found some documentation saying that I can change the cups-pdf.conf file to cups-pdf-whatever.pdf and change the uri of the printer to match but that isn't working.
Any idea what I might be missing? This would work in that I can assign different post processing scripts per printer if I can get this figured out.

michaelk 09-11-2014 02:47 PM

I have not found any documentation on multiple cups-pdf printers except by changing and recompiling the source code.

wpflum 09-12-2014 07:32 AM

It's in the Readme file of the source code and looking at the code I see it in there but I'm just not sure why it wont work. There is a section of the code that looks at the uri of the printer and if it's not the default uri it uses the name for the config file. Normal file is cups-pdf.conf but if you change the backend name to cups-pdf-newprinter it sees the difference in length and looks for cups-pdf-newprinter.conf. It just doesn't seem to work for me though. I'm going to dig into it deeper today and see what I'm missing.

wpflum 09-12-2014 09:51 AM

Figured it out!

When you create a printer the standard uri is cups-pdf:/ to make it look at another config file you add the additional name after the slash. If you want the config file to be cups-pdf-managers.conf you have to make the uri cups-pdf:/managers and then the program will use that config file.

I still have an issue with the file name so instead of having the different post processing scripts email to seperate email groups I'm going to make individual printers that print/email a specific report and then have the the backend of that printer rename the file to something appropriate and then email to a group. That way I get a pdf with a relevant name and get it sent to a group of people.

michaelk 09-12-2014 11:06 AM

Thanks for the update.

manuelfhp 03-21-2024 01:12 PM

Quote:

Originally Posted by wpflum (Post 5236832)
Figured it out!

When you create a printer the standard uri is cups-pdf:/ to make it look at another config file you add the additional name after the slash. If you want the config file to be cups-pdf-managers.conf you have to make the uri cups-pdf:/managers and then the program will use that config file.

I still have an issue with the file name so instead of having the different post processing scripts email to seperate email groups I'm going to make individual printers that print/email a specific report and then have the the backend of that printer rename the file to something appropriate and then email to a group. That way I get a pdf with a relevant name and get it sent to a group of people.


Thank you man!
After 10 years this info is really amazing ...
I was trying to find a way to get the printer name to run distinct post processing ......
I create my account here just to post this reply and say thank you!


All times are GMT -5. The time now is 12:54 AM.