用Briss批量切除pdf文件的白边

这段时间准备论文,要看好多电子资料。比如中国知网下载的N多论文还有N多RFC的pdf。已经忍无可忍成天对住台电脑看资料,于是入手了一部kindle4。这下问题又来了,pdf(Portable Document Format)是专门为打印设计的,在页面的四个方向都预留了白边。对于kindle4本来就不大的屏幕来说,pdf显示在kindle4的屏幕上,字小的同乌蝇一样,比用电脑看还要费眼。于是想到去掉白边,在网络上搜索了一下,发现了好几种软件,最后哥选了briss,真的非常的酷喔~~可以把白边删除得干干净净。

不过问题又来了,我有好多pdf文件呀!但是briss的操作界面只支持一次处理一个文件。看Briss的帮助文件的时候发现Briss支持用控制台操作~~如下:

================

 

Command line usage(使用命令行)

If you prefer command line and trust the basic automatic detection algorithm use it this way (can be batched!):

如果你喜欢用命令行并信任白边自动推测算法,可以用以下命令操作(支持批处理)。

java -jar briss-0.0.13.jar -s [SOURCEFILE] [-d [DESTINATIONFILE]]

Example:

java -jar briss-0.0.13.jar -s dogeatdog.pdf -d dogcrop.pdf
java -jar briss-0.0.13.jar -s dogeatdog.pdf 

================

到此,就非常好办了。我的电脑装了UNIX工具链在windows平台下的移植版:cygwin,于是我只用写一行unix命令就把我的一个目录夹下面所有的pdf文件都切边了。命令如下:

 

zausiu@enigma /cygdrive/e/kindle4/ipv6_en             // 当前目录 e://kindle4/ipv6_en 下面存放了所有待切白边的pdf文件.
$ ls *.pdf | xargs -I'{}' -n1 java -jar d:/Program\ Files\ \(x86\)/briss-0.0.13/briss-0.0.13.jar -s '{}'    // 用来把该目录下面所有.pdf文件去白边的命令。
 
我的pdf文件很多,随便贴出一点命令的输出。
 
Since no destination was provided destination will be set to  : E:\kindle4\ipv6_en\draft-itojun-ipv6-transition-abuse-01_cropped.pdf
Clustering PDF: draft-itojun-ipv6-transition-abuse-01.pdf
Created 2 clusters.
Starting to render clusters…..finished!
Calculating crop rectangles.
Starting to crop files.
Cropping succesful. Cropped to:E:\kindle4\ipv6_en\draft-itojun-ipv6-transition-a=buse-01_cropped.pdf
 
Since no destination was provided destination will be set to  : E:\kindle4\ipv6_en\layer2_attacks_and_mitigation_t_cropped.pdf
Clustering PDF: layer2_attacks_and_mitigation_t.pdf
Created 2 clusters.
Starting to render clusters……….finished!
Calculating crop rectangles.
Starting to crop files.
Cropping succesful. Cropped to:E:\kindle4\ipv6_en\layer2_attacks_and_mitigation_t_cropped.pdf
 
大概的意思是,我的命令没有提供切白边后新pdf文件的文件名,于是自动取了一个名字。然后程序分析pdf文件,开始切边,最后切边成功。
由于我写的命令是用了Unix Shell的语法,所以如果你的机器没有装cygwin是运行不了这个命令的。可以把它用windows批处理的语法改写,但是哥不会windows批处理的语法哈~~~