Created
January 19, 2017 12:14
-
-
Save Teqqles/91a832e54a9925375547e7948acdadfa to your computer and use it in GitHub Desktop.
Remove those pesky cover sheets from a PDF résumé
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyPDF2 import PdfFileWriter, PdfFileReader | |
import sys | |
pages_to_remove = [0] | |
if len(sys.argv) < 3: | |
raise ValueError("A source and destination file need to be supplied") | |
infile_name = sys.argv[1] | |
outfile_name = sys.argv[2] | |
infile = PdfFileReader(infile_name) | |
output = PdfFileWriter() | |
for i in range(infile.getNumPages()): | |
page_data = infile.getPage(i) | |
if i not in pages_to_remove: | |
output.addPage(page_data) | |
with open(outfile_name, 'wb') as f: | |
output.write(f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment