I have some problems converting from a PDF page to image using Spire.Officefor.NETStandard (on versions 8.4.0 and 8.6.0). I have the following code snippet, but the code seems to run into problems when it reaches the SaveAsImage method. It simply hangs for some time until I get a timeout on my request. I've noticed when debugging that the debugger allocates a pretty significant amount of memory when trying to convert the PDF page. It goes from about 10MB to 32GB. I therefore suspect that this has something to do with a memory leak, however I'm not entirely sure. I've attached a sample file in which I experience this bug.
- Code: Select all
using (var inputStream = new MemoryStream(Convert.FromBase64String(inputDoc.Content)))
using (var doc = new PdfDocument(inputStream))
{
for (int i = 0; i < doc.Pages.Count; i++)
{
using var imgStream = doc.SaveAsImage(i);
var img = PdfImage.FromStream(imgStream);
var size = new SizeF(img.Width, img.Height);
var page = _outputDocument.Pages.Add(size);
img.Draw(page.Canvas);
}
}