Created
March 1, 2022 08:10
-
-
Save xxsimoxx/769b6b45c9990a60d481f1cb8b50d60c to your computer and use it in GitHub Desktop.
Separa un PDF in due files in base a step.
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/perl | |
use strict; | |
use warnings; | |
use PDF::API2; | |
my ($pdf, $step) = @ARGV; | |
if (not defined $pdf) { | |
die "Need file name\n"; | |
} | |
if (not defined $step) { | |
die "Need steps\n"; | |
} | |
my $file = PDF::API2->open($pdf); | |
my $pag = $file->pages(); | |
my @range=(1..$pag); | |
my $cmd_lettere = "pdftk ${pdf} cat "; | |
my $cmd_bollettini = "pdftk ${pdf} cat "; | |
foreach(@range){ | |
if($_%$step == 1){ | |
$cmd_lettere .= "$_ "; | |
} | |
} | |
foreach(@range){ | |
if($_%$step != 1){ | |
$cmd_bollettini .= "$_ " | |
} | |
} | |
$pdf =~ s/\.pdf$//; | |
$cmd_lettere .= "output ${pdf}-lettere.pdf"; | |
$cmd_bollettini .= "output ${pdf}-bollettini.pdf"; | |
print "\n$cmd_lettere\n\n$cmd_bollettini\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment