Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Did multiple changes... #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions Applications/Merge Multiple PDF/source-code.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
from PyPDF2 import PdfFileMerger
import os
#var = os.getcwd() For extracting from enother folder
merger = PdfFileMerger()
for items in os.listdir():
if items.endswith('.pdf'):
merger.append(items)
merger.write("Final_pdf.pdf")
# Download the following library using pip.
import os
# The above library already in your library.

# Make a function of PyPDF2 a variable.
merger = PdfFileMerger()
with open(originalFile, 'rb') as fin:
merger.append(PdfFileReader(fin))
os.remove(originalFile)

# Run the for loop to scan through all the pdf files.
# If wanted you can also just put the names of files instead of scanning all the files.
for items in os.listdir(): # os.listdir mean that it will scan through all the files.
# This is an endswith function to check the extension of the object.
if items.endswith('.pdf'):
# This will append/add all projects.
merger.append(items)

# This will write the whole document/ add it together into a new pdf.
merger.write("Rename.pdf") # The name can easily be changed.

merger.close()

# This project is edited by Atul Anand based upon python version 3.9.
# I can assure you that this project will properly work if you use the latest version of python.
# Check my version of this project and many other projects on github.com/AtulACleaver.