We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem Opening Pdf from File Stream to Acrobat

Hi,
I am trying to open a pdf in Acrobat from a memory stream using the “save” method but I keep getting the following error message: You are in direct-to-file mode,please use Close() instead of Save().

The same code worked fine when we were running our application on .Net 2.0, but now that we have upgraded to 3.5, this is one of the problems I am running into. Let me know if you need to see the code files. There was no problem in the previous version, although.

Thank you,
Susan

Hi Susan,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please share the template file and sample code to show the issue. This will help us identify and resolve the issue soon.

Thank You & Best Regards,

Here are the files.

We were able to solve the problem. Here is the revised code:

Sub GetPropCover()

Dim iBudg_id As Integer = GetBudgID()
Dim oCover As LFCoverSheet = New LFCoverSheet(iBudg_id)
oCover.MakeCoverSheet()

Dim memStr As MemoryStream = New MemoryStream
oCover.SaveDoc(memStr, “pdf”)

memStr.Seek(0, SeekOrigin.Begin)
Dim data() As Byte = memStr.GetBuffer
Dim sFN As String = “CoverSheet” & iBudg_id & “.pdf”
LFAsposeHTTPSave.SavePDF(memStr.GetBuffer(), Me.Response, sFN)

End Sub

Public Shared Sub savePDF(ByVal buff As Byte(), ByVal response As HttpResponse, ByVal fn As String)
response.Clear()
response.ContentType = “application/pdf”
response.AddHeader(“content-disposition”, “attachment; filename=” & fn)
response.BinaryWrite(buff)
response.End()

End Sub