|
signature.Bounds = new RectangleF(new PointF(0, 0), signatureImage.PhysicalDimension); |
|
//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); |
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
|
//Sets signature information
signature.Bounds = new RectangleF(0,0,200,100);
//Draws the signature image in page graphics
loadedPage.Graphics.DrawImage(signatureImage, signature.Bounds); |
|
//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)); |