How to quickly modify cups-pdf printer output folder setting?
Matthew Martinez
Longtime user of cups-pdf printer, I've always kept the default output folder setting: $HOME/PDF (or the identical /home/$USER/PDF).
Now I want to use a custom location for generated PDFs, but there is no output at all after modifying the config file (/etc/cups/cups-pdf.conf). Help?
12 Answers
The problem is with apparmor, not with cups or the virtual printer driver.
For any who want the convenience of 'one-touch' printing to pdf, the package can be installed by its older name:
sudo apt install cups-pdfOr by the newer:
sudo apt install printer-driver-cups-pdfThen to change the default output file destination, the config file may be edited:
sudo gedit /etc/cups/cups-pdf.conf (Use gksu or gksudo in place of sudo if preferred.)On the line:
Out ${HOME}/PDFChange the folder location as desired. Examples:
Out ${HOME}/Desktop Out ${HOME}/print/pdfs Out /home/username/pdf(If pasting an example line, use only one, like the original file.) Highlight the location part after the $, copy, then save the file and close it. Next, open the apparmor config file:
sudo gedit /etc/apparmor.d/usr.sbin.cupsdFind the two lines near the bottom with the old default path, {HOME}/PDF
@{HOME}/PDF/ rw,
@{HOME}/PDF/* rw,On each line, highlight everything between the @ and the trailing / and paste the new dirspec just copied. Inspect to be sure only the two paths were changed, and there are no missing or extra characters or spaces inserted. (Make a backup copy beforehand if unsure, and remember ctrlz undo is your friend.) Ex.
@{HOME}/Desktop/ rw,
@{HOME}/Desktop/* rw,Save, close and reboot, then test print. Should work.
0For those of you who have symlinked folders this will be helpful. In addition to setting up the above custom folder in /etc/cups/cups-pdf.conf do the following. In the 'K'Ubuntu 20.04 and above (the below explanation is implemented in Kubuntu 21.04), the default folder settings in the apparmor (/etc/apparmor.d/usr.sbin.cupsd) shouldn't be fiddled with. The defaults are good as below, retain them as is.
@{HOME}/[^.]*/{,**/} rw,
@{HOME}/[^.]*/** rw,In my case i have a separate ext4 partition /mnt/data/username for hosting the user directories such as Documents, Downloads, Music, Videos, Public, Templates, Pictures and VirtualBox VMs. I symlink these folders to /home/username/ example as below.
ln -s /mnt/data/username/Documents /home/username/DocumentsSo, for the cups-pdf print-to folder PDFs, i have mine in /mnt/data/username/Documents/PDFs.
My setup is as follows:
in /etc/cups/cups-pdf.conf set
Out ${HOME}/Documents/PDFsin /etc/apparmor.d/usr.sbin.cupsd leave it at defaults.
Run
sudo dpkg-configure apparmorand in the dialog box that appears, add /mnt/data/ (note the trailing '/') as additional ${HOMEDIRS) and hit OK. That's all that needs done.
I need my userdirs in /mnt/data/username/ as i share the very same folders with ArchLinux Gnome40 install with the same username and UID/GID.
For reference and understanding why, see the following links: