Hi Aspose support, having an issue with convert a small (10kb) jpg file (attached) to save as PDF, it is consuming tons of memory.
Is there a known issue?
Here is the code, memory issue occurred on the Save:
Public Shared Sub ConvertToPdf(inputStream As Stream, outputStream As Stream, type As String)
Dim pdfDoc As New Aspose.Pdf.Document()
Dim page As Aspose.Pdf.Page = pdfDoc.Pages.Add()
Dim image As System.Drawing.Image = System.Drawing.Image.FromStream(inputStream)
'Create an image object in the section
Dim image1 As Aspose.Pdf.Image = New Aspose.Pdf.Image()
'Set margins so image will fit, etc.
page.PageInfo.Width = image.Width + 100
page.PageInfo.Height = image.Height + 100
'Add image object into the Paragraphs collection of the section
page.Paragraphs.Add(image1)
image1.ImageStream = inputStream
'Save the Pdf
**pdfDoc.Save(outputStream)**
End Sub
Attached is a zipped IISMemory.zip (5.7 MB)
recording of the issue that my client shared with us, but I am seeing the same issue on my computer as well.
I traced the issue to the call to save: pdfDoc.Save(outputStream), memory just spikes and seems to just hang.
The video is very clear about how much memory is consumed. But if I submit a ticket, I will be asked what other code is triggered besides the one in the snippet.
Anything else, you want to add before I create a ticket?
There are other codes in the application before getting to the ConvertToPdf, but none of them affected memory usage. Attached a sample of much larger image file (21MB) that has no issue, here is the link:
I am not the person involved with keeping track of the license, but since we are using 20.4, I assume we can’t use 23.4. Basically I am getting an error when using using the SetLicense method with our existing license file.
That it is why it is important to see if the issue has been solved already.
Fixed are not implemented in old code, only in the current version.
I was not able to replicate the issue like the one you showed in your machine. But if the video recorded is from code that is using the latest API version, I can submit that.
Otherwise it will be a waste of time for you because the first response will be to update to the latest API.
EDIT: Also, keep in mind you can use that you can use the code without a valid license, but it will inject some stamps that will take even more memory and time, so for the purpose of this analisys is not the optimal path to follow.
Remember that the code you are using is behind multiple minor releases and 3 major ones.
I was able to use the latest version now, but now it returns an error “Page have not room to place a paragraphs” saving the small image file. Attached are links to the saved PDF for the much larger file I shared earlier:
20.4:
Removing the 2 lines of code works, even with version 20.4, but we had those 2 lines of codes for a long time and it only encounter the issue with this particular images. Will your developer be able to determine the actual cause?
Is there issue with the width to height ratio of the image file. I took a HD (6110x3680) photo, NGTAPRIL16_NB23.jpg that I shared in the earlier thread and cropped it to 456x42 (see attached) NGTAPRIL16_NB23-Edited.jpg (7.1 KB)
and it has the same memory issue.