I have a project based on
https://github.com/parzibyte/firmar_pdf_python
My directory(I have tried to modify the endesive libraries)
C:\Users\Polo\AppData\Local\Programs\Python\Python312\Lib\site-packages\endesive\pdf\PyPDF2_annotate\annotations\
signature.py
In this python file, set:
HELVETICA_PATH =
os.path.join(os.path.dirname(__file__), "..", "Fonts", "
Helvetica.ttf")
Line 165
if block:
font = self.get_default_font()
font2 = self.get_default_font()
cs.extend(processor.text_box('\n'.join(block), font,font2, t_left, 5,(bbox[2]-5)-t_left, height-5))
C:\Users\Polo\PycharmProjects\firmar_pdf_python-main\
firmador.py line 20
def firmar(contraseña, certificado,hoja, pdf, qr_img, fecha ):
#date =
datetime.datetime.now()
date =
datetime.datetime.utcnow()
date2 =
datetime.datetime.now()
print(date)
print(date2)
print(qr_img)
#date2 = date.strftime("%Y-%m-%d%H:%M:%S.%F")
date2 = date2.strftime("%Y-%m-%dT%X.%F-05:00")
date = date.strftime("D:%Y%m%d%H%M%S+00'00'")
# with open("cert.p12", "rb") as fp:
p12 = pkcs12.load_key_and_certificates(
certificado.read(), contraseñ
a.encode("ascii"), backends.default_backend()
)
x = str(p12[1]).split("=")
y = x[2].split(",")
la_signed = "Firmado electrónicamente por: " + str(y[0])
# print(x[0])
# print(x[1])
print(la_signed)
# print(x[3])
generar_qr(str(y[0]), date2)
qr_img = "C:/Users/Polo/PycharmProjects/firmar_pdf_python-main/output" + str(y[0]) + ".png"
dct = {
"aligned": 0,
"sigflags": 2,
"sigflagsft": 132,
"sigpage": int(hoja),
"sigbutton": True,
"sigfield": "Signature1",
"auto_sigfield": True,
"sigandcertify": True,
"signaturebox": (100, 150, 250, 200),
#"signature": la_signed,
#"signature_img": qr_img,
"contact": "",
"location": "Ubicación",
"signingdate": date,
"reason": "Razón",
"password": contraseña,
'fontsize': 6,
"signature_appearance":{
'icon': qr_img,
'outline': [0.0, 0.0, 0.0],
'border': 0,
'labels': True,
'display': 'CN'.split(' '),
},
}
print(dct["signature_appearance"])
I need to modify the font of “CN”.
"Signature_appearance":{
'icon': qr_img,
'outline': [0.0, 0.0, 0.0],
'border': 0,
'labels': True,
'display': 'CN'.split(' '),
Delivery term: Not specified