Skip to content

Commit

Permalink
Merge pull request #546 from Axedyson/patch-1
Browse files Browse the repository at this point in the history
Use stringWidth from reportlab pdf module instead of custom function to fix cover letter generation
  • Loading branch information
feder-cr authored Oct 16, 2024
2 parents b4bb280 + cb27357 commit 1781092
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/aihawk_easy_applier.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from reportlab.lib.pagesizes import A4
from reportlab.pdfgen import canvas
from selenium.common.exceptions import NoSuchElementException, TimeoutException
from reportlab.pdfbase.pdfmetrics import stringWidth
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
Expand Down Expand Up @@ -536,11 +537,11 @@ def split_text_by_width(text, font, font_size, max_width):
wrapped_lines = []
for line in text.splitlines():

if utils.stringWidth(line, font, font_size) > max_width:
if stringWidth(line, font, font_size) > max_width:
words = line.split()
new_line = ""
for word in words:
if utils.stringWidth(new_line + word + " ", font, font_size) <= max_width:
if stringWidth(new_line + word + " ", font, font_size) <= max_width:
new_line += word + " "
else:
wrapped_lines.append(new_line.strip())
Expand Down
4 changes: 0 additions & 4 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,3 @@ def printyellow(text):
reset = "\033[0m"
logger.debug("Printing text in yellow: %s", text)
print(f"{yellow}{text}{reset}")

def stringWidth(text, font, font_size):
bbox = font.getbbox(text)
return bbox[2] - bbox[0]

0 comments on commit 1781092

Please sign in to comment.