WinFuture-Forum.de: Script Zum A5 Broschüre / Booklet Ausdrucken - WinFuture-Forum.de

Zum Inhalt wechseln

Nachrichten zum Thema: Entwicklung
Seite 1 von 1

Script Zum A5 Broschüre / Booklet Ausdrucken


#1 _Fenix_

  • Gruppe: Gäste

geschrieben 19. Januar 2009 - 22:47

Hi,
anbei ein kleines Script, das normale PDF Dateien so umwandelt, dass man sie als Din A5 Broschüren drucken kann.
Man braucht dazu:
pdftops aus xpdf,
pstops aus psutils,
ps2pdf aus ghostscript

Bedienung:
./scriptname dateiname.pdf simplex
-> erstellt aus dateiname.pdf eine Datei dateiname-front.pdf mit den Vorderseiten der Blätter und eine Datei dateiname-back.pdf mit den Rückseiten. Die PDFs können dann getrennt ausgedruckt werden und man kann für Drucker ohne Duplex per Hand zwischendurch umsortieren.
./scriptname dateiname.pdf duplex
-> erstellt aus dateiname.pdf eine Datei dateiname-duplex.pdf, die die PDF passend als A5 Broschüre beinhaltet.

#!/bin/bash

#
# Copyright (c) 2009, Jan Bessai
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#	 * Redistributions of source code must retain the above copyright
#	   notice, this list of conditions and the following disclaimer.
#	 * Redistributions in binary form must reproduce the above copyright
#	   notice, this list of conditions and the following disclaimer in the
#	   documentation and/or other materials provided with the distribution.
#	 * Neither the name of Jan Bessai nor the
#	   names of its contributors may be used to endorse or promote products
#	   derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY Jan Bessai ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL Jan Bessai BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#


FILE=`basename $1 .pdf`
FILEPS="$FILE.ps"

if [[ -z "$1" || -z "$2" || ( "$2" != "duplex" && "$2" != "simplex" ) ]]
then
	echo "usage: $0 filename mode" >&2
	echo "where mode is duplex or simplex" >&2
	exit -1
elif [[ ! -e $1 || ! -r $1 ]]
then
	echo "error: cannot read $FILE" >&2
	exit -1
elif [ $2 = "duplex" ]
then
	FILEDUPLEXPS="$FILE-duplex.ps"
	FILEDUPLEX="$FILE-duplex.pdf"

	if [[ -e $FILEPS || -e $FILEDUPLEXPS || -e $FILEDUPLEX ]]
	then
		echo "error: Make sure $FILEPS $FILEDUPLEXPS and $FILEDUPLEX are not existing!" >&2
		exit -1
	else

		pdftops -paper A4 $1 $FILEPS
		pstops -pa4 "4:[email protected](21cm,0)[email protected](21cm,14.85cm),[email protected](21cm,0)[email protected](21cm,14.85cm)" $FILEPS $FILEDUPLEXPS
		ps2pdf -sPAPERSIZE=a4 $FILEDUPLEXPS $FILEDUPLEX

		rm -f $FILEPS
		rm -f $FILEDUPLEXPS
	fi	
	exit 0
elif [ $2 = "simplex" ]
then
	FILEFRONTPS="$FILE-front.ps"
	FILEFRONT="$FILE-front.pdf"
	FILEBACKPS="$FILE-back.ps"
	FILEBACK="$FILE-back.pdf"

	if [[ -e $FILEPS || -e $FILEFRONTPS || -e $FILEBACKPS || -e $FILEFRONT || -e $FILEBACK ]]
	then
		echo "error: Make sure $FILEPS $FILEFRONTPS $FILEBACKPS $FILEFRONT and $FILEBACK are not existing!" >&2
		exit -1
	else
		pdftops -paper A4 $1 $FILEPS

		pstops -pa4 "4:[email protected](21cm,0)[email protected](21cm,14.85cm)" $FILEPS $FILEFRONTPS
		pstops -pa4 "4:[email protected](21cm,0)[email protected](21cm,14.85cm)" $FILEPS $FILEBACKPS

		ps2pdf -sPAPERSIZE=a4 $FILEFRONTPS $FILEFRONT
		ps2pdf -sPAPERSIZE=a4 $FILEBACKPS $FILEBACK
		
		rm -f $FILEPS
		rm -f $FILEFRONTPS
		rm -f $FILEBACKPS
	fi

	exit 0
fi


Viel Erfolg und Spaß damit :)

Gruß,
Fenix

Dieser Beitrag wurde von Fenix bearbeitet: 11. September 2011 - 16:56

0

Anzeige



Thema verteilen:


Seite 1 von 1

1 Besucher lesen dieses Thema
Mitglieder: 0, Gäste: 1, unsichtbare Mitglieder: 0