Junk

Junk Commit Details

Date:2015-01-27 09:39:27 (4 years 5 months ago)
Author:Nicola Fontana
Branch:master
Commit:aaae3083ec5f242de60b2268305844ebf105bd1b
Parents: 5f1eac158a192990cf64903faf2cf5caa53e3073
Message:schema: initial import

A script to join and convert in black & white a serie of PDF files. I'm
using it to put together the PDFs generated by an electric diagram CAD
(one PDF per page), hence the name.
Changes:
Amisc/pdf2bw (full)
Amisc/schema (full)

File differences

misc/pdf2bw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#! /bin/sh
error() {
echo "Error: $1"
echo "Usage: pdf2bw INPUT OUTPUT"
exit 1
}
[ -r "$1" ] || error "'$1' is not readable"
[ -n "$2" ] || error "Output file must be specified"
pdf2ps-dLanguageLevel=3 "$1" - |
gs-o "$2" -q \
-sDEVICE=pdfwrite \
-dAutoRotatePages=/None \
-c "/setrgbcolor{0 mul 3 1 roll 0 mul 3 1 roll 0 mul 3 1 roll 0 mul add add setgray}def" \
-
misc/schema
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#! /bin/bash
#
# Join together a bunch of colored PDF, transforming them in
# black and white before the merge.
error() {
echo "Error: $1"
echo "Usage: schema SCHEMA PDF_PAGE [PDF_PAGE ...]"
exit 1
}
[ -z "$2" ] && error "Invalid arguments"
schema=$1
tmpdir=/tmp/bw
shift
# Convert every PDF page in input to B&W
mkdir -p "$tmpdir"
for f in $*; do
pdf2bw "$f" "$tmpdir/$(basename "$f")"
done
# Merge the PDFs into a single file
pdfs=
for f in $@; do pdfs="$pdfs $tmpdir/$(basename "$f")"; done
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="$schema" $pdfs
rm -fr "$tmpdir"

Archive Download the corresponding diff file

Branches