I need to convert a PDF to JPEG (or any other image format as PNG…) with C#
I have the path to the PDF and I want to obtain a MemoryStream of the image.
I managed to do it with Ghostscript and GhostscriptSharp but I’m forced to create a file, the actual image, and then read this file to create the MemoryStream.
Can I do it without this step?
Thanks
Yes, but you will need to interface directly to Ghostscript using the Ghostscript DLL (I’m assuming Windows since you mention C#).
The simplest solution is probably to use the display device which sends an in-memory bitmap back to the parent application, the default GS application then creates a window and a device context, and draws the bitmap in it.
You should be able to use the GS application as a starting point to see how this is done, and you don’t need to create a device of your own which means you don’t need to recompile the Ghostscript binary.