Skip to content

Instantly share code, notes, and snippets.

@cherryblossom000
Last active December 25, 2022 07:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cherryblossom000/bf9f07ed2d78e664393cdebe2ceaf300 to your computer and use it in GitHub Desktop.
Save cherryblossom000/bf9f07ed2d78e664393cdebe2ceaf300 to your computer and use it in GitHub Desktop.

Don’t like the

This document is intended for <student name> at <school> (user ID: <id>). Unauthorised circulation in any form is not permitted.

at the bottom of each page of an Edrolo PDF textbook?

Use this script!

  • Install Python 3
  • pip install pikepdf
  • python3 remove-edrolo-thing.py input.pdf output.pdf

This script worked using Python v3.9.7 and pikepdf v5.1.0.

Works with

  • Physics 3&4 2nd ed.
  • Biology 3&4 2nd ed.

Other textbooks may or may not work.

#!/usr/bin/env python3
import sys
from pikepdf import Pdf
def remove_edrolo_thing(input_file: str, output_file: str):
with Pdf.open(input_file) as pdf:
for page in pdf.pages:
# page.Contents[-1].read_bytes() is something like
# b' Q\nq\nq 0.99987 0 0 0.99987 0.17688 0 cm /Xi9 Do Q\nQ\n'
# or
# b' Q\nq\nq 0.99987 0 0 0.99987 0.17688 0 cm /Xi791 Do Q\nQ\n'
del page.Resources.XObject[page.Contents[-1].read_bytes()[40:-8]]
del page.Contents[-1]
pdf.save(output_file)
remove_edrolo_thing(sys.argv[1], sys.argv[2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment