Update lfs-uefi.txt
[linux_from_scratch_hints.git] / LFS-HINT-PDF-printer.txt
blobde0c3128bf884aab9dc7e4e520663f12beffe098
1 AUTHOR: Thomas de Roo <thomas@de-roo.org>
3 ACKNOWLEDGEMENTS:
5 DATE:2012-011-30
7 LICENSE: GNU Free Documentation License
9 SYNOPSIS:
11 Install a PDF-printer using CUPS and Ghostscript
13 DESCRIPTION:
15 This hint describes how you can install a PDF-printer on your (B)LFS-system. 
17 ATTACHMENTS:
19 http://download.adobe.com/pub/adobe/printerdrivers/win/all/ppdfiles/adobe.zip
21 PREREQUISITES:
23 This hint assumes you have already
24 - LFS
25 - Ghostscript
26 - CUPS
27 - wget
28 - unzip
29 - sudo
31 HINT:
33 - Download ans install the Adobe PostScript Printer Description-files:
34 wget http://download.adobe.com/pub/adobe/printerdrivers/win/all/ppdfiles/adobe.zip
35 unzip adobe.zip
36 sudo cp Adobe/ADIST5.PPD /usr/share/cups/model/distiller.ppd
38 - Make ps2pdf.cups:
39 sudo mkdir /usr/lib/cups/pdf
40 sudo ln -s /usr/bin/ps2pdfwr /usr/lib/cups/pdf/ps2pdf.cups
42 - create the backend:
43 sudo su -
44 cat > /usr/lib/cups/backend/pdf << "EOF"
45 #!/bin/sh
47 umask 002
48 PDFBIN=/usr/lib/cups/pdf/ps2pdf.cups
49 FILENAME=
50 # filename of the PDF File
51 PRINTTIME=`date +%Y-%m-%d_%H.%M.%S`
52 # no argument, prints available URIs
53 if [ $# -eq 0 ]; then
54         if [ ! -x "$PDFBIN" ]; then
55                 exit 0
56         fi
57         echo "direct pdf \"Unknown\" \"PDF Creator\""
58         exit 0
60 # case of wrong number of arguments
61 if [ $# -ne 5 -a $# -ne 6 ]; then
62         echo "Usage: pdf job-id user title copies options [file]"
63         exit 1
65 # get PDF directory from device URI, and check write status
66 PDFDIR=${DEVICE_URI#pdf:}
67 if [ ! -d "$PDFDIR" -o ! -w "$PDFDIR" ]; then
68         echo "ERROR: directory $PDFDIR not writable"
69         exit 1
71 # generate output filename
72 OUTPUTFILENAME=
73 if [ "$3" = "" ]; then
74         OUTPUTFILENAME="$PDFDIR/unknown.pdf"
75 else
76         if [ "$2" != "" ]; then
77                 OUTPUTFILENAME="$PDFDIR/$2-$PRINTTIME.pdf"
78         else
79                 OUTPUTFILENAME="$PDFDIR/$PRINTTIME.pdf"
80         fi
81         echo "PDF file: $OUTPUTFILENAME placed in: $PDFDIR" >> $LOGFILE
83 # run ghostscript
84 if [ $# -eq 6 ]; then
85         $PDFBIN $6 $OUTPUTFILENAME >& /dev/null
86 else
87         $PDFBIN - $OUTPUTFILENAME >& /dev/null
90 exit 0
91 EOF
92 exit
93 sudo chmod 755 /usr/lib/cups/backend/pdf
95 - Create the printer in CUPS:
96 (You can choose another path for /tmp, where the PDFs will be saved.)
97 sudo /usr/sbin/lpadmin -p PDF -v pdf:/tmp -E -P /usr/share/cups/model/distiller.ppd
99 - Restart CUPS:
100 sudo /etc/rc.d/init.d/cups restart
102 Now you have a printer "PDF" that writes its output to the /tmp directory.
105 ACKNOWLEDGEMENTS:
107 Based on http://www.linuxquestions.org/linux/answers/Applications_GUI_Multimedia/Setting_up_a_PDF_printer_in_CUPS_in_my_case_in_Slackware
109 CHANGELOG:
111     [2012-12-03]
112      * initial hint
113