Compare commits
No commits in common. "8c5950b37f372c00e726761230fb8cf9f584b29b" and "df2a8d554f5bc731d4964eaa30cf846c77720fb3" have entirely different histories.
8c5950b37f
...
df2a8d554f
@ -1,5 +1,4 @@
|
|||||||
import io
|
import io
|
||||||
from random import randint
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from pyhanko import stamp
|
from pyhanko import stamp
|
||||||
@ -50,8 +49,8 @@ class SignOrchestrator:
|
|||||||
reason=reason,
|
reason=reason,
|
||||||
)
|
)
|
||||||
|
|
||||||
def sign(self, reason: str, signature_index: int|None, input_content: Buffer, on_page: int, box_place: (int, int, int, int), signer_text: str) -> io.BytesIO:
|
def sign(self, reason: str, signature_index: int, input_content: Buffer, on_page: int, box_place: (int, int, int, int), signer_text: str) -> io.BytesIO:
|
||||||
field_name = 'Signature' + str(signature_index) if signature_index is not None else 'Signature'+ str(randint(1000, 99999999999))
|
field_name = 'Signature' + str(signature_index)
|
||||||
signature_meta = self._make_signature_metadata(reason, field_name)
|
signature_meta = self._make_signature_metadata(reason, field_name)
|
||||||
|
|
||||||
pdf_signer = signers.PdfSigner(
|
pdf_signer = signers.PdfSigner(
|
||||||
|
@ -13,7 +13,7 @@ orchestrator = SignOrchestrator('./assets/dummy.p12',
|
|||||||
pkcs12_password=None)
|
pkcs12_password=None)
|
||||||
|
|
||||||
with open('./assets/test.pdf', 'rb') as input:
|
with open('./assets/test.pdf', 'rb') as input:
|
||||||
signed_content = orchestrator.sign(reason="first signer", signature_index=None,
|
signed_content = orchestrator.sign(reason="first signer", signature_index=0,
|
||||||
input_content=input.read(), box_place=(300, 600, 500, 660), on_page=0,
|
input_content=input.read(), box_place=(300, 600, 500, 660), on_page=0,
|
||||||
signer_text="Mme Caroline Diallo")
|
signer_text="Mme Caroline Diallo")
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ with open('./assets/test.pdf', 'rb') as input:
|
|||||||
output.write(signed_content.read())
|
output.write(signed_content.read())
|
||||||
|
|
||||||
with open('./assets/test_signed_0.pdf', 'rb') as input:
|
with open('./assets/test_signed_0.pdf', 'rb') as input:
|
||||||
signed_content = orchestrator.sign(reason="second signer", signature_index=None,
|
signed_content = orchestrator.sign(reason="second signer", signature_index=1,
|
||||||
input_content=input.read(), box_place=(100, 600, 300, 660), on_page=0,
|
input_content=input.read(), box_place=(100, 600, 300, 660), on_page=0,
|
||||||
signer_text="M. Bah Mamadou")
|
signer_text="M. Bah Mamadou")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user