All Projects → hellerbarde → Stapler

hellerbarde / Stapler

Licence: other
A small utility making use of the pypdf library to provide a (somewhat) lighter alternative to pdftk

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Stapler

Booktype
Booktype is a free, open source platform that produces beautiful, engaging books formatted for print, Amazon, iBooks and almost any ereader within minutes.
Stars: ✭ 810 (+240.34%)
Mutual labels:  pdf, pdf-converter
Gotenberg Php Client
PHP client for the Gotenberg API
Stars: ✭ 80 (-66.39%)
Mutual labels:  pdf, pdf-converter
Gotenberg Go Client
Go client for the Gotenberg API
Stars: ✭ 35 (-85.29%)
Mutual labels:  pdf, pdf-converter
Images To Pdf
An app to convert images to PDF file!
Stars: ✭ 602 (+152.94%)
Mutual labels:  pdf, pdf-converter
Docnet
DocNET is as fast PDF editing and reading library for modern .NET applications
Stars: ✭ 128 (-46.22%)
Mutual labels:  pdf, pdf-converter
Dinktopdf
C# .NET Core wrapper for wkhtmltopdf library that uses Webkit engine to convert HTML pages to PDF.
Stars: ✭ 682 (+186.55%)
Mutual labels:  pdf, pdf-converter
Laravel Pdf
A Simple package for easily generating PDF documents from HTML. This package is specially for laravel but you can use this without laravel.
Stars: ✭ 79 (-66.81%)
Mutual labels:  pdf, pdf-converter
Node Html Pdf
📄 Html to pdf converter in nodejs. It spawns a phantomjs process and passes the pdf as buffer or as filename.
Stars: ✭ 3,364 (+1313.45%)
Mutual labels:  pdf, pdf-converter
Ptext Release
pText is a library for reading, creating and manipulating PDF files in python.
Stars: ✭ 124 (-47.9%)
Mutual labels:  pdf, pdf-converter
Email To Pdf Converter
Converts email files (eml, msg) to pdf
Stars: ✭ 110 (-53.78%)
Mutual labels:  pdf, pdf-converter
Mdpdf
Markdown to PDF command line app with support for stylesheets
Stars: ✭ 512 (+115.13%)
Mutual labels:  pdf, pdf-converter
Pdfcropmargins
pdfCropMargins -- a program to crop the margins of PDF files
Stars: ✭ 141 (-40.76%)
Mutual labels:  pdf, pdf-converter
Pdf To Text
Extract text from a pdf
Stars: ✭ 462 (+94.12%)
Mutual labels:  pdf, pdf-converter
Docconv
Converts PDF, DOC, DOCX, XML, HTML, RTF, etc to plain text
Stars: ✭ 735 (+208.82%)
Mutual labels:  pdf, pdf-converter
Serverless Libreoffice
Run LibreOffice in AWS Lambda to create PDFs & convert documents
Stars: ✭ 410 (+72.27%)
Mutual labels:  pdf, pdf-converter
Pdfsave
Convert websites into readable PDFs
Stars: ✭ 46 (-80.67%)
Mutual labels:  pdf, pdf-converter
Pdf Flipbook
Browse PDF document like a book turning its pages
Stars: ✭ 279 (+17.23%)
Mutual labels:  pdf, pdf-converter
Python Automation Scripts
Simple yet powerful automation stuffs.
Stars: ✭ 292 (+22.69%)
Mutual labels:  pdf, pdf-converter
Remarks
Extract highlights, scribbles, and annotations from PDFs marked with the reMarkable tablet. Export to Markdown, PDF, PNG, and SVG
Stars: ✭ 94 (-60.5%)
Mutual labels:  pdf, pdf-converter
Net Core Docx Html To Pdf Converter
.NET Core library to create custom reports based on Word docx or HTML documents and convert to PDF
Stars: ✭ 133 (-44.12%)
Mutual labels:  pdf, pdf-converter

Stapler

Stapler is a pure Python alternative to PDFtk <http://www.pdfhacks.com/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.

Version 0.3 of stapler was completely refactored by Fred Wenzel. He also added tests and awesome 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 a pull request.

Contributors and Authorship

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.

Change log (sorta)

  • 1.0.0 Port to Python 3. Replace OptionParser with more modern ArgumentParser. Cleaning up repository.

  • 0.3.3 include try-except blocks for supporting legacy pyPdf if needed. Also fixes some PyPI issues like the missing License Trove classifier and some dependencies.

  • 0.3.0 Refactoring by Fred Wenzel and now using PyPDF2

  • 0.2.0 Feature completeness using original pyPdf

License

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)


``sel`` is also available as ``cat`` for compatibility with my
personal muscle memory. :)

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

Input files can be associated with handles for use with ranges later.
A handle is a single, upper-case letter:

::

    <input handle>=<input>

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 in 180° (D for down), 20-40 from a.pdf, 1-5 from b.pdf in 
    # this order
    stapler sel a.pdf 1 4-8D 20-40 b.pdf 1-5 output.pdf

    # the same example with a handle for b.pdf
    stapler sel B=b.pdf a.pdf 1 4-8D 20-40 B1-5 output.pdf

    # generate a pdf file called output.pdf with the following pages:
    # 1 from a.pdf, 1-5 from b.pdf, 4-8 in 180° (D for down), 20-40 from a.pdf
    # this order
    stapler sel A=a.pdf B=b.pdf A1 B1-5 A4-8D A20-40 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.

zip:
~~~~

With zip, you can cherry-pick pages from pdfs (like select). The pages
from each pdf are merged together in an interleaving manner. This can be
used to collate a pdf with odd pages and a pdf with even pages into a
single file.

Syntax: stapler zip input1 [range[rotation]] [range ...] [input2
[range...] ...] out

Examples:

::

    # combine a pdf with odd pages and a pdf with even pages into output.pdf
    stapler zip odd.pdf even.pdf output.pdf

    # combine a.pdf b.pdf and c.pdf, but use only some pages of c.pdf and
    #  rotate b.pdf right (90° clockwise) and rotate c.pdf left (90° counter-
    # clockwise)
    stapler zip a.pdf b.pdf 1-endR c.pdf 1-3L output.pdf

If one of the ranges is shorter than the others, stapler will continue
to merge the remaining pages.

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:

list-logical:
~~~~~~~~~~~~~

Shows each logical page number and the associated physical page number.

Syntax:

::

    stapler list-logical foo.pdf

Example output:

::

    A-1	1
    C-1	2
    D-1	3
    D-2	4
    D-3	5
    D-4	6

background
~~~~~~~~~~

Merge/Overlay the given input files interleaved. Similar to zip, it merges the pages into a single page instead of interleaving them.

Syntax: stapler background input1 [range[rotation]] [range ...] [input2
[range...] ...] out

Examples:

::

    # merge the pages of two pdfs into divided pages that will include both
    stapler background input1.pdf input2.pdf output.pdf
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].