Skip to content

Instantly share code, notes, and snippets.

@rxw1
Created August 23, 2023 16:26
Show Gist options
  • Save rxw1/fbb00aa4d281bf63ec7ca158f61d01f3 to your computer and use it in GitHub Desktop.
Save rxw1/fbb00aa4d281bf63ec7ca158f61d01f3 to your computer and use it in GitHub Desktop.

Revisions

  1. rxw1 created this gist Aug 23, 2023.
    22 changes: 22 additions & 0 deletions acroform_font_size.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    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])