Created
August 23, 2023 16:26
-
-
Save rxw1/fbb00aa4d281bf63ec7ca158f61d01f3 to your computer and use it in GitHub Desktop.
Bulk change PDF AcroForm text field annotation font sizes
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
from sys import argv | |
from pikepdf import Name, Pdf | |
def render(input: str, output: str) -> None: | |
with Pdf.open(input) as pdf: | |
for page in pdf.pages: | |
annots = page.get("/Annots") | |
if annots is not None: | |
for annot in [ | |
a | |
for a in annots.as_list() | |
if a.Subtype == Name("/Widget") and hasattr(a, "FT") | |
]: | |
if annot.FT == Name("/Tx"): | |
annot.DA = "/Helv 10 Tf 0 g" | |
pdf.save(output) | |
if __name__ == "__main__": | |
render(argv[1], argv[2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment