How do I add either text or an image, or both to a digital signature for a PDF file?
I have seen in the Documentation some hints about an image, but I would like to reference a Stream instead of a simple file name.
I have also seen that in PdfFileSignature.Sign, I can specify “Reason”, “Contact”, and “Location” text, but I have also seen the ability for custom/free text in digital signatures. Unfortunately, I can’t find anything in the Documentation or in the code about that.
jay_bp:How do I add either text or an image, or both to a digital signature for a PDF file?
Hi,
Thanks for using our products and sorry for replying you late.
You can specify the text and image with the digital signature when adding it to PDF document. Use PdfFileSignature.SignatureAppearance property to specify the path of image file that you need to display. In order to display text, you may try using either of the Sign overloaded method of PdfFileSignature class.
jay_bp:I have seen in the Documentation some hints about an image, but I would like to reference a Stream instead of a simple file name.
I am afraid the requested feature is currently not supported but for the sake of implementation, I have logged this requirement in our issue tracking system under New Features list as PDFNEWNET-30887. We will investigate this issue in details and will keep you updated on the status of a correction.
Can you please share some details regarding this requirement. We apologize for your inconvenience.jay_bp:I have also seen that in PdfFileSignature.Sign, I can specify "Reason", "Contact", and "Location" text, but I have also seen the ability for custom/free text in digital signatures. Unfortunately, I can't find anything in the Documentation or in the code about that.
codewarior:Can you please share some details regarding this requirement. We apologize for your inconvenience.jay_bp:I have also seen that in PdfFileSignature.Sign, I can specify "Reason", "Contact", and "Location" text, but I have also seen the ability for custom/free text in digital signatures. Unfortunately, I can't find anything in the Documentation or in the code about that.
The PdfFileSignature.Sign function places text like:
Digitally signed by 'E=XXXX, CN=XXXX, OU=...'I am wondering if I can place custom text on the signature instead.
Date: 2011.09.28 01:01:01 -03:00
Reason: Some reason
Location: undefined
This example text
Does not exactly conform
To above format
jay_bp:
The PdfFileSignature.Sign function places text like:Digitally signed by 'E=XXXX, CN=XXXX, OU=...'I am wondering if I can place custom text on the signature instead.
Date: 2011.09.28 01:01:01 -03:00
Reason: Some reason
Location: undefined
This example text
Does not exactly conform
To above format
Hi,
Thanks for sharing the details. I am afraid the requested feature is currently not supported. However for the sake of implementation, I have logged this requirement as PDFNEWNET-30991 in our issue tracking system. We will further look into the details of this feature and will keep you posted on the status of correction. Please be patient and spare us little time.
Besides this, I am pleased to share that the requirement requested earlier 'PdfFileSignature.SignatureAppearance property should also accept stream' has been implemented and it will be included in our upcoming release version which is expected to be released by first week of October2011. Please be patient and wait for the new version.
Hi,
Thanks for your patience.
I am pleased to share that the requirement of using stream object to reference the SignatureAppearance image will become available in our upcoming release version 6.3.0. Please take a look over the following code snippet that you will use the reference stream image.
[C#]
PdfFileSignature pdfSign = new PdfFileSignature(@“test.pdf”, @“signed.pdf”);
PKCS1 signature = new PKCS1(@“temp.pfx”, “temp”);
pdfSign.Sign(1, true, new System.Drawing.Rectangle(100, 100, 200, 50), signature);
FileStream fs = new FileStream(“butterfly.jpg”, FileMode.Open);
pdfSign.SignatureAppearanceStream = fs;
pdfSign.Save();
Please note that old property PdfFileSignature.SignatureAppearance will remain without any change, however setting SignatureAppearanceStream will reset SignatureAppearance and Vice-versa.
The issues you have found earlier (filed as 30887 ) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.
Hi,
In order to suppress showing standard signature properties Boolean Signature.ShowProperties property was created. The code snippet specified below demonstrates basic idea:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
[C#]
string inFile = TestSettings.GetInputFile("PdfWithText.pdf");
string outFile = TestSettings.GetOutputFile("SignUsingUserSignature.pdf");
PdfFileSignature pdfSign = new PdfFileSignature(inFile, outFile);
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(100, 100, 200, 100);
PKCS7 signature = new PKCS7(TestSettings.GetInputFile("test1.pfx"), "test1");
signature.ShowProperties = false;
// draw signature
System.Drawing.Bitmap bmp = new Bitmap(TestSettings.GetInputFile("butterfly.jpg"));
System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(bmp);
System.Drawing.Font font = new System.Drawing.Font("Arial", 24);
System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.Yellow);
gr.DrawString("This example text", font, brush, 10F, 10F);
gr.DrawString("Does not exactly conform", font, brush, 10F, 50F);
gr.DrawString("To above format", font, brush, 10F, 100F);
FileStream fsIn = new FileStream(TestSettings.GetOutputFile("SignUsingUserSignatureIn.jpg"), FileMode.Create);
bmp.Save(fsIn, System.Drawing.Imaging.ImageFormat.Jpeg);
pdfSign.SignatureAppearanceStream = fsIn;
// ---
pdfSign.Sign(1, "Allen", "success", "ChangSha", true, rect, signature);
pdfSign.Save();
fsIn.Close();
Please notice the the usage of new (recently added) property SignatureAppearanceStream. Now you can draw on any stream, code snippet utilizes FileStream, but you can use MemoryStream and other Stream descendants. This properly is available in our upcoming release version of Aspose.Pdf for .NET 6.4.0 which is expected to be released in a day or two. Please be patient and wait for the new release version.
The issues you have found earlier (filed as 30991) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.