- Home
- Forum
- Xamarin.Forms
- Digital signature position
Digital signature position
It´s possible to get a existent PDF file and choose the position (END) of the Digital Signature ?
Because in your example, I create a new Blank Page and add the digital signature to this new page. So, if it´s a PDF file with 2 pages, will be 3 and the first 2 pages we will not have any signature or "check".
For example:
1) The user upload a PDF file with 2 pages
1) The user upload a PDF file with 2 pages
2) The user read the document
3) He wants to Digital Sign the document.
4) The app open the "Whitescreen" to sign
5) I put this signature (Image) at the End of the existent uploaded PDF file (still 2 pages).
SIGN IN To post a reply.
5 Replies
1 reply marked as answer
SL
Sowmiya Loganathan
Syncfusion Team
June 10, 2020 12:56 PM UTC
Hi Marcelo,
Thank you for contacting Syncfusion support.
We have analyzed your requirement. If your requirement is to add a digital signature in a new page (added page) of PDF document, please refer the below sample for your reference,
Note: You can set the bounds of the signature by using the below code snippet,
|
signature.Bounds = new RectangleF(new PointF(0, 0), signatureImage.PhysicalDimension); |
If this is not your requirement, please let us know further details about your requirement. It will helpful for us to provide a precise solution to this.
Regards,
Sowmiya Loganathan
MC
marcelo couto fernandes
June 11, 2020 12:01 AM UTC
Hi,
As I´ve told you, I need to add the signature to a existent page of a PDF file. Not to a new page.
I saw this example before, but it doesn´t is what I need. I upload a file and add the signature to the beginning or end of one page (first or last for example)
Thanks.
SL
Sowmiya Loganathan
Syncfusion Team
June 11, 2020 11:26 AM UTC
Hi Marcelo,
Thank you for the details.
Please find the below code snippet to add digital signature in starting of the last page in PDF document.
|
//Load the file as stream
Stream docStream =typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("GettingStarted.Assets.BlankPDF-merged.pdf");
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream);
//Get the last page of PDF document
PdfLoadedPage loadedPage = loadedDocument.Pages[loadedDocument.Pages.Count - 1] asPdfLoadedPage;
//Creates a certificate instance from PFX file with private key
Stream certificateStream =typeof(MainPage).GetTypeInfo().Assembly.GetManifestResourceStream("GettingStarted.Assets.PDF.pfx");
PdfCertificate pdfCert = new PdfCertificate(certificateStream, "syncfusion");
//Creates a digital signature
PdfSignature signature = new PdfSignature(loadedDocument, loadedPage, pdfCert, "Signature");
//Load the image file
Stream imageStream =typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("GettingStarted.Assets.logo.png");
//Sets an image for signature field
PdfBitmap signatureImage = new PdfBitmap(imageStream);
//Sets signature information
signature.Bounds = new RectangleF(new PointF(0, 0), signatureImage.PhysicalDimension);
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am author of this document.";
//Draws the signature image
loadedPage.Graphics.DrawImage(signatureImage, 0, 0);
//Save the document to the stream
MemoryStream stream = new MemoryStream();
loadedDocument.Save(stream); |
Please try the above solution in your end and let us know the result.
Regards,
Sowmiya Loganathan
Marked as answer
Hi Marcelo,Thank you for the details.Please find the below code snippet to add digital signature in starting of the last page in PDF document.
//Load the file as streamStream docStream =typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("GettingStarted.Assets.BlankPDF-merged.pdf");PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream);//Get the last page of PDF documentPdfLoadedPage loadedPage = loadedDocument.Pages[loadedDocument.Pages.Count - 1] asPdfLoadedPage;//Creates a certificate instance from PFX file with private keyStream certificateStream =typeof(MainPage).GetTypeInfo().Assembly.GetManifestResourceStream("GettingStarted.Assets.PDF.pfx");PdfCertificate pdfCert = new PdfCertificate(certificateStream, "syncfusion");//Creates a digital signaturePdfSignature signature = new PdfSignature(loadedDocument, loadedPage, pdfCert, "Signature");//Load the image fileStream imageStream =typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("GettingStarted.Assets.logo.png");//Sets an image for signature fieldPdfBitmap signatureImage = new PdfBitmap(imageStream);//Sets signature informationsignature.Bounds = new RectangleF(new PointF(0, 0), signatureImage.PhysicalDimension);signature.LocationInfo = "Honolulu, Hawaii";signature.Reason = "I am author of this document.";//Draws the signature imageloadedPage.Graphics.DrawImage(signatureImage, 0, 0);//Save the document to the streamMemoryStream stream = new MemoryStream();loadedDocument.Save(stream);Please try the above solution in your end and let us know the result.Regards,Sowmiya Loganathan
Thanks. I will give a try.
But, can I choose where will be setted the image of the signature ?
Above you put the image, but doesn´t set where...
loadedDocument.Save(stream);
SL
Sowmiya Loganathan
Syncfusion Team
June 12, 2020 01:26 PM UTC
Hi Marcelo,
You can draw the image anywhere in PDF document by specifying the position(PointF) or bounds(RectangleF). Please refer the below code snippet,
|
//Sets signature information
signature.Bounds = new RectangleF(0,0,200,100);
//Draws the signature image in page graphics
loadedPage.Graphics.DrawImage(signatureImage, signature.Bounds); |
Also, you can draw the image in signature appearance and please refer the below code snippet for more details,
|
//Sets signature information
signature.Bounds = new RectangleF(0,0,200,100);
//Draw image in signature appearance
signature.Appearance.Normal.Graphics.DrawImage(signatureImage, new RectangleF(0, 0, 200, 100)); |
Please let us know if you need any further assistance on this.
Regards,
Sowmiya Loganathan
SIGN IN To post a reply.
- 5 Replies
- 3 Participants
- Marked answer
-
MC marcelo couto fernandes
- Jun 9, 2020 04:21 PM UTC
- Jun 12, 2020 01:26 PM UTC