Manual fonts not rendering
frankroberto20 opened this issue · 4 comments
frankroberto20 commented
Hi, I've been trying to customize my signature field but I ran into an issue where even if I specify a manual font and add it to the manual signature it does not render the signature with the correct font and instead uses the default one. Here's my example code (sorry for the mess, this is just meant for testing, the actual code is different).
dct = {
"aligned": 0,
"sigflags": 3,
"sigflagsft": 132,
"sigpage": 0,
"sigfield": "Signature1",
"auto_sigfield": True,
"signform": False,
"signaturebox": (40, 110, 260, 190),
"signature_manual": [
['text_box', f'Investor\nName: {user.full_name}\nEmail: {user.email}\nDate: {date}\nLocation: Szczecin',
# font *[bounding box], fs, wrap, align, baseline
'default', 5, 10, 270, 40, 7, True, 'left', 'top'],
['fill_colour', 0.4, 0.4, 0.4],
['rect_fill', 0, 50, 250, 1],
['fill_colour', 0, 0, 0],
['text_box', user.full_name,
'DancingScript', 7, 25, 270, 50, 12, True, 'left', 'top'],
],
"manual_fonts": {'AlexBrush': 'AlexBrush-Regular.ttf', 'Freestyle': 'Freestyle Script Regular.ttf', 'DancingScript': 'DancingScript-VariableFont_wght.ttf'},
"contact": user.email,
"location": "Szczecin",
"signingdate": date,
"reason": f"Investment in {investment.home.company.name} by {investment.user.full_name}",
"password": "1234",
}
with open(user_p12, "rb") as fp:
p12 = pkcs12.load_key_and_certificates(
fp.read(), b"1234", backends.default_backend()
)
fname = "agreement_1.pdf"
datau = pdf
print(type(pdf))
datas = cms.sign(datau, dct, p12[0], p12[1], p12[2], "sha256")
fname = fname.replace(".pdf", "-signed-cms.pdf")
signed_pdf = io.BytesIO(datau)
with open('agreement_1.pdf', "wb") as fp:
fp.write(signed_pdf.getvalue())
signed_pdf.seek(0, 2)
signed_pdf.write(datas)
signed_pdf.seek(0)
with open('agreement_1-first_sign.pdf', "wb") as fp:
fp.write(signed_pdf.getvalue())
Here's the resulting PDF, above the line it should write the signature using the custom font.
frankroberto20 commented
m32 commented
try current version from git
frankroberto20 commented
That seemed to fix it, thanks! Any plans to upload this version as a pip package?
m32 commented
uploaded