Free Support Forum -

Converting PDF Binary to PDF document

I am trying to pull the binary of a PDF from the database and display a prompt to the screen. I am having trouble getting this to work. I am getting the error:

You are in direct-to-file mode,please use Close() instead of Save().

Please explain what I need to do in order to get this functionality.

Here is my sample code:

//ConvertBytesToPDF method is just sending the byte array to a MemoryStream

MemoryStream tempStream = ConvertBytesToPDF(PDFFiles[0].Data);<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

tempStream.Seek(0, SeekOrigin.Begin);

Pdf temppdf = new Pdf(tempStream);

temppdf.Save("output.pdf", Aspose.Pdf.SaveType.OpenInAcrobat, HttpContext.Current.Response);




I would like to share with you that Aspose.Pdf only allows you to create PDF files from scratch. If you want to load an existing PDF file then you’ll have to use Aspose.Pdf.Kit. Please share more details regarding your requirement, so we could guide you accordingly.