The PDF manager is a simple command-line PDF editor developed in Python.
Clone the repository:
git clone git@github.com:davidspader/pdf-manager.git
Access the project directory:
cd pdf-manager
You need the PyPDF2 library:
pip install PyPDF2
There are two main required parameters: action and fileName, and a third parameter(used in some methods, each with its own purpose).
The PDF files that will be manipulated must be located in the ./pdfs
folder. All new generated files will have the same name as the file edited with -new
at the end.
python3 index.py action fileName thirdParameter
Each page will be transformed into a pdf file, they are in ./pdf/allPages
:
python3 index.py GetAllPages example.pdf
Remove all files from ./pdf/allPages
:
python3 index.py RemoveAllPagesFiles noFile
This method doesn't need any files, so we use noFile
.
Extracting only the first page:
python3 index.py GetFirstPage example.pdf
Extracting only the last page:
python3 index.py GetLastPage example.pdf
Extracting any page:
python3 index.py GetOnePage example.pdf 3
Extracting multiple pages:
python3 index.py GetPages example.pdf 1 2 4
You can pass to
as a parameter to get a sequence of pages:
python3 index.py GetPages example.pdf 1 to 4
After the file name example.pdf
, the parameters will all be interpreted as pages.
You can use this function to sort the pages too:
python3 index.py GetPages example.pdf 5 3 4 1 2
Now the page order is 5 3 4 1 2.
Join two pdfs:
python3 index.py GetMerge example.pdf example2.pdf
To rotate the file:
python3 index.py GetRotatePages example.pdf 90
The third parameter is the number of degrees that the file will rotate, it always has to be multiples of 90.
You can delete one or more pages:
python3 index.py DeletePages example.pdf 1
deleting multiple pages:
python3 index.py DeletePages example.pdf 1 3 5
You can also pass to
as a parameter to get a sequence of pages to delete:
python3 index.py DeletePages example.pdf 2 to 4