Skip to content

Instantly share code, notes, and snippets.

@shubhamagarwal92
Last active May 13, 2020 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shubhamagarwal92/1d446b92dda996e413bc83697fff8278 to your computer and use it in GitHub Desktop.
Save shubhamagarwal92/1d446b92dda996e413bc83697fff8278 to your computer and use it in GitHub Desktop.
combine pdfs
# https://cmdlinetips.com/2016/03/how-to-join-pdf-files-in-mac-on-terminal/
# On mac
/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py -o pages.pdf 1.pdf 2.pdf
# Another command
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combine.pdf -dBATCH 1.pdf 2.pdf
# sed 's/>>> //g ' combinePDF.py >> combinePDF.py
# For specific pages python command
# from PyPDF2 import PdfFileReader
# from PyPDF2 import PdfFileWriter
# file1= open('ds7002.pdf','rb')
# pdf1 = PdfFileReader(file1)
# newFile = 'newFile.pdf'
# writer = PdfFileWriter()
# writer.addPage(pdf1.getPage(0))
# file2 = open('out.pdf','rb')
# pdf2=PdfFileReader(file2)
# writer.addPage(pdf2.getPage(1))
# writer.addPage(pdf2.getPage(2))
# writer.addPage(pdf2.getPage(3))
# writer.addPage(pdf2.getPage(4))
# newPdf = open(newFile,'wb')
# writer.write(newPdf)
# newPdf.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment