--- cupsys-1.3.0.orig/debian/local/filters/textonly +++ cupsys-1.3.0/debian/local/filters/textonly @@ -0,0 +1,124 @@ +#!/bin/bash +## Copyright (C) 2003-2006 Red Hat, Inc. +## Copyright (C) 2003-2006 Tim Waugh +## Changed on 2007/05/17, Opher Shachar, LADPC Ltd. +## Added support for page-ranges option. +## Added page accounting. + +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. + +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. + +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +if [ $# == 0 ]; then + echo >&2 "ERROR: $0 job-id user title copies options [file]" + exit 1 +fi + +# Extract the papersize +SENDFF=`grep '^\*DefaultSendFF' "$PPD" | cut -d\ -f2` +COPIES=1 +if [ $# -ge 4 ]; then + COPIES="$4" +fi + +if [ "$COPIES" -gt 1 ] && [ $# -lt 6 ]; then + unset TMPFILE + trap -- 'rm -f "$TMPFILE"' EXIT + TMPFILE=$(mktemp ${TMPDIR:-/tmp}/textonly.XXXXXX) + cat > "$TMPFILE" +else + TMPFILE="$6" +fi + +PR=${5#*page-ranges=} +# Do options specify page-ranges? +if [[ "$PR" != "$5" ]]; then + PR=${PR%% *} +else + #unset PR + PR=1-999999 +fi + +if [[ "$PR" ]]; then + TMPFILE2=$(mktemp ${TMPDIR:-/tmp}/textonly2.XXXXXX) + pagenum=0 + EOF= + { + while [[ "$PR" ]]; do + pl=${PR%%,*} ;# take first subrange + PR=${PR#$pl};PR=${PR#,} ;# remove from range list + pu=${pl#*-} ;# extract upper and lower + pl=${pl%-*} ;# pages of subrange + # Allows interpreting 0-5,3-10 as 1-5,6-10 rejects 5-1 or 1- + (( pagenum >= pl )) && pl=$(( pagenum + 1 )) + (( pl > pu )) && continue + + # Loop reading pages until at or over lower page of subrange. + while read -d `echo -ne '\f'` -r; do + (( pagenum++ )) + (( pagenum == pl )) && break + done + # Did we reach lower page of subrange or EOF? + if (( pagenum < pl )); then + [[ ! "$REPLY" ]] && break ;# empty last page - we're done. + (( pagenum++ )) + EOF=y + fi + # Output page and report to page log + if (( pagenum == pl )); then + echo -n "${REPLY}" >>"$TMPFILE2" + # If EOF then page has no final FF + [[ ! "$EOF" ]] && echo -ne '\f' >>"$TMPFILE2" + echo "PAGE: $pagenum $COPIES" >&2 + fi + [[ "$EOF" ]] && break + # Is the current subrange a single page? + (( pagenum == pu )) && continue + while read -d `echo -ne '\f'` -r; do + (( pagenum++ )) + echo -ne "${REPLY}\f" >>"$TMPFILE2" + echo "PAGE: $pagenum $COPIES" >&2 + (( pagenum == pu )) && break + done + # Could be that we reached EOF before page boundry + if (( pagenum < pu )); then + if [[ "$REPLY" ]]; then + (( pagenum++ )) + echo -n "${REPLY}" >>"$TMPFILE2" + echo "PAGE: $pagenum $COPIES" >&2 + fi + break + fi + done + } <"$TMPFILE" +else + TMPFILE2="$TMPFILE" + pc=$(grep -co `echo -ne '\f'` "$TMPFILE2") + pc=$(( pc * $COPIES )) + echo "PAGE: $pc" >&2 +fi + +while [ "$COPIES" -gt 0 ]; do + # Just translate LF->CRLF at the moment, until the PPD has options added. + sed -e 's/$/'`echo -ne '\r'`'/g' "$TMPFILE2" + + if [ "$SENDFF" == "True" ] + then + echo -ne \\14 + fi + + COPIES=$(($COPIES - 1)) +done +# Cleanup +[[ "$TMPFILE" != "$TMPFILE2" ]] && rm -f "$TMPFILE2" +exit 0 --- cupsys-1.3.0.orig/debian/local/filters/oopstops +++ cupsys-1.3.0/debian/local/filters/oopstops @@ -0,0 +1,184 @@ +#!/usr/bin/perl -w +# =============================================================================== +# oopstops prefilter to sanitize PostScript jobs generated by OpenOffice 2.x +# ------------------------------------------------------------------------------- +# 1.00 - 2007-03-17/Bl +# First implementation +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# Description: +# ------------ +# OpenOffice as of version 2.x has built-in CUPS support, parses +# the user selectable options in the printer's PPD and inserts the respecitve +# PostScript code into the PostScript job. However, it does not insert all +# defined defaults nor the JCL settings, but it does honour the JobPatchFile +# keyword. In addition, if a default setting in the PPD does not correspond +# to one of the choices listed in the respective UI block, OpenOffice silently +# selects the first choice (NOTE: this cannot be corrected by this filter). +# Moreover, the page related features are inserted into the page setup section +# of the first page. This violates the page independence and prohibits successful +# working of job attivutes like number-up or same-up. +# +# We therefore modify the PostScript job as follows: +# - any JobPatchFile features are discaarded, as they are re-inserted by the +# pstops filter. +# - the first page's page setup is moved to the end of the general setup section +# (in fact, the respective comments are moved instead). + + + +use IO::Handle; + +# +# Check the arguments +# +die ("ERROR: wrong number of arguments\n") if (scalar @ARGV < 5); + +$jobid = $username = $title = $copies = $options = undef; +$jobid = shift; # Job ID +$username = shift; # Job requesting user name +$title = shift; # Job title +$copies = shift; # Number of requested copies +$options = shift; # Textual representation of job attributes +$psfile = shift; # read from file ? + + +# +# Normalize options string +# +$options =~ s/^\s+//; +$options =~ s/\s+$//; +$options = ' ' . $options . ' '; + +# +# Check from where to read +# +if (defined $psfile) +{ + open (FILI, "<$psfile") || die ("ERROR: $psfile: $!\n"); +} +else +{ + open (FILI, "<&STDIN") || die ("ERROR: STDIN: $!\n"); +} + +# STDOUT->autoflush (1); + +# +# Parse the input until and including the page setup of the first page +# and relocate the setup features to the end of the setup section. +# +@feature = (); +$within_feature = 0; +$feature_name = ''; +$saw_page = 0; +@pagehead = (); + +while () +{ + if (/^\[\{/) + { + push (@feature, $_); + $_ = ; + if (/^%%BeginFeature:\s+\*(\S+)\s+/) + { + $feature_name = $1; + push (@feature, $_); + $within_feature = 1; + next; + } + else + { + print STDOUT shift @feature; + print STDOUT; + } + next; + } + if (/^%%EndFeature/) + { + if ($within_feature) + { + push (@feature, $_); + $_ = ; + if (/^\}\s+stopped\s+cleartomark/) + { + push (@feature, $_); + } + else + { + $next_line = $_; + } + if ($feature_name eq 'JobPatchFile') + { + @feature = (); # discard the job patch file(s) + } + $within_feature = 0; + print STDOUT $next_line if (defined $next_line && $next_line); + } + else + { + print STDOUT; + } + next; + } + next if (/^%%EndSetup/); + if (/^%%Page:/) + { + $saw_page = 1; + push (@pagehead, $_); + next; + } + if (/^%%EndPageSetup/) + { + push (@pagehead, $_); + if (scalar @feature > 0) + { + while (my $line = shift @feature) + { + print STDOUT $line; + } + $feature_name = ''; + } + print STDOUT "%%EndSetup\n"; + while (my $line = shift @pagehead) + { + print STDOUT $line; + } + $saw_page = 0; + last; + } + next if (/^<< \/NumCopies null /); # skip the copies hack because of Ghostscript quirks + if ($within_feature) + { + push (@feature, $_); + } + elsif ($saw_page) + { + push (@pagehead, $_); + } + else + { + print STDOUT; + } +} + +# +# Now copy the rest without further interpretation +# +while () +{ + print STDOUT; +} + +close (FILI) if (defined $psfile); + + --- cupsys-1.3.0.orig/debian/local/filters/pdftops +++ cupsys-1.3.0/debian/local/filters/pdftops @@ -0,0 +1,167 @@ +#!/usr/bin/perl -w +# pdftops.pl - wrapper script for xpdf's pdftops utility to act as a CUPS filter +# ============================================================================== +# 1.00 - 2004-10-05/Bl +# Initial implementation +# +# Copyright: Helge Blischke / SRZ Berlin 2004 +# This program is free seoftware and governed by the GNU Public License Version 2. +# +# Description: +# ------------ +# This program wraps the pdftops utility from the xpdf 3.00 (and higher) suite +# to behave as a CUPS filter as a replacement for the original pdftops filter. +# +# The main purpose of this approach is to keep the properties of a PDF to be +# printed as undesturbed as possible, especially with respect to page size, +# scaling, and positioning. +# +# The pdftops utility reads a configuration file 'pdftops.conf' in the +# CUPS_SERVERROOT directory, which must exist but may be empty. The sample +# configuration file accompanying this program sets the defaults which +# seem plausible to me with respect to high end production printers. +# +# To give the user highest possible flexibility, this program accepts and +# evaluates a set of job attributes special to this filter, which are +# described below: +# +# pdf-pages=, +# expands to the -f and -l options of pdftops +# to select a page range to process. This is independent +# of the page-ranges attribute and may significantly +# increase throughput when printing page ranges. +# Either of these numbers may be omitted. +# +# pdf-paper= +# pdf-paper=x +# may be one of letter, legal , A4, A3, or match; +# and are the paper width and height +# in printers points (1/72 inch). This expands to +# either the -paper or the -paperh and -paperw options +# of pdftops +# +# pdf-opw= +# pdf-upw= +# expand to the -opw and -upw options of pdftops, +# respectively and permit printing of password +# protected PDFs. +# +# pdf-