docplastic
August 26th, 2006, 07:42 PM
Purpose: to emulate some of the booklet printing functions of the Windows FinePrint utility (http://www.fineprint.com/), i.e. trying to save a few sheets of paper.
A. Command Line Version (there is also a "point-and-click" version to print from the Nautilus File Browser, see B. paragraph bellow)
1. Copy and paste the following code it into a text file named fp
2. Make it executable with the command: chmod 755 fp
3. Copy that file to a directory in your PATH. You may want to copy it into your own private /bin dir created with the command: mkdir -p /home/`whoami`/bin. If you name it /bin It will be automatically added to your environment the next time your system boots.
4. Print the file with the command: fp filename.ps
5. Remember that any printed file in Linux starts its life as a .ps file, so all what you have to do is, from any program, select "Print", choose any printer, click the "print to file" check mark and print it into a .ps file.
#!/bin/bash
#
# fp is a fineprint-like utility to duplex print postscript - .ps -
# files into A5 booklets.
#
# Tested with HP, Epson and Canon InkJets.
# It prints front and rear, even in plain (non duplex) printers.
#
# It will accept a .ps file and modify it (compressing
# and rotating each two A4 pages into a single A4 sheet).
#
# It will print front (odd) pages and then wait for you to
# reinsert the printed paper. Once paper reinserted it will
# print rear (even) pages.
#
# In the end you may fold the printed sheets to form an A5 booklet;
#
# Copyright © 2005-2008 by J. Antas.
# Licensed under a GPL 2.0 License (full text available
# at http://www.gnu.org/copyleft/gpl.html)
#
if !((test -f /usr/bin/psbook) && (test -f /usr/bin/pstops)) ; then
echo -e "\nYou need to (re)install the 'psutils' package, " ;
echo -e "Try installing it with 'sudo apt-get install psutils'\n" ;
exit 62;
fi;
if [ -z "$1" ] ; then
echo -e "\nUsage: `basename $0` filename.ps\n";
exit 64;
fi;
if [ -f "$1" ] ; then
echo -e "Script `basename $0` started...\n" ;
#
/usr/bin/psbook $1 | /usr/bin/pstops -q -p a4
"4:1L@0.7(21.0cm,14.95cm)+0L@0.7(21.0cm,0.6cm),3L@0 .7(21.0cm,14.95cm)+2L@0.7(21.0cm,0.6cm)"
> "tmp-$1";
echo -e "\nPrinting to the default printer: odd pages first...";
# printer def: -P PrinterName as seen using: lpstat -a
# If no printer it will use the default printer
# You may also set the PRINTER env variable with: export PRINTER=tp0
/usr/bin/lpr -o page-set=odd -o outputorder=reverse "tmp-$1";
echo -n "...after printing this batch, load the paper back in and hit
<enter>";
read dummy;
echo -e "\nNow printing even pages...\n";
/usr/bin/lpr -o page-set=even "tmp-$1";
echo -e "Done.\n";
/bin/rm "tmp-$1";
else
echo -e "\nFile '$1' was not found. Program aborted\n";
exit 66;
fi;
exit 0;
#end of code
UPADATE: 2008.02.22 - Attached bellow is code to "point-and-click" print from the (Nautilus) File Browser
B. "Point-and-Click" Version:
This version will let you print directly from the Nautilus File Browser by right clicking at the selected .ps file.
6. Copy and paste the following code it into a text file named fprint
7. Make it executable: chmod 755 fprint
8. Copy that file to /home/`whoami`/.gnome2/nautilus-scripts
9. Start printing by right clicking at the desired .ps file and selecting fprint from the right click drop-down menu
10. Remember that any printed file in Linux starts its life as a .ps file, so all what you have to do is, from any program, select "Print", choose any printer, click the "print to file" check mark and print it into a .ps file.
#!/bin/bash
#
# fprint is a fineprint-like utility to duplex print postscript - .ps -
# files into A5 booklets.
#
# Tested with HP, Epson and Canon InkJets.
# It prints front and rear, even in plain (non duplex) printers.
#
# It will accept a .ps file and modify it (compressing
# and rotating each two A4 pages into a single A4 sheet).
#
# It will print front (odd) pages and then wait for you to
# reinsert the printed paper. Once paper reinserted it will
# print rear (even) pages.
#
# In the end you may fold the printed sheets to form an A5 booklet;
#
# Copyright © 2005-2008 by J. Antas.
# Licensed under a GPL 2.0 License (full text available
# at http://www.gnu.org/copyleft/gpl.html)
#
file=$(echo $NAUTILUS_SCRIPT_SELECTED_URIS | sed -e 's/file:\/\///g' -e 's/\%20/\\ /g') ;
dir=$(echo $NAUTILUS_SCRIPT_CURRENT_URI | sed -e 's/file:\/\///g' -e 's/\%20/\\ /g') ;
tmpfile="$file~"
/usr/bin/psbook "$file" | /usr/bin/pstops -q -p a4 "4:1L@0.7(21.0cm,14.95cm)+0L@0.7(21.0cm,0.6cm),3L@0 .7(21.0cm,14.95cm)+2L@0.7(21.0cm,0.6cm)" > "$tmpfile";
/usr/bin/lpr -o page-set=odd -o outputorder=reverse "$tmpfile";
if zenity --question --text "Printing $file\nPrinting odd pages first,\nWhen finished load the paper back in and click OK"; then
/usr/bin/lpr -o page-set=even "$tmpfile";
#zenity --info --text "Done.";
fi ;
killall zenity;
[ -f "$tmpfile" ] && /bin/rm "$tmpfile";
#end of code
Enjoy,
J. Antas
A. Command Line Version (there is also a "point-and-click" version to print from the Nautilus File Browser, see B. paragraph bellow)
1. Copy and paste the following code it into a text file named fp
2. Make it executable with the command: chmod 755 fp
3. Copy that file to a directory in your PATH. You may want to copy it into your own private /bin dir created with the command: mkdir -p /home/`whoami`/bin. If you name it /bin It will be automatically added to your environment the next time your system boots.
4. Print the file with the command: fp filename.ps
5. Remember that any printed file in Linux starts its life as a .ps file, so all what you have to do is, from any program, select "Print", choose any printer, click the "print to file" check mark and print it into a .ps file.
#!/bin/bash
#
# fp is a fineprint-like utility to duplex print postscript - .ps -
# files into A5 booklets.
#
# Tested with HP, Epson and Canon InkJets.
# It prints front and rear, even in plain (non duplex) printers.
#
# It will accept a .ps file and modify it (compressing
# and rotating each two A4 pages into a single A4 sheet).
#
# It will print front (odd) pages and then wait for you to
# reinsert the printed paper. Once paper reinserted it will
# print rear (even) pages.
#
# In the end you may fold the printed sheets to form an A5 booklet;
#
# Copyright © 2005-2008 by J. Antas.
# Licensed under a GPL 2.0 License (full text available
# at http://www.gnu.org/copyleft/gpl.html)
#
if !((test -f /usr/bin/psbook) && (test -f /usr/bin/pstops)) ; then
echo -e "\nYou need to (re)install the 'psutils' package, " ;
echo -e "Try installing it with 'sudo apt-get install psutils'\n" ;
exit 62;
fi;
if [ -z "$1" ] ; then
echo -e "\nUsage: `basename $0` filename.ps\n";
exit 64;
fi;
if [ -f "$1" ] ; then
echo -e "Script `basename $0` started...\n" ;
#
/usr/bin/psbook $1 | /usr/bin/pstops -q -p a4
"4:1L@0.7(21.0cm,14.95cm)+0L@0.7(21.0cm,0.6cm),3L@0 .7(21.0cm,14.95cm)+2L@0.7(21.0cm,0.6cm)"
> "tmp-$1";
echo -e "\nPrinting to the default printer: odd pages first...";
# printer def: -P PrinterName as seen using: lpstat -a
# If no printer it will use the default printer
# You may also set the PRINTER env variable with: export PRINTER=tp0
/usr/bin/lpr -o page-set=odd -o outputorder=reverse "tmp-$1";
echo -n "...after printing this batch, load the paper back in and hit
<enter>";
read dummy;
echo -e "\nNow printing even pages...\n";
/usr/bin/lpr -o page-set=even "tmp-$1";
echo -e "Done.\n";
/bin/rm "tmp-$1";
else
echo -e "\nFile '$1' was not found. Program aborted\n";
exit 66;
fi;
exit 0;
#end of code
UPADATE: 2008.02.22 - Attached bellow is code to "point-and-click" print from the (Nautilus) File Browser
B. "Point-and-Click" Version:
This version will let you print directly from the Nautilus File Browser by right clicking at the selected .ps file.
6. Copy and paste the following code it into a text file named fprint
7. Make it executable: chmod 755 fprint
8. Copy that file to /home/`whoami`/.gnome2/nautilus-scripts
9. Start printing by right clicking at the desired .ps file and selecting fprint from the right click drop-down menu
10. Remember that any printed file in Linux starts its life as a .ps file, so all what you have to do is, from any program, select "Print", choose any printer, click the "print to file" check mark and print it into a .ps file.
#!/bin/bash
#
# fprint is a fineprint-like utility to duplex print postscript - .ps -
# files into A5 booklets.
#
# Tested with HP, Epson and Canon InkJets.
# It prints front and rear, even in plain (non duplex) printers.
#
# It will accept a .ps file and modify it (compressing
# and rotating each two A4 pages into a single A4 sheet).
#
# It will print front (odd) pages and then wait for you to
# reinsert the printed paper. Once paper reinserted it will
# print rear (even) pages.
#
# In the end you may fold the printed sheets to form an A5 booklet;
#
# Copyright © 2005-2008 by J. Antas.
# Licensed under a GPL 2.0 License (full text available
# at http://www.gnu.org/copyleft/gpl.html)
#
file=$(echo $NAUTILUS_SCRIPT_SELECTED_URIS | sed -e 's/file:\/\///g' -e 's/\%20/\\ /g') ;
dir=$(echo $NAUTILUS_SCRIPT_CURRENT_URI | sed -e 's/file:\/\///g' -e 's/\%20/\\ /g') ;
tmpfile="$file~"
/usr/bin/psbook "$file" | /usr/bin/pstops -q -p a4 "4:1L@0.7(21.0cm,14.95cm)+0L@0.7(21.0cm,0.6cm),3L@0 .7(21.0cm,14.95cm)+2L@0.7(21.0cm,0.6cm)" > "$tmpfile";
/usr/bin/lpr -o page-set=odd -o outputorder=reverse "$tmpfile";
if zenity --question --text "Printing $file\nPrinting odd pages first,\nWhen finished load the paper back in and click OK"; then
/usr/bin/lpr -o page-set=even "$tmpfile";
#zenity --info --text "Done.";
fi ;
killall zenity;
[ -f "$tmpfile" ] && /bin/rm "$tmpfile";
#end of code
Enjoy,
J. Antas