diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..dbd26242c Binary files /dev/null and b/.DS_Store differ diff --git a/projects/.DS_Store b/projects/.DS_Store index cc9466266..fcb358eff 100644 Binary files a/projects/.DS_Store and b/projects/.DS_Store differ diff --git a/projects/Demerge_pdfs/.DS_Store b/projects/Demerge_pdfs/.DS_Store new file mode 100644 index 000000000..8d7bb8672 Binary files /dev/null and b/projects/Demerge_pdfs/.DS_Store differ diff --git a/projects/Demerge_pdfs/Python.pdf b/projects/Demerge_pdfs/Python.pdf new file mode 100644 index 000000000..72cfb3237 Binary files /dev/null and b/projects/Demerge_pdfs/Python.pdf differ diff --git a/projects/Demerge_pdfs/Python1(270 pages).pdf b/projects/Demerge_pdfs/Python1(270 pages).pdf new file mode 100644 index 000000000..46d99f77e Binary files /dev/null and b/projects/Demerge_pdfs/Python1(270 pages).pdf differ diff --git a/projects/Demerge_pdfs/Python2(270 pages): 270.pdf b/projects/Demerge_pdfs/Python2(270 pages): 270.pdf new file mode 100644 index 000000000..66e0043aa Binary files /dev/null and b/projects/Demerge_pdfs/Python2(270 pages): 270.pdf differ diff --git a/projects/Demerge_pdfs/Python3(90 pages).pdf b/projects/Demerge_pdfs/Python3(90 pages).pdf new file mode 100644 index 000000000..94f19d575 Binary files /dev/null and b/projects/Demerge_pdfs/Python3(90 pages).pdf differ diff --git a/projects/Demerge_pdfs/Python4(180 pages).pdf b/projects/Demerge_pdfs/Python4(180 pages).pdf new file mode 100644 index 000000000..ef1a89df8 Binary files /dev/null and b/projects/Demerge_pdfs/Python4(180 pages).pdf differ diff --git a/projects/Demerge_pdfs/README.md b/projects/Demerge_pdfs/README.md new file mode 100644 index 000000000..ece61751e --- /dev/null +++ b/projects/Demerge_pdfs/README.md @@ -0,0 +1,9 @@ +# Demerging_pdfs +Python program to convert a large pdf file to number of different sized pdf files without any change in the large file. + +# Required Libraries +PyPDF2,it can be installed by typing "pip3 install PyPDF2" on your command line + +# Author Name +Darpan-Balar + diff --git a/projects/Demerge_pdfs/demerging_pdfs.py b/projects/Demerge_pdfs/demerging_pdfs.py new file mode 100644 index 000000000..fdb6bfe7a --- /dev/null +++ b/projects/Demerge_pdfs/demerging_pdfs.py @@ -0,0 +1,40 @@ +import PyPDF2 + +# Note: here instead of Python.pdf you should give the whole path to the pdf if the pdf is not present in the same directory where python program is present +merged_pdf = open('Python.pdf', mode='rb') + + +pdf = PyPDF2.PdfFileReader(merged_pdf) + +(u, ctr, x) = tuple([0]*3) +for i in range(1, pdf.numPages+1): + + if u >= pdf.numPages: + print("Successfully done!") + exit(0) + name = input("Enter the name of the pdf: ") + ctr = int(input(f"Enter the number of pages for {name}: ")) + u += ctr + if u > pdf.numPages: + print('Limit exceeded! ') + break + + # Note: In the braces you should give the desired path of where new files should be stored + base_path = '{}.pdf' + # If you want to store the new pdfs in the same directory, then leave the braces empty + path = base_path.format(name) + f = open(path, mode='wb') + pdf_writer = PyPDF2.PdfFileWriter() + + for j in range(x, x+ctr): + page = pdf.getPage(j) + pdf_writer.addPage(page) + + x += ctr + + pdf_writer.write(f) + f.close() + + +merged_pdf.close() +print("Successfully done!") diff --git a/projects/Demerge_pdfs/explanation.txt b/projects/Demerge_pdfs/explanation.txt new file mode 100644 index 000000000..a25f825d8 --- /dev/null +++ b/projects/Demerge_pdfs/explanation.txt @@ -0,0 +1,17 @@ +yay,we have successfully demerged a "Python" book pdf containing 810 pages🥳. +Python book was demerged into 4 books: Python1,Python2,Python3,Python4 +Bookname No.of pages +Python1 270 +Python2 270 +Python3 90 +Python4 180 +Total 810(270+270+90+180) + +This python script was a interactive program. +It means the program when executed asks user to input and runs accordingly. +Note: +1. We should be careful while giving no.of pages as input. If the given input exceeds the limit it will yell "Limit Exceeded!". +2. We can always come out of the program if we need only some part of pdf. + Example: If we have a pdf of 400 pages and we need only first 200 pages of it in 2 different pages + then we can input for those 2 pdfs and then PRESS CMD+C(Mac) or CTRL+C(windows) +