Welcome Guest Search | Active Topics | Sign In | Register

PDF to System.IO.Stream Options
Ross
Posted: Monday, October 22, 2012 11:00:38 AM
Rank: Newbie
Groups: Member

Joined: 5/13/2011
Posts: 3
How do you get a pdf you are creating to output in System.IO.Stream so you don't have to save it on the web server in order to download?

Thanks in advance.
eo_support
Posted: Monday, October 22, 2012 12:07:49 PM
Rank: Administration
Groups: Administration

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

You just call PdfDocument.Save(Stream).

Thanks!
Ross
Posted: Monday, October 22, 2012 1:15:03 PM
Rank: Newbie
Groups: Member

Joined: 5/13/2011
Posts: 3
Tried that but receive an error stating that the document is corrupt.

If I save the same output to the disk first then it works fine. (doc.Save(Request.PhysicalApplicationPath + "\pdf\" & "Aru" & lQuote.text & ".pdf"))

I'm thinking it has to be my response.

Code: Visual Basic.NET
Response.Clear()
            Response.AddHeader("content-disposition", "attachment; filename=Aru" & lQuote.Text & ".pdf")
            Response.ContentType = "application/pdf"
            doc.Save(Response.OutputStream)
            Response.[End]()
eo_support
Posted: Monday, October 22, 2012 1:24:27 PM
Rank: Administration
Groups: Administration

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

As long as you can save to disk fine, it means the PDF part is working fine and the problem is somewhere else. PdfDocument doesn't really care about what kind of streams you give to it. The code you posted appears to be fine. So you might want to see if you can get a static PDF file to send to your browser that way (read a static PDF file into a byte array and then write into Response.OutputStream) just to see if the problem is anywhere else.

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.