View Single Post
Old 10-23-2010, 03:35 PM   #2
martienne
.~^пиратка^~.
martienne can read faster than his screen refreshesmartienne can read faster than his screen refreshesmartienne can read faster than his screen refreshesmartienne can read faster than his screen refreshesmartienne can read faster than his screen refreshesmartienne can read faster than his screen refreshesmartienne can read faster than his screen refreshesmartienne can read faster than his screen refreshesmartienne can read faster than his screen refreshesmartienne can read faster than his screen refreshesmartienne can read faster than his screen refreshes
 
martienne's Avatar
 
Posts: 238
Karma: 14000
Join Date: Sep 2009
Location: Ask NSA...
Device: Onyx Boox M92
This Perl Script does it. I don't know anything about Perl but managed to get it working on Windows 7. You have to first install the Perl framework and then something called PDF::API2 - a kind of library, I think. You save the file with the extension .pl and simply run it.

This is the script. You can see where I have made changes.

Code:
#!/usr/bin/env perl
use strict; use warnings;
use PDF::API2;

my $filename = shift || 'E:\E-BOOKS\~Travel Guides\Ukraina\ukraine-getting-started.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('E:\E-BOOKS\~Travel Guides\Ukraina\started.pdf');

__END__

A TOOL WITH A GUI WOULD BE NICE, THOUGH! Anyone knows of one?
martienne is offline   Reply With Quote