Skip to content

Instantly share code, notes, and snippets.

@tonytx05
Created October 2, 2023 17:39
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 tonytx05/144674ff55bc3646624b2d10860a822c to your computer and use it in GitHub Desktop.
Save tonytx05/144674ff55bc3646624b2d10860a822c to your computer and use it in GitHub Desktop.
Script to remove author names from all annotations in a PDF.
from pypdf import PdfReader, PdfWriter
reader = PdfReader('input.pdf')
writer = PdfWriter()
for page in reader.pages:
if '/Annots' in page:
for annot in page['/Annots']:
obj = annot.get_object()
if '/T' in obj:
obj.pop('/T')
writer.append_pages_from_reader(reader)
with open('output.pdf', 'wb') as fp:
writer.write(fp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment