Free Support Forum - aspose.com

Pdf from disk to browser

I want to load a previously saved pdf file from disk into an Aspose.pdf object and then stream it to the browser.

At the moment the only way I found to load the object was to use the pdf(filestream) overloaded constructor. (Is this the only way to do this)?

However upon trying to call the 'save' method as I normally do to stream to the httpresponse, I get a runtime error about using the close method instead.

Should I be doing something else, like converting to a byte array and streaming? How would I accomplish this from the object?

Thanks.

Hi,

Thank you for considering Aspose.

It is not supported to load existing PDF into Aspose.Pdf.Pdf object. If you just want to stream the PDF to browser, you can load it into a stream and send the data to browser like the following:

Response.Clear();
Response.ClearContent();
Response.ClearHeaders();

Response.AddHeader("content-disposition","inline; filename=" + fileName);
Response.ContentType = "application/pdf";

Response.BinaryWrite(binaryDataOfThePdf);

Response.Flush();
Response.End();

Thanks for the feedback.

This would be a great feature to have since docs might be stored in pdf format (acrobat forms for instance) and to make use of Aspose.pdf you would have to convert to html or Word or something first, then to Aspose.pdf. correct? I know the toolkit has some options for filling in pdf forms but how to get it there is the problem.

Hi,

I agree with you that it is a usful feature but it is very difficult to load a PDF and edit it with Aspose.Pdf. You can only used Aspose.Pdf.Kit to load the PDF and currently some basic editting features are supported.