Skip to content

Instantly share code, notes, and snippets.

@bsidhom
bsidhom / rewrite-pdf-outline.py
Last active November 15, 2024 02:11
Write an outline specified in JSON format into a PDF document using qpdf
#!/usr/bin/env python3
from __future__ import annotations
import argparse
import json
import sys
def main():
@ctrlcctrlv
ctrlcctrlv / jstor_unmetadata.bash
Last active July 16, 2024 10:36
JSTOR remove PDF download information (your IP and the date)
#!/bin/bash
# RIP Aaron Swartz, killed by corporate greed. (Not JSTOR itself, they are a charity;
# I mean the publishers they must contract with
# to offer the limited public service that they do.)
#
# “There is no justice in following unjust laws.
# It’s time to come into the light and, in the grand tradition of civil disobedience,
# declare our opposition to this private theft of public culture.” ~ Aaron Swartz
#
# Requires:
@lelegard
lelegard / pdf-booklet.sh
Created August 29, 2022 21:11
Reorder pages in a PDF file to print a booklet
#!/usr/bin/env bash
# Reorder pages in a PDF file to print a booklet.
# Then, print the output PDF in duplex mode, short-edge binding, 2 pages per sheet.
SCRIPT=$(basename "$BASH_SOURCE")
INFILE=
OUTFILE=
VERBOSE=false
SYSTEM=$(uname -s)
@convexset
convexset / remove-pdf-watermark.sh
Last active January 1, 2025 05:42
Remove multiple text watermarks from a PDF file. Requires xxd and qpdf to work correctly.
#!/bin/bash
# Remove multiple text watermarks from a PDF file. Requires xxd and qpdf to work correctly.
#
# Usage:
#
# remove-pdf-watermark.sh "Your Input File.pdf" "Your Output File.pdf" [WATERMARK1] [WATERMARK2] [WATERMARK3] [...]
#
# For Example:
#
@sneakers-the-rat
sneakers-the-rat / remove_meta.sh
Last active July 16, 2024 10:34
remove pdf metadata
####
# 1) install exiftool and qpdf
# https://exiftool.org/
# http://qpdf.sourceforge.net/
# (can be installed with homebrew: brew install exiftool qpdf )
####
# 2) remove metadata - this step is reversible, so we will need to recreate the PDF afterwards
exiftool -all:all= /location/of/some/file.pdf