Home > Linux > PDF Printout over Samba and Cups

PDF Printout over Samba and Cups

Edit your Samba Configuration File and add the following Lines.

/etc/samba/smb.conf

[pdf]
path = /var/spool/samba
guest ok = Yes
printable = Yes
print command = ( lpr -r -P pdf -o raw %s ) &
lpq command = ( lpq -P pdf ) &
lprm command = ( lprm -P pdf %j ) &
printer name = PDF Printer
comment = PDF Printer
writable = No
public = Yes
browsable = Yes
create mode = 0666
printer = pdf


Create the following File, importend it must be made executable.
/usr/lib/cups/backend/pdf

#!/bin/sh
#
PDFBIN=/usr/lib/cups/pdf/ps2pdf.cups
MAILBIN=/usr/lib/cups/pdf/sendpdf
FILENAME=
#filename of the PDF File
PRINTTIME=`date +%Y-%m-%d_%H.%M.%S`
#no argument, prints available URIs
if [ $# -eq 0 ]; then
if [ ! -x „$PDFBIN“ ]; then
exit 0
fi
echo „direct pdf \“Unknown\“ \“PDF Creator\““
exit 0
fi
#case of wrong number of arguments
if [ $# -ne 5 -a $# -ne 6 ]; then
echo „Usage: pdf job-id user title copies options [file]“
exit 1
fi
#get PDF directory from device URI, and check write status
PDFDIR=${DEVICE_URI#pdf:}
if [ ! -d „$PDFDIR“ -o ! -w „$PDFDIR“ ]; then
echo „ERROR: directory $PDFDIR not writable“
exit 1
fi
#generate output filename
OUTPUTFILENAME=
if [ „$3“ = „“ ]; then
OUTPUTFILENAME=“$PDFDIR/unknown.pdf“
else
if [ „$2“ != „“ ]; then
OUTPUTFILENAME=“$PDFDIR/$2-$PRINTTIME.pdf“
else
OUTPUTFILENAME=“$PDFDIR/$PRINTTIME.pdf“
fi
echo „PDF file: $OUTPUTFILENAME placed in: $PDFDIR“ >> $LOGFILE
fi
#run ghostscript
if [ $# -eq 6 ]; then
$PDFBIN $6 $OUTPUTFILENAME >& /dev/null
else
$PDFBIN – $OUTPUTFILENAME >& /dev/null
fi

if [ „$2“ != „“ ]; then
$MAILBIN $2 $OUTPUTFILENAME
rm -f $OUTPUTFILENAME
fi
exit 0

Download destiller.ppd and copy it to the following Location and make it executable.
/usr/share/cups/model/

Create the following Shellscript. Make the File executable.
/usr/bin/pdfcreator.sh

#!/bin/bash
date=`date +%d%m%Y_%H%M`
/usr/bin/ps2pdf /var/spool/samba/$1 /tmp/$date.pdf
mv /tmp/$date.pdf /share/pdf/
rm /var/spool/samba/$1

Create the following Directory.
/usr/lib/cups/pdf/

Copy ps2pdf.cups to this Directory and make it executable.

Create the following executable Shellscript.
/usr/lib/cups/pdf/sendpdf

#!/usr/bin/perl
use MIME::Entity;
$to = $ARGV[0];
$to_domain = „\@yourdomain.com“;
$to = $to . $to_domain;
$pdffile = $ARGV[1];
$mailpipe = ‚| /usr/lib/sendmail -t -oi‘;
$from = „root“;
$subject =“PDF Datei“;
$inhalt = „Ihr PDF Ausdruck“;
my $mail = MIME::Entity->build( Type => ‚text/plain‘,
From => $from,
To => $to,
Subject => $subject,
Data => $inhalt
);
$mail->attach( Path => $pdffile,
Type => ‚application/pdf‘,
Encoding => ‚base64‘
);
open MAIL, „$mailpipe“ or die „Could not open mailpipe \“$mailpipe\“ !\n“;
$mail->print(\*MAIL);
close MAIL;

Now restart your Samba and your Cups Server.

Configurate your Printer in Cups with your Browser.

Mostly located under http://yourserver:631

KategorienLinux Tags: ,
  1. Bisher keine Kommentare
  1. Bisher keine Trackbacks
Du musst Dich anmelden um einen Kommentar zu schreiben