Skip to content

Instantly share code, notes, and snippets.

@ericmjl
Created June 5, 2015 16:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericmjl/a0b5941b3cbf5aeb01da to your computer and use it in GitHub Desktop.
Save ericmjl/a0b5941b3cbf5aeb01da to your computer and use it in GitHub Desktop.
A Python script for stripping out metadata from a PDF file.
import os
from PyPDF2 import PdfFileReader, PdfFileMerger
files_dir = os.getcwd()
if 'stripped' not in os.listdir(files_dir):
os.mkdir('stripped')
for f in os.listdir(files_dir):
if f.split('.')[-1] == 'pdf':
merger = PdfFileMerger()
merger.append(PdfFileReader(f, 'rb'))
merger.write('stripped/{0}'.format(f))
@positivedefinite
Copy link

this isn't working anymore :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment