Last active
August 29, 2015 14:04
-
-
Save y-yu/d76eef120b14c8945b21 to your computer and use it in GitHub Desktop.
split.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
my $pdffile = $ARGV[0]; | |
my $output = $ARGV[1] ? $ARGV[1] : "."; | |
my ($pagesize) = `pdfinfo $pdffile` =~ m/Pages:\s* (\d+)/x; | |
my $tenth = int($pagesize / 10); | |
for (0..$tenth - 1) { | |
my ($x, $y) = ($_ * 10 + 1, $_ * 10 + 10); | |
my $cmd = "pdftk $pdffile cat $x-$y output $output/$x-$y.pdf"; | |
print "$cmd\n"; | |
system $cmd; | |
} | |
my $cmd = "pdftk $pdffile cat ". ($tenth*10+1). "-$pagesize output $output/". ($tenth*10+1) ."-$pagesize.pdf"; | |
print "$cmd\n"; | |
system $cmd; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment