CUPS printing system is more or less built around postscript, so it's pretty much unavoidable that PostScript files, or at least postscript output will be involved at some point, and PDFs aren't much different than PostScript files, as you note. (CUPS-PDF simply calls Ghostscript's ps2pdf to convert PostScript to PDF.)
Well, playing around, I did more or less figure out how to this, printing to PDF then use calibre for conversion afterwards.
Of course, (1) you'd get identical results simply printing to PDF in the normal way and then importing/converting using calibre's GUI, and (2) given your situation, with a textbook, I'm about 99% sure you'd be better off just printing to PDF and leaving it as a PDF. (Ideally there should be options for setting the page sizes to a PDF to a smaller size so it looks better on your screen.)
However, if you really want to, here's what I did. This may vary a bit depending on Linux distribution.
- Install the cups-pdf pacakge, and install a "Generic-CUPS-PDF-Printer" in the usual way. (The details here would depend on distribution, but I doubt you'll have trouble finding instructions for this if you google it. (Note, I think you need a real virtual printer, and not just a PDF option under "Print to File".)
- Create a post-processing script. You might, for example, name it /home/<yourname>/bin/cups-pdf_script.sh -- mine looks like this:
Code:
#!/bin/bash
xhost +local
CURRENT_PDF="${1}"
CURRENT_USER="${2}"
DISPLAY=:0.0
export DISPLAY
XAUTHORITY=/home/${CURRENT_USER}/.Xauthority
export XAUTHORITY
PDFNAME="$(zenity --file-selection --save --confirm-overwrite --title 'Save PDF as...')"
mv "$CURRENT_PDF" "$PDFNAME"
if zenity --question --text "Create ePub?" ; then
EPUBNAME="$(zenity --file-selection --save --confirm-overwrite --title 'Save EPUB as...')"
ebook-convert "$PDFNAME" "$EPUBNAME"
fi
(This requires the zenity program for GTK dialog-boxes, which usually comes with GNOME, as well as the ebook-convert program which comes with calibre. Basic idea is stolen from here.)
- Make that file executable:
Code:
chmod a+x /home/<yourname>/bin/cups-pdf_script.sh
- Now make a copy of your cups-pdf settings:
Code:
sudo cp /etc/cups/cups-pdf.conf{,-old}
And then edit them:
Code:
sudo vim /etc/cups/cups-pdf.conf
(For "vim", substitute your favorite text editor: gedit, nano, emacs, etc., as you prefer.)
- Find the line:
And change it to:
Code:
PostProcessing /home/<yourname>/bin/cups-pdf_script.sh
(Be sure to remove the # at the beginning.)
- Restart the CUPS Daemon, which depending on distribution may be done either with:
Code:
sudo /etc/init.d/cupsd restart
Or with:
Code:
sudo /etc/rc.d/cups restart
Now when you print to the Generic CUPS-PDF printer, after it asks you where to save the PDF, it'll follow up by asking if you want to create an ePub as well, and if you click yes, and pick a location, it will call calibre to convert the PDF.
This worked for me on Arch Linux running GNOME. It may need to be tweaked for your distribution or set up. You may also want to customize the script, including the options for ebook-convert
(see here).
But again, I'm not sure how that's better than simply using calibre's GUI, or using a properly sized PDF.