Welcome Guest Search | Active Topics | Sign In | Register

Displaying PDFDocument in WebBrowser Control Options
Louis
Posted: Sunday, March 27, 2016 4:30:56 PM
Rank: Newbie
Groups: Member

Joined: 7/7/2012
Posts: 2
Tyring to load a PDFDocument from Steam to an EO.WebBrowser.WeView
using VB.net

Here is my code
Code: Visual Basic.NET
Public Overrides Sub ProcessRequest(request As Request, response As Response)
        If String.Compare(request.Url, EmbeddedPageUrl, True) = 0 Then
            Dim doc As New PdfDocument("C:\Temp\test__22_.pdf")
            Dim Stream As IO.MemoryStream
            response.Headers.Clear()
            response.Headers.Add("Content-Type", "application/pdf")
            response.Headers.Add("Contect-Disposition", "attachment;filename= Page001.pdf;")
            doc.Save(response.OutputStream)
            response.OutputStream.Flush()

        End If
    End Sub
End Class


If I load the url with the disk address direct the page loads fine
but from the stream I only get a small white rectangle in the middle of the screen
Any suggestion as to what I am doing wrong
eo_support
Posted: Monday, March 28, 2016 8:43:02 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

You do not need to load the contents into a PdfDocument and then save it back to the OutputStream. You can just write a loop to copy the contents of your intput stream directly to the output stream.

Thanks
Louis
Posted: Monday, March 28, 2016 8:48:15 AM
Rank: Newbie
Groups: Member

Joined: 7/7/2012
Posts: 2
This was just for example. in production the stream comes from the cloud and is never written to disk.
My point is this code fails to properly load the pdf in the webbrowser and I am looking for a code example that works with your current version of code
Thanks
eo_support
Posted: Monday, March 28, 2016 8:52:05 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

I don't think there is anything particular in our code regarding where the bytes come from. You give us 10 bytes and we pass that 10 bytes down to the browser engine. You give us 20 bytes and we pass 20 bytes. So the only reason that I can think of is the bytes you pass to us are wrong since we do not alter them in anyway. If however you use a PdfDocument to load and save them, then the bytes will be altered by the PdfDocument object. That's why I asked you to leave that out first.

If you still have problem, you can try to save the content of your stream to a real PDF file and then check that file. Most likely that file will be wrong.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.