Created
May 21, 2021 08:43
-
-
Save wvengen/d035a105683bf14f73e6709a3abd7c85 to your computer and use it in GitHub Desktop.
Alternative for Zotero's "Unlink citations" in Google Docs
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
#!/usr/bin/env python3 | |
# | |
# Alternative for Zotero's "Unlink citations" in Google Docs. | |
# It just removes all Zotero-specific links. | |
# | |
# Requires pymupdf >= 1.18.0 | |
# | |
import sys | |
import fitz | |
def matching_link(link): | |
return link['uri'] is not None and link['uri'].startswith('https://www.zotero.org/google-docs/?') | |
if len(sys.argv) != 3: | |
sys.stderr.write('Usage: %s <input_pdf> <output_pdf>\n' % sys.argv[0]) | |
sys.exit(1) | |
doc = fitz.open(sys.argv[1]) | |
for page in doc: | |
for link in page.links(kinds=(fitz.LINK_URI,)): | |
if matching_link(link): | |
page.delete_link(link) | |
doc.save(sys.argv[2]) | |
doc.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment