Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Extracted Signature Images Are in Black and White

$
0
0
Hello,

When I extract signature images from a pdf, the resulting images are in black and white. For example, if the image is blue with transparent background, the result would be a white image with a black background. Same for black signatures where the background becomes black and the signature becomes white. Note that the original signatures are in Png format.

This is the code that I'm using to extract the signatures:

     int count = 0;
            using (Document pdfDocument = new Document(pdfPath))
            {
                foreach (Field field in pdfDocument.Form)
                {
                    SignatureField sf = field as SignatureField;
                    if (sf != null)
                    {
                        count++;
                        String outFile = String.Format("{0}\\Signature Image-{1}.png", destinationPath, count);
                        using (Stream imageStream = sf.ExtractImage())
                        {
                            if (imageStream != null)
                            {
                                using (System.Drawing.Image image = Bitmap.FromStream(imageStream))
                                {
                                    image.Save(outFile, ImageFormat.Png);
                                }
                            }
                        }
                    }
                }
            }

Is there any way to keep the colors as they were?
Thank you.

Viewing all articles
Browse latest Browse all 3131

Trending Articles