LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-07-2024, 09:32 PM   #1
Kenan
LQ Newbie
 
Registered: May 2024
Posts: 5

Rep: Reputation: 0
CUPS PDF output file name changing


Is there a way to change the CUPS PDF printer output file name? I use Ubuntu and most recent CUPS.

I tried a script, cups-pdf.conf file, lp options but I was not able to find a way.

If you have a solution for this please let me know
 
Old 05-08-2024, 10:50 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,760

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
I have not played with cups-pdf in awhile but you should be able to add a post-processing script in the cups-pdf.conf file.

Quote:
### Key: PostProcessing (config, lptoptions)
## postprocessing script that will be called after the creation of the PDF
## as arguments the filename of the PDF, the username as determined by
## CUPS-PDF and the one as given to CUPS-PDF will be passed
## the script will be called with user privileges
## set this to an empty value to use no postprocessing
 
1 members found this post helpful.
Old 05-08-2024, 09:19 PM   #3
Kenan
LQ Newbie
 
Registered: May 2024
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by michaelk View Post
I have not played with cups-pdf in awhile but you should be able to add a post-processing script in the cups-pdf.conf file.
I have already written a script. So should I just paste it with the starting Key, "PostProcessing"? How can I use my script for this?

#PDFVer 1.4

### Key: PostProcessing (config, lptoptions)
## postprocessing script that will be called after the creation of the PDF
## as arguments the filename of the PDF, the username as determined by
## CUPS-PDF and the one as given to CUPS-PDF will be passed
## the script will be called with user privileges
## set this to an empty value to use no postprocessing
### Default: <empty>

PostProcessing



My Script:

#!/bin/bash
# /etc/cups/generate_pdf_filename.sh

# Get current user login
USER=$(whoami)

# Get hostname
HOSTNAME=$(hostname)

# Generate timestamp
TIMESTAMP=$(date +'%Y-%m-%d_%H-%M-%S')

# Construct filename
FILENAME="${HOME}/PDF/stdntrns_${USER}_${HOSTNAME}_${TIMESTAMP}.pdf"
 
Old 05-09-2024, 12:42 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,760

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
It seems like you copied the script from another forum/thread that did not appear to work.

In another thread it appeared like it was not possible to create another file name via the cups configuration file since Ubuntu developers changed the cups-pdf code. I have not looked at the source code. I don't see any option with cups-pdf from debian repository either.

Change cups-pdf.conf to make the script executable. I don't necessarily like /etc/ for executable scripts.
Quote:
PostProcessing /path/to/generate_pdf_filename.sh
untested.
Quote:
#!/bin/bash

USER=$2 # 2nd command line argument passed is user name
OLD_FILE=$1 # 1st command line argument file name as generated by cups-pdf
HOSTNAME=$(hostname)
TIMESTAMP=$(/usr/bin/date +'%Y-%m-%d_%H-%M-%S')
mv "$OLD_FILE" "/home/$USER/PDF/stdntrns_${USER}_${HOSTNAME}_${TIMESTAMP}.pdf"

Last edited by michaelk; 05-10-2024 at 03:47 AM.
 
Old 05-09-2024, 11:53 PM   #5
Kenan
LQ Newbie
 
Registered: May 2024
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by michaelk View Post
It seems like you copied the script from another forum/thread that did not appear to work.

In another thread it appeared like it was not possible to create another file name via the cups configuration file since Ubuntu developers changed the cups-pdf code. I have not looked at the source code. I don't see any option with cups-pdf from debian repository either.

Change cups-pdf.conf to make the script executable. I don't necessarily like /etc/ for executable scripts.


untested.
I am the one who asks this question for different forums. The script was written by me. So I will try on PostProssesing. Can you provide more information about this?
The question is when I change the cups-pdf.conf file as you stated and with my script. Is there anything else should I do? Like -lp options or something like that? Or you said that one right script and cups-pdf.conf are enough for this. Right?
 
Old 05-10-2024, 03:49 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,760

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
My script and posted changes to the conf file should be enough.
 
Old 05-10-2024, 12:14 PM   #7
Kenan
LQ Newbie
 
Registered: May 2024
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by michaelk View Post
My script and posted changes to the conf file should be enough.
I will let you know. Thank you so much, Michael.
 
Old Yesterday, 01:23 AM   #8
Kenan
LQ Newbie
 
Registered: May 2024
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by michaelk View Post
My script and posted changes to the conf file should be enough.
Unfortunately, it did not work. Are you sure about the script you send me?


#!/bin/bash

USER=$2 # 2nd command line argument passed is user name
OLD_FILE=$1 # 1st command line argument file name as generated by cups-pdf
HOSTNAME=$(hostname)
TIMESTAMP=$(/usr/bin/date +'%Y-%m-%d_%H-%M-%S')
mv "$OLD_FILE" "/home/$USER/PDF/stdntrns_${USER}_${HOSTNAME}_${TIMESTAMP}.pdf"
 
Old Yesterday, 07:14 AM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,760

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
I tested it using debian versus Ubuntu but I am fairly certain it will work. Did you remove the leading '#' in front of postprocessing? Did you use the full path to your script and is it executable?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to combine a .txt file and a .pdf file into one .pdf file rblampain Programming 1 01-11-2023 04:51 AM
[SOLVED] lp doesn't print file to pdf directory after installing cups-pdf using synaptic mrcj Debian 1 10-09-2013 07:18 PM
How to search contents of multiple pdf files and return the pdf's file name? Hoxygen232 Linux - Newbie 4 04-28-2013 09:39 AM
My cups-pdf pdf printer is not working. sgsawant Linux - Software 1 03-16-2010 02:35 AM
How to wget a webpage, and save as PDF (like cups-pdf) ? frenchn00b Programming 3 11-18-2008 03:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration