Hello, i need to edit a pdf by adding a signature that i´ve got from your signature pannel, but i cant find a way of converting my existing pdf document into the pdf object and then add the signature at the bottom right of the doc.
Tried to convert it from a byte array but it doesn´t work and with the append method but it doesn´t work either
You can load the signature field from the existing PDF document using PdfLoadedSignatureField class and add certificate to the document using PdfCertificate class in Maui.
|
Assembly assembly = typeof(MainPage).GetTypeInfo().Assembly; string basePath = "PdfSampleMaUI.Resources.Fonts."; Stream docStream = assembly.GetManifestResourceStream(basePath + "Input.pdf");
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); //Gets the first page of the document PdfLoadedPage page = loadedDocument.Pages[0] as PdfLoadedPage; //Gets the first signature field of the PDF document PdfLoadedSignatureField field = loadedDocument.Form.Fields[0] as PdfLoadedSignatureField;
//Creates a certificate FileStream certificateStream = new FileStream("PDF.pfx", FileMode.Open, FileAccess.Read); PdfCertificate certificate = new PdfCertificate(certificateStream, "password123"); field.Signature = new PdfSignature(loadedDocument, page, certificate, "Signature", field);
//Save the document into stream MemoryStream stream = new MemoryStream(); loadedDocument.Save(stream); stream.Position = 0; //Close the document loadedDocument.Close(true); //Defining the ContentType for pdf file string contentType = "application/pdf"; //Define the file name string fileName = "Output.pdf"; //Creates a FileContentResult object by using the file contents, content type, and file name return File(stream, contentType, fileName); |
We have attached a sample for your reference, please try this on your end and let us know the result.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/PdfSampleMaUI1561909265
If still you are facing an issue, we request you to share the modified sample and steps to replicate the issue on our end. So that we can assist you further in this.
Hello! Thanks for the fast reply, but i still have the same problem. I was looking in the example and realised that i may have committed a mistake on the question of the forum. What i need is to implement a signature from your signaturepad into a pdf that already exists. https://help.syncfusion.com/maui/signaturepad/getting-started This one.
And the pdfCertificate object it´s used to protect the pdf?
We regret any inconvenience caused. We are currently analyzing the reported behavior with the provided details on our end. Meanwhile, we request you share a simplified sample to replicate the issue on our end. so that we can assist you further in this.
Note: we maintain the confidentiality of the information disclosed by our customers to us. Therefore, any documents shared with Syncfusion will only be used to replicate the issue and will not be shared with anyone else. So kindly share the original input document or share the input document after removing confidential information.
Hello! I´ve already managed to make it work!. Thank you!