Free Support Forum - aspose.com

How to write pdf stream to pdf file

var ostream = new MemoryStream();

oFinalDocument.Save(ostream, SaveFormat.Pdf);

return ostream.ToArray();

byte[] footNoteData = null;

byte[] footNoteData = ostream.ToArray();

--now how to write tht byte to pdf file----here ostream is getting in byte

how to write pdf stream to pdf file?

Hi Deepi,

If you do not want to perform any other operations on the PDF file then you can use the .NET code to save the byte array to PDF file on the disk. Please see the following code snippet:


FileStream fileStream = new FileStream(“output.pdf”, FileMode.Create);

fileStream.Write(footNoteData, 0, footNoteData.Length);

fileStream.Close();


I hope this helps. If you find any further questions, please do let us know.
Regards,

can u pls let me know..using aspose.pdf is it possible to write pdf stream to pdf file?

actually ur code shows tht with out using aspose.pdf........just using file stream we are doing ....

is it the right way to do using aspose?

Hi Deepi,

As I shared on Live Chat, it is not feasible to pass the byte array directly to the Aspose.Pdf. However, if you convert it to MemoryStream then you can pass this MemoryStream to Aspose.Pdf and save it as a PDF file. As your output is already in MemoryStream you do not need to first convert the stream to byte array and then back to stream. You can directly pass the first output stream to Aspose.Pdf. Please try Aspose.Pdf.Facades.PdfFileInfo class to pass this stream and then save the output PDF file.

I hope this helps. If you find any further questions, please do let us know.
Regards,