Jawle has asked for the wisdom of the Perl Monks concerning the following question:
I have undertaken the task of learning Perl in the interest of running this script:
http://snipplr.com/view/18924/split-crop-double-page-pdfs-in-two/
#!/usr/bin/env perl use strict; use warnings; use PDF::API2; my $filename = shift || 'test.pdf'; my $oldpdf = PDF::API2->open($filename); my $newpdf = PDF::API2->new; for my $page_nb (1..$oldpdf->pages) { my ($page, @cropdata); $page = $newpdf->importpage($oldpdf, $page_nb); @cropdata = $page->get_mediabox; $cropdata[2] /= 2; $page->cropbox(@cropdata); $page->trimbox(@cropdata); $page->mediabox(@cropdata); $page = $newpdf->importpage($oldpdf, $page_nb); @cropdata = $page->get_mediabox; $cropdata[0] = $cropdata[2] / 2; $page->cropbox(@cropdata); $page->trimbox(@cropdata); $page->mediabox(@cropdata); } (my $newfilename = $filename) =~ s/(.*)\.(\w+)$/$1.clean.$2/; $newpdf->saveas('$newfilename'); __END__
I have created the program and am able to launch it, however I am very confused as to what I need to replace with my file and directory. For ex: should I insert my filename in line 6 in the brackets of ($filename)?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Splitting PDFs with PDF::API2
by aitap (Curate) on Oct 29, 2014 at 20:26 UTC | |
by Jawle (Initiate) on Oct 29, 2014 at 21:11 UTC | |
|
Re: Splitting PDFs with PDF::API2
by onelander (Sexton) on Oct 29, 2014 at 21:09 UTC | |
|
Re: Splitting PDFs with PDF::API2
by Jawle (Initiate) on Oct 29, 2014 at 18:30 UTC | |
by perlron (Pilgrim) on Oct 29, 2014 at 18:45 UTC | |
by Jawle (Initiate) on Oct 29, 2014 at 19:09 UTC | |
by perlron (Pilgrim) on Oct 29, 2014 at 19:18 UTC |