Free Support Forum - aspose.com

Create Pdf from Stream output from PDF.Save()

Hello... I've created an Aspose.Pdf.Pdf file and saved it to a Stream. I've performed the necessary processing on the stream (saving it to the database, etc.) and would now like to reform it into an Aspose.Pdf.Pdf to do a .Save the HttpResponse object. How can I create a Pdf from a stream when the constructor only takes blank or a FileStream object?

Thanks!

Hi,

Thank you for considering Aspose.

It is not possible to get the stream and save it as file using Aspose.Pdf. Aspose.Pdf library is used to create PDF from scratch. You need Aspose.Pdf.Kit library to deal with this issue. You can use PdfViewer class of Aspose.Pdf.Kit and use OpenPdfFile(Stream) to open PDF from stream and use PrintLargePdf to save it as a PDF document.

Thanks.

Thanks for the suggestion. OK, I see how I can open an Aspose.Pdf.Pdf saved to a Stream from the .Save() method using a Kit.PdfViwer. However I don't want to print the Pdf, what I'd like to do, is return an Aspose.Pdf.Pdf so that I can send it to the user (similar to how the Apose.Pdf.Pdf class has a .Save() which takes an HttpResponse object.).

Thanks!

-Matt

Hi,

If the only reason for reading the PDF back into Aspose.Pdf.Pdf is so that you can send it to the browser then you should send the pdf directly to browser. Please consult http://blogs.msdn.com/rahulso/archive/2006/03/24/4-ways-to-send-a-pdf-file-to-the-ie-client-in-asp-net-2-0.aspx

Thanks.

Adeel,

I'm afraid we're miscommunicating. I'm saving the Aspose.Pdf.Pdf to a Stream via the Save() method. I then work with the Stream in various ways in memory - including saving it to the database - afterwhich I'd like to stream it down to the user in a clean fashion like the other overloaded methods of .Save(). I don't want to save the stream to a file, as this blog suggests, and would prefer to do it all from memory.

Any ideas?

Hi,

Aspose.Pdf supports creating PDF from scratch only. When you save the resulting PDF into stream, you CAN NOT reload it with Aspose.Pdf.Pdf object. That means after saving the PDF into stream, you have to send the stream to browser by yourself.

Tommy, thanks - that is what I wanted to make sure of. Sorry for the confusion.

Thanks to both of you!