Please provide option to add PNG image as signature in the signature widget #65
-
Steps I Followed - add Signature Placeholder Sign PDF This signs the PDF and create a rectangle with the signature. But is there a way to add signature image like png there ? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 6 replies
-
I am new to python and a node js developer - so I think it ll take time for me to understand your code. @MatthiasValvekens |
Beta Was this translation helpful? Give feedback.
-
Yes, that's possible; see here: https://pyhanko.readthedocs.io/en/latest/cli-guide/config.html#styles-for-stamping-and-signature-appearances and https://pyhanko.readthedocs.io/en/latest/api-docs/pyhanko.stamp.html#pyhanko.stamp.BaseStampStyle. In particular, note the following:
Combining these, it's possible to set up a signature appearance with only an image and no text: stamp-styles:
bitmap-notext:
type: text
stamp-text: ""
background: image.png
background-opacity: 1 Would that work for you? |
Beta Was this translation helpful? Give feedback.
-
But still seems like we have less control on the signing text and image position. |
Beta Was this translation helpful? Give feedback.
-
@MatthiasValvekens Can you give a simple example of adding an image background to a stamp.TextBoxLayout Object ? |
Beta Was this translation helpful? Give feedback.
-
I'm going to give a minimum reproduce-able example of what I'm trying to achieve using the API. Old Codepdf_signer = signers.PdfSigner(
signers.PdfSignatureMetadata(field_name=f'Signature{i}'), signer=self.signer, stamp_style=stamp.TextStampStyle(
stamp_text='Signed by: %(signer)s\nTime: %(ts)s', text_box_style=stamp.TextBoxStyle(font_size=20)
)
) New Requested Code @MatthiasValvekens @ghoshpushpenduI want to add a tick image to the left of text such as the following, Please provide some code using the API |
Beta Was this translation helpful? Give feedback.
Yes, that's possible; see here: https://pyhanko.readthedocs.io/en/latest/cli-guide/config.html#styles-for-stamping-and-signature-appearances and https://pyhanko.readthedocs.io/en/latest/api-docs/pyhanko.stamp.html#pyhanko.stamp.BaseStampStyle.
In particular, note the following:
background
entry in a style definition can take a PNG image as its argument (or even another PDF).stamp-text
empty.background-opacity
option (which is only documented in the API reference at this point, but it works in config as well) that allows you to have the background displayed with full opacity.Combining these, it's possible to set up a signature appearance with only an im…