-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgtk-pdftk
executable file
·211 lines (186 loc) · 5.63 KB
/
gtk-pdftk
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/bin/bash
#pdftk nautilus-script for gnome2
#edit by flow. mail: bandari.fans@163.com
#dependencies
#pdftk
#move this file into ~/.gnome2/nautilus-scripts then `chmod 755 filename`
case $@ in
$NULL)
zenity --title="error" --info --width=260 --height=80 --text="usage:
gtk-pdftk [ FILENAME ] "
exit
;;
*.pdf )
;;
*)
zenity --title="error" --info --width=260 --height=80 --text="you must specify a Adobe pdf file "
exit
;;
esac
case $LANG in
en*)
wancheng()
{
notify-send -i application-pdf "Operation Finished"
}
getback ()
{
zenity --title="choose a background pdf file" --file-selection --file-filter=*.pdf
}
getoutput ()
{
zenity --title="save as" --width=600 --height=600 --file-selection --save --file-filter=*.pdf --confirm-overwrite
}
getinput_mul()
{
zenity --title="choose pdf files you wanna merge" --width=700 --file-selection --file-filter=*.pdf --multiple
}
inputpasswd()
{
zenity --title="enter password" --text="please enter a passwd" --entry --hide-text
}
jiamiop()
{
zenity --title="choose a option" --width=550 --hide-header --list --radiolist --print-column=3 --hide-column=3 --column=x --column=y --column=z x "set a owner passwd to prevent print or edit pdf" jm1 x "set a user passwd and when you read it you need enter passwd" jm2
}
inputf()
{
zenity --title="choose some files you want to add in pdf" --width=600 --height=400 --file-selection --multiple
}
getpagenum()
{
zenity --title="add attach" --entry --text="enter a page number" --entry-text=1
}
rou()
{
zenity --title=rotate --width=400 --height=200 --list --text="choose angle of rotation" --print-column=3 --radiolist --hide-header --hide-column=3 --column=x --column=y --column=z x "rotate the image 90 degrees to the right" E x "rotate the image 180 degrees to the right" S x "rotate the image 270 degrees to the right" W x "rotate the image 90 degrees to the left" L
}
delpage()
{
zenity --title="del page" --entry --text="enter the page number you wanna delete" --entry-text=1
}
sel()
{
zenity --title="choose a opreation" --width=400 --height=400 --list --radiolist --print-column=3 --hide-header --hide-column=3 --column=x --column=y --column=z x "choose files to merge" hebing x encrypt jiami x decrypt jiemi x compress yasuo x uncompress jieya x "view pdf data" information x "delete page" del x brust brust x stamp stamp x "repair pdf files" repair x "add files to pdf" addfiles x "unpack files" unpack x rotate rotate
}
;;
#####################
zh* )
wancheng()
{
notify-send -i application-pdf "操作完成"
}
getback ()
{
if [ `zenity --title="选择水印pdf文件" --file-selection --file-filter=*.pdf` = $NULL ]; then echo xxxx;exit ;fi
}
getoutput ()
{
zenity --title="保存为" --file-selection --save --file-filter=*.pdf --confirm-overwrite
}
getinput_mul()
{
zenity --title="选择要合并的文件" --width=700 --file-selection --file-filter=*.pdf --multiple
}
inputpasswd()
{
zenity --title="输入密码" --text="enter a passwd" --entry --hide-text
}
jiamiop()
{
zenity --title="选择一个选项" --list --radiolist --print-column=3 --hide-column=3 --column=x --column=y --column=z x 只加密文档防止修改打印 jm1 x 加密文档,打开时要求输入密码 jm2
}
inputf()
{
zenity --title="选择要插入的文件,可多选" --width=600 --height=400 --file-selection --multiple
}
getpagenum()
{
zenity --title="插入文件" --entry --text="输入要插入的页码" --entry-text=1
}
rou()
{
zenity --title="旋转" --list --text="选择要旋转的角度" --print-column=3 --radiolist --hide-header --hide-column=3 --column=x --column=y --column=z x 顺时针旋转90度 E x 顺时针旋转180度 S x 顺时针旋转270度 W x 逆时针旋转90度 L
}
delpage()
{
zenity --title="删除页面" --entry --text="输入要删除的页面" --entry-text=1
}
sel()
{
zenity --title="请选择一项" --width=400 --height=400 --list --radiolist --print-column=3 --hide-header --hide-column=3 --column=x --column=y --column=z x 选择文件进行合并(可多选) hebing x 加密 jiami x 清除密码 jiemi x 压缩 yasuo x 解压 jieya x 查看信息 information x 删除某页 del x 将文件每页分为单个文档 brust x 添加水印 stamp x 修复损坏的pdf repair x 添加附件到文档 addfiles x 将附件提取到当前目录 unpack x 旋转 rotate
}
;;
esac
###############################################################
case "$(sel)" in
stamp)
pdftk "$@" stamp "$(getback)" output "$(getoutput)".pdf
wancheng
;;
hebing)
pdftk "$@" "$(getinput_mul)" cat output "$(getoutput)".pdf
wancheng
;;
jiami)
if [ $(jiamiop) = jm1 ]
then
pass=$(inputpasswd)
pdftk "$@" output "$(getoutput)".pdf owner_pw $pass
else
pass=$(inputpasswd)
pdftk "$@" output "$(getoutput)".pdf user_pw $pass
fi
wancheng
;;
jiemi)
pdftk "$@" input_pw "$(inputpasswd)" output "$(getoutput)".pdf
wancheng
;;
yasuo)
pdftk "$@" output "$(getoutput)".pdf compress
wancheng
;;
jieya)
pdftk "$@" output "$(getoutput)".pdf uncompress
wancheng
;;
information)
pdftk "$@" dump_data output /tmp/info.txt
zenity --text-info --filename=/tmp/info.txt
rm /tmp/info.txt
;;
addfiles)
pdftk "$@" attach_files "$(inputf)" to_page "$(getpagenum)" output "$(getoutput)".pdf
wancheng
;;
burst)
pdftk "$@" burst
wancheng
;;
repair)
get=$(getoutput)
pdftk "$@" output "$get".pdf|zenity --progress --pulsate --auto-close --title="repair PDF "
if [ $? = 1 ]
then zenity --title "error" -info --text=error
fi
wancheng
;;
unpack)
pdftk "$@" unpack_files output
;;
rotate)
pdftk "$@" cat "1-end$(rou)" output "$(getoutput)".pdf
wancheng
;;
del)
mm="$(delpage)"
let fr1=mm-1
let be1=mm+1
pdftk "$@" cat "1-$fr1" "$be1-end" output "$(getoutput)".pdf
wancheng
;;
$NULL)
exit
;;
esac