Skip to content

Commit

Permalink
Mypy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
BryceStevenWilley committed Jun 17, 2024
1 parent db6a496 commit 78cdfde
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions formfyxer/pdf_wrangling.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ def __init__(self, rsrcmgr: PDFResourceManager, device: PDFDevice, doc) -> None:
self.rsrcmgr = rsrcmgr
self.device = device
self.doc = doc
self.field_pages = {}
self.field_pages: Dict[Any, List[FormField]] = {}
existing_fields = get_existing_pdf_fields(doc)

for page_fields, page in zip(existing_fields, doc.pages):
Expand Down Expand Up @@ -802,20 +802,18 @@ def process_page(self, page) -> None:
continue
font = contender_font
self.textstate.fontsize = 8
x = 0
y = 0
x = 0.0
y = 0.0
needcharspace = False
# Start a specific position on the page (field.x and field.y)
self.do_TD(field.x, field.y)
matrix = mult_matrix(self.textstate.matrix, ctm)
# print(f"{field.get('T')}, {matrix}")
# Manual Tj operation
for char in r"{{" + field.name + r"}}":
for cid in font.decode(char.encode()):
if needcharspace:
x += 0.1 # charspace
# print(x, cid, font.char_width(cid))
x += self.device.render_char(
x += self.device.render_char( # type: ignore
translate_matrix(matrix, (x, y)),
font,
self.textstate.fontsize, # fontsize,
Expand All @@ -825,8 +823,8 @@ def process_page(self, page) -> None:
self.ncs,
self.graphicstate.copy(),
)
if cid == 32 and wordspace:
x += 0 # wordspace
# if cid == 32 and wordspace:
# x += 0 # wordspace
needcharspace = True
self.do_ET()
self.device.end_page(page)
Expand Down Expand Up @@ -861,7 +859,7 @@ def render(item: LTItem) -> None:
elif isinstance(item, LTImage):
if self.imagewriter is not None:
self.imagewriter.export_image(item)
elif isinstance(item, LTAnnot):
elif isinstance(item, LTAnno):
self.write_text(item.get_text())

if self.showpageno:
Expand Down

0 comments on commit 78cdfde

Please sign in to comment.