forked from kappapiana/script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_doc_no.sh
executable file
·43 lines (30 loc) · 884 Bytes
/
add_doc_no.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#/bin/bash!
# Creates a PDF with overlaying something on the first page
# REQUIRES pdftk
# usage: you create an overlay one-pager PDF (such as "document_no1.pdf")
# Then you pass the original document and this document as script variables
pdftkpath=`which pdftk`
#checking if variables are all filled in
if [ "$2" = "" ]; then
echo ""
echo "+*******"
echo "|"
echo "| missing variable (2 required)"
echo "|"
echo "| usage: [scriptname] [original filename] [overlay filename] "
echo "|"
echo "+******"
echo ""
else
PAGES=`$pdftkpath $1 dump_data |grep NumberOfPages | awk '{print $2}'`
echo ""
echo "your document appears to be $PAGES pages long"
echo ""
$pdftkpath $2.pdf multibackground $1 output ~/temp.pdf
$pdftkpath A=~/temp.pdf B=$1 cat A1 B2-$PAGES output $1_final.pdf
rm ~/temp.pdf
echo ""
echo "----"
echo ""
echo "$1_final.pdf successfully created"
fi