Amazing-Python-Scripts

Форк
0

README.md

PDF reordering script

This script can be helpful for re-arranging a pdf file which may have pages out of order.

About the script ReArrange.py**

  • It takes path of the file as an Input.

  • Then it takes current page which is in the wrong order and the right page no. it should be on.

  • Seperate values by a comma ',' and line by line.

    • Example:-

      1,2
      3,1
      2,3

      here the 1st page in the pdf should be on the 2nd page instead and so on.

  • The script parses and sorts the input values by the function input_and_parse(n) which takes no. of pages in pdf file as input.

  • Then using the re_arrange() function we can get the desired file after rearranging.

Setup instructions

  • We use pdfrw library for this script.

    • To install this library, type pip install pdfrw in your terminal.
  • To run the script python3 pdf_reorder_.py and then enter the required information.

  • After running the script it will create a modified file in the same folder as that of the original pdf file.

Output:

A short demo of how the script works

Here We have a pdf file wrong.pdf which has pages in wrong order.

Image 1

We can see in the below two images that in the PDF file contents of page 5 are on page 1. Similar error exists throughout the pdf file

Image 2

After entering the required input like the path of the file and the current page which is in the wrong order and the right page no. it should be on seperated by commas ','. The script runs and a modified file is created.

Image 3

We can see the contents of the directory and the modified file will be present there.

Image 4

Voila! the pages are in the right order now.

Image 5

image 6

Author:

Mohta Rahul Suresh

Note:

I have also added wrong.pdf file for testing purposes in this directory.

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.