Git Product home page Git Product logo

stapler's Introduction

Stapler

Stapler is a pure Python alternative to PDFtk, a tool for manipulating PDF documents from the command line.

History

PDFtk was written in Java and C++, and is natively compiled with gcj. Sadly, it has been discontinued a few years ago and bitrot is setting in (e.g., it does not compile easily on a number of platforms).

Philip Stark decided to look for an alternative and found pypdf, a PDF library written in pure Python. He couldn't find a tool which actually used the library, so he started writing his own.

This version of stapler is Fred Wenzel's fork of the project, with a completely refactored source code, tests, and added functionality.

Like pdftk, stapler is a command-line tool. If you would like to add a GUI, compile it into a binary for your favorite platform, or contribute anything else, feel free to fork and send me a pull request.

License

Stapler version 0.2 was written in 2009 by Philip Stark. Stapler version 0.3 was written in 2010 by Fred Wenzel.

For a list of contributors, check the CONTRIBUTORS file.

Stapler is distributed under a BSD license. A copy of the BSD Style License used can be found in the file LICENSE.

Usage

There are the following modes in Stapler:

select/delete (called with sel and del, respectively)

With select, you can cherry-pick pages from pdfs and concatenate them into a new pdf file.

Syntax:

stapler sel input1 page_or_range [page_or_range ...] [input2 p_o_r ...]

Examples:

# concatenate a and b into output.pdf
stapler sel a.pdf b.pdf output.pdf

# generate a pdf file called output.pdf with the following pages:
# 1, 4-8, 20-40 from a.pdf, 1-5 from b.pdf in this order
stapler sel a.pdf 1 4-8 20-40 b.pdf 1-5 output.pdf

# reverse some of the pages in a.pdf by specifying a negative range
stapler sel a.pdf 1-3 9-6 10 output.pdf

The delete command works almost exactly the same as select, but inverse. It uses the pages and ranges which you didn't specify.

split/burst:

Splits the specified pdf files into their single pages and writes each page into it's own pdf file with this naming scheme:

${origname}_${zero-padded page no}.pdf

Syntax:

stapler split input1 [input2 input3 ...]

Example for a file foobar.pdf with 20 pages:

$ stapler split foobar.pdf
$ ls
    foobar_01.pdf foobar_02.pdf ... foobar_19.pdf foobar_20.pdf

Multiple files can be specified, they will be processed as if you called single instances of stapler.

info:

Shows information on the metadata stored inside a PDF file.

Syntax:

stapler info foo.pdf

Example output: *** Metadata for foo.pdf

/ModDate:  D:20100313082451+01'00'
/CreationDate:  D:20100313082451+01'00'
/Producer:  GPL Ghostscript 8.70
/Title:  foo.pdf
/Creator:  PDFCreator Version 0.9.9
/Keywords:
/Author:  John Doe
/Subject:

stapler's People

Contributors

dtgay avatar esantoro avatar hellerbarde avatar nerdrew avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.