I’m writing a websercive in C# that will generate pdf-files and send back to the caller as a byte[]. The pdf file is generated using a third party component, but I’m struggling with the conversion. The pdf is just an in-memory object in the web service, and I can’t find any good way of converting the generated pdf to a byte[] before returning it to the caller. Any advice on this?
Edited for clarification:
I’m working with a pdf in-memory object (Aspose.pdf Pdf-object to be precise) which is constructed in the webservice using the data sent in to the web service. It is never saved by the webservice, the caller should convert the byte[] back to a pdf-file and save it on their end.
If the PDF library allows to save to a stream, you can stream it to a
MemoryStream– from this you can get yourbyte[]by callingGetBuffer.