I have Aspose.Total .Net License and using Aspose.Pdf .Net
In the Docs this example exists but I Do NOT want to use file or disk access only Memory Stream, is there a way for that without memory mapped files?
Document pdfDocument = new Document(“input.pdf”);
using (FileStream imageStream = new FileStream(“image.jpg”,FileMode.Create))
{ Resolution resolution = new Resolution(300); JpegDevice jpegDevice = new JpegDevice(resolution, 100);
As per my understanding, you do not want to use FileStream object and need to use MemoryStream object when saving output of PDF to Image conversion. If so is the case, then you may consider using the following code snippet to accomplish your requirements.
In case I have not properly understood your requirement or you have any further query, please feel free to contact.
[C#]
Document pdfDocument = new Document("c:/pdftest/SourceFile_Converted.pdf");
// instantiate MemoryStream object
MemoryStream imageStream = new MemoryStream();
Resolution resolution = new Resolution(300);
JpegDevice jpegDevice = new JpegDevice(resolution, 100);
jpegDevice.Process(pdfDocument.Pages[1], imageStream);
//imageStream.Close();
Console.WriteLine(imageStream.Length);
imageStream.Close();
It works! however in my web service it was always throwing this error: "Cannot access a closed Stream"
the problem was the pdfDocument stream itself is closed not the ImageStream
I mean if we read the pdfDocument from MemoryStream, we have to keep the stream open. it looks like the pdf Document does not have a copy of the content, however it is using the same MemoryStream that it was read from.
I would recommend having this piece of info in the documentation related to opening pdfDocument from MemoryStream.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.