Reputation: 17492
I'm using a generic C# wrapper to render images from PDFs after a user uploads a file and I'm wondering whether its possible to configure the wrapper to work with byte arrays rather than actual files on disk as this will save me an extra trip and increase my application's performance. Ideally I want to pass a byte array of the PDF and have it return a byte array. I had look at the wrapper code and I can't figure out how exactly (if even possible) I would do this. So is it possible? If so any guidance as to where I should start?
Thanks.
Upvotes: 1
Views: 2321
Reputation: 9338
The wrapper you are using is pure wrapper does not provide you what you need. Take a look at Ghostscript.NET managed Ghostscript wrapper (full implementation) which allows you to run interpret prolog / postscript and multiple instances of Ghostscript library at a same time if you have a need to process multiple pdf's at a same time. There is a class GhostscriptViewerPdfFileHandler which demonstrates you how to manipulate pdf through the interpreter. Everything you need can be done.
Upvotes: 1
Reputation: 31199
You can't feed a sequence of bytes to the Ghostscript PDF interpreter, nor read back a PDF file as a sequence of bytes produced by the pdfwrite device.
The reason is simply that the PDF interpreter, and the PDF writer, both need random access to the file in order to interpret/create the file. If the whole file were held in memory then it would be possible to do so, but that would be a severe limitation on the size of files.
Upvotes: 2