0

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?

1
  • Please don't create meaningless and useless tags like destination, that make no sense within the context of this site
    – muru
    Aug 4 '20 at 4:33
1

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-pdf

Or by the newer:

sudo apt install printer-driver-cups-pdf

Then 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}/PDF

Change 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.cupsd

Find 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.

0
0

For 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/Documents

So, 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/PDFs

in /etc/apparmor.d/usr.sbin.cupsd leave it at defaults. Run

sudo dpkg-configure apparmor

and 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:

http://manpages.ubuntu.com/manpages/trusty/en/man5/apparmor.d.5.html

https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1701831.html

https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1701828.html

https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/447292

https://forums.whonix.org/t/apparmor-exception-for-shared-folder-on-guess/656

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.