Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7089445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:55:21+00:00 2026-05-28T07:55:21+00:00

I am looking for a tool to extract a given rectangular region (by coordinates)

  • 0

I am looking for a tool to extract a given rectangular region (by coordinates) of a 1-page PDF file and produce a 1-page PDF file with the specified region:

# in.pdf is a 1-page pdf file
extract file.pdf 0 0 100 100 > out.pdf
# out.pdf is now a 1-page pdf file with a page of size 100x100
# it contains the region (0, 0) to (100, 100) of file.pdf

I could convert the PDF to an image and use convert, but this would mean that the resulting PDF would not be vectorial anymore, which is not acceptable (I want to be able to zoom).

I would ideally like to perform this task with a command-line tool or a Python library.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:55:22+00:00Added an answer on May 28, 2026 at 7:55 am

    The following script found in
    http://snipplr.com/view.php?codeview&id=18924
    splits each page of a pdf into 2.

    #!/usr/bin/env perl
    use strict; use warnings;
    use PDF::API2;
    
    my $filename = shift;
    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('destination_path/myfile.pdf');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking for solution to extract content from a PDF file (using console tool or
I am looking for a small linux tool that would be able to extract
I am looking for tool that can convert .Glade (or xml) file to C
I am looking for a tool/api in .net, which can roughly extract the key
I'm looking for a tool to extract topic keywords from text. Topia seems to
I am looking for a tool to build good looking network Diagram. Right now
Looking for a tool to calculate the # of lines of code in an
Looking for a tool that will automatically create a graphical representation of a MySQL
I'm looking for a tool which can generate a Makefile for a C/C++ project
I am looking for a tool that can serialize and/or transform SQL Result Sets

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.