I'm creating a LotusScript web agent that reads the content of a pdf file somewhere on the network and returns it as a stream to the browser.
the agent will be called like this : getPDF?openAgent&pdfId=123456
and it should directly returns the pdf stream. (I didn't implement yet the url parameter catching)
Here's my current try, I still have an issue to convert the read buffer to the final stream
Sub Initialize
On Error GoTo errrorhandle
Dim session As New NotesSession
Dim stream As NotesStream
Set stream = session.CreateStream
Dim buffer As variant
Dim fileNum As Integer
Dim txt As String
Dim filename As String
Dim filecontent As String
filename = "C:\temp\test.PDF"
If Not stream.Open(filename,"binary") Then
MessageBox filename,, "Open failed"
Exit Sub
End If
If stream.Bytes = 0 Then
MessageBox filename,, "File has no content"
Exit Sub
End If
Print "content-type:application/pdf"
Do
buffer = stream.read(1)
Print buffer(0)
Loop Until stream.IsEOS
Call stream.Close
Exit Sub
errrorhandle :
Print "Error :" & Error & " at line : " & Erl
Exit sub
End Sub