Search code examples
c#pdfsyncfusion

How to convert byte[] to PdfBitmap?


I'm using SyncFusion to create PDFs and was wondering how I could convert an array byte I have of a signature that was drawn on a canvas in XAML/C# to a PdfBitmap. So I could add the signature to the PDF document.

//requires stream of a file, but I only have a byte array
PdfBitmap image = new PdfBitmap(stream);
graphics.DrawImage(image, 0, 0);

Solution

  • You can find your answer in @Patrick McDonald comment. However, for further reference, here it is what you need:

    Stream stream = new MemoryStream(byteArray);
    PdfBitmap image = new PdfBitmap(stream);
    graphics.DrawImage(image, 0, 0);