Skip to content

Instantly share code, notes, and snippets.

@mazulo
Last active October 15, 2021 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mazulo/1ffa79d611d096771dd602ef680a9ac7 to your computer and use it in GitHub Desktop.
Save mazulo/1ffa79d611d096771dd602ef680a9ac7 to your computer and use it in GitHub Desktop.
Script que mostra os fields editáveis do form
import os
from pathlib import Path
import pdfrw
ANNOT_KEY = '/Annots'
ANNOT_FIELD_KEY = '/T'
SUBTYPE_KEY = '/Subtype'
WIDGET_SUBTYPE_KEY = '/Widget'
TEMPLATE_PATH = 'Documents/Dunderlabs/Posts/escape.pdf'
template_pdf = pdfrw.PdfReader(os.path.join(Path.home(), TEMPLATE_PATH))
annotations = template_pdf.pages[0][ANNOT_KEY]
for annotation in annotations:
if annotation[SUBTYPE_KEY] == WIDGET_SUBTYPE_KEY:
if annotation[ANNOT_FIELD_KEY]:
key = annotation[ANNOT_FIELD_KEY][1:-1]
print(key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment