Hi,
I know if I can put digital signature with these codes line :
Dim license As Aspose.Pdf.License = New Aspose.Pdf.License
license.SetLicense(“Aspose.Total.lic”)
Dim pdfSign As New PdfFileSignature()
pdfSign.BindPdf("source.pdf")
Dim signature As New PKCS1("JoeSigner.pfx", "password123")
pdfSign.Sign(1, True, New System.Drawing.Rectangle(100, 100, 200, 50), signature)
Dim fs As New FileStream("signature.jpg", FileMode.Open)
pdfSign.SignatureAppearanceStream = fs
pdfSign.Save("result.pdf")
but I want something dynamically rather set position of digital signature with this code:
System.Drawing.Rectangle(100, 100, 200, 50),
I would like to make it automatically set into near position where some object exist. For eg where the mail merge field XXXX exist.
similar question has been asked and answered perfectly at How to get the textbox in mailmerge field
unfortunately it is with aspose.word. But might be give you an idea what I’m looking for.
Please any suggestion with sample codes will be appreciated.
Thanks in advance.
Hi Dicky,
Thanks for your inquiry. You may find the object e.g. Textbox field, and use its position for adding signature. Please check following code snippet. My sample document has a textboxfield, I used its position to add signature. Hopefully it will help you to accomplish the task.
'open document<o:p></o:p>
Dim pdfDocument As New Document(myDir + "Form_Test.pdf")
'get a field
Dim textBoxField As TextBoxField =
TryCast(pdfDocument.Form("ExtraCycles"),
TextBoxField)
' get existing position
Dim rect1 As Aspose.Pdf.Rectangle
= textBoxField.Rect
'create PdfFileSignature object and
bind input and output PDF files
Dim pdfSign As New PdfFileSignature()
pdfSign.BindPdf(myDir + "Form_Test.pdf")
'create a rectangle for signature
location
Dim rect As New
System.Drawing.Rectangle(CInt(rect1.LLX), CInt(rect1.LLY) - 30, CInt(rect1.URX)
- CInt(rect1.LLX), CInt(rect1.URY) - CInt(rect1.LLY))
'set signature appearance
pdfSign.SignatureAppearance = myDir + "imgLogoPdf1.png"
'create any of the three signature
types
Dim signature As New PKCS1(myDir + "temp.pfx", "password")
' PKCS#1 or
signature.ShowProperties = False
pdfSign.Sign(1, "Signature
Reason", "Contact", "Location", True, rect, signature)
pdfSign.Save(myDir + "signaturetest.pdf")
Please feel free to contact us for any further assistance.
Best Regards,