Skip to content

python scripts to reverse the order of the PDF pages without losing the original quality

License

Notifications You must be signed in to change notification settings

luke-who/reverse-pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python scripts to reverse the order of the PDF pages

python pip

  • Note the reversed PDF file generated by this script is slightly reduced compared to the original file size when tested.

Usage

Package requirement: pdfrw

pip3 install pdfrw

then run

python3 reverse_pdf.py file.pdf
  • Note the reversed PDF file generated by this script is slightly reduced compared to the original file size when tested.

Usage

Package requirement tkinter:

For Debian-based Linux:

sudo apt-get install python-tk

via homebrew python-tk:

brew install [email protected]

then run

python3 reverse_pdf_PyPDF2.py

to select a PDF file in the GUI to proceed

reverse_apple.py + Apple's Automator

Here is a Python script that takes one or more PDF files on its command-line and writes each document's reversed pages into a new document with "_reversed" appended to the filename (e.g. foo.pdf => foo_reversed.pdf). This requires the System Python because it is using the Apple PDFKit framework. This is adaptable to an Automator Run Shell Script with passed PDF file arguments. As long as Apple continues to provide a System Python that has Cocoa bridge support, this Python script reverse_apple.py will rapidly reverse the pages in one or more PDF (without modifying the original) and write file.pdf out as file_rev.pdf in the original filesystem location.

  • Note for this script to work it requires pyobjc, if not already installed:
pip3 install pyobjc

It can be incorporated into a single Automator Run Shell Script action saved as either a drag/drop application on the Desktop, or as a Quick Action, so you can select one or more PDF in the Finder and with a right-click, choose Quick Actions -> Reverse PDF Pages.

Automator (Quick Action):

Set up

Automator Quick Action

Debugging: Note in macOS Monterey, you may encounter this error due to Python 2.7 deprecation

Make sure there's no bug left and save Save Quick Action

Alternatively download Reverse PDF Pages and open it. The default path to store this workflow is "/Users/<your_user_name>/Library/Services/Reverse\ PDF\ Pages.workflow"

Usage in Finder

Finder Quick Action

Automator (Application):

TBD

Contributing

Any suggestions are welcome with a pull request. Either to expand this further or adding more functionalities.

LICENSE


MIT License

About

python scripts to reverse the order of the PDF pages without losing the original quality

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages