Convert pdf to png in c#

image of bottom in pdf file is not created in png file.

  • c# code
public bool SavePage(MemoryStream pageStream, string fileName, string companyId)
        {
            try
            {

                CloudBlob blob;
                var imageProcess = new ImageProcess();
                Stream pdfStream = new MemoryStream();

                blob = blobContainer.GetBlobReference(fileName + ".PDF");
                blob.DeleteIfExists();
                blob.UploadFromStream(pageStream);

                Document pdfDoc = new Document(pageStream);

                Resolution resolution = new Resolution(100);
                PngDevice pngDevice = new PngDevice(resolution);
                Stream imageStream = new MemoryStream();

                pngDevice.Process(pdfDoc.Pages[1], imageStream);

                System.Drawing.Image image = System.Drawing.Image.FromStream(imageStream);
                image.Save(imageStream, ImageFormat.Png);
                imageStream.Seek(0, SeekOrigin.Begin);

                blob = blobContainer.GetBlobReference(fileName + ".PNG");
                blob.UploadFromStream(imageStream);


                Stream imageThumbStream = new MemoryStream();
                image.Save(imageThumbStream, ImageFormat.Gif);

                imageThumbStream = imageProcess.CreateThumbnail(imageStream, 100, 100);
                imageThumbStream.Seek(0, SeekOrigin.Begin);

                blob = blobContainer.GetBlobReference(fileName + ".GIF");
                blob.UploadFromStream(imageThumbStream);

                imageThumbStream.Close();

                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

@koreaus1
For a long time I tried to reproduce the code you provided. Then, with a simplified code, I reproduced the error.

var docStream = new MemoryStream(File.ReadAllBytes(myDir + "TestForm_Lay.pdf"));
var pdfDoc = new Document(docStream);

var resolution = new Resolution(100);
var pngDevice = new PngDevice(resolution);

var imageStream = new FileStream(myDir + "TestForm_Lay-result.png", FileMode.Create);

pngDevice.Process(pdfDoc.Pages[1], imageStream);

And with this code I will set the task for the development team.
Thank you for writing to us.

@koreaus1
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-54298

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.