Created
May 28, 2024 02:24
-
-
Save ftnext/d9a2094ca2a54e84d3677217e607c783 to your computer and use it in GitHub Desktop.
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
# /// script | |
# dependencies = ["pikepdf"] | |
# /// | |
# Usage: pipx run unlock_pdf.py path/to/locked.pdf | |
# ref: https://methane.hatenablog.jp/entry/2024/01/11/PDF%E3%82%92%E3%82%BF%E3%83%96%E3%83%AC%E3%83%83%E3%83%88%E3%81%A7%E8%AA%AD%E3%82%80 | |
import sys | |
from pathlib import Path | |
from pikepdf import Pdf | |
src = Path(sys.argv[1]) | |
dest = Path(src.with_stem(src.stem + "-unlocked")) | |
with Pdf.open(src) as pdf: | |
pdf.save(dest) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment