PdfRenderer.ExportAsImage do not export signature

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


Attachment: SouhrnnyList_35533180.zip

3 Replies

VS Vasugi Sivajothi Syncfusion Team April 22, 2022 12:46 PM UTC

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());

 



https://help.syncfusion.com/cr/file-formats/Syncfusion.Pdf.Interactive.PdfField.html#Syncfusion_Pdf_Interactive_PdfField_Flatten

https://help.syncfusion.com/file-formats/pdf/working-with-forms#removing-editing-capability-of-form-fields


We have shared the sample for your reference which can be downloaded from the below link.

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ExportAsImageWithSignature-2106126907


Kindly try this and let us know if you have any concerns about this.


Regards,

Vasugi.



DE David Eisler replied to Vasugi Sivajothi April 25, 2022 07:22 AM UTC

Hi Vasugi,


Your workaround works for me.


Regards,

David



SK Shamini Kiruba Sobers Syncfusion Team April 26, 2022 04:45 AM UTC

Hi David,


Thanks for the update.


Regards,

Shamini


Loader.
Up arrow icon