When I try to export pdf as an image, the signature on the top of the first page just disappears.
Do you have any suggestions?
Code:
PdfRenderer pdfRenderer = new PdfRenderer();
pdfRenderer.Load(attachment.Data);
Bitmap[] bitmapImages = pdfRenderer.ExportAsImage(0, pdfRenderer.PageCount - 1);
See attachment for input file and output image (first page).
Thank you,
David
Hi David,
Currently, there is no direct support to export the image with the digital signature. However, you can flatten the existing digital signature field by using Flatten property. Please use the below code snippet before performing export as an image action.
Code Snippet:
|
FileStream docStream = new FileStream("../../../PruvodniList-signed.pdf", FileMode.Open, FileAccess.Read);
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream);
//Gets the page
PdfLoadedPage page = loadedDocument.Pages[0] as PdfLoadedPage;
//Get the loaded form.
PdfLoadedForm loadedForm = loadedDocument.Form;
//Load the signature field from field
PdfLoadedSignatureField loadedSignatureField = loadedForm.Fields[0] as PdfLoadedSignatureField;
loadedSignatureField.Flatten = true;
//Save the document into stream
MemoryStream stream = new MemoryStream();
loadedDocument.Save(stream);
stream.Position = 0;
//Close the documents
loadedDocument.Close(true); File.WriteAllBytes("../../../FlattenField.pdf", stream.ToArray());
|
We have shared the sample for your reference which can be downloaded from the below link.
Kindly try this and let us know if you have any concerns about this.
Regards,
Vasugi.
Hi Vasugi,
Your workaround works for me.
Regards,
David
Hi David,
Thanks for the update.
Regards,
Shamini