Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
Streaming the PDF document directly to the browser |
Post Reply
|
| Author | |
Halv
Beginner
Joined: 17 Sep 12 Status: Offline Points: 9 |
Post Options
Thanks(0)
Quote Reply
Topic: Streaming the PDF document directly to the browserPosted: 20 Sep 12 at 10:50PM |
|
Greetings,
As the subject says, I found the FAQ for "Streaming the PDF document directly to the browser" and trying to get this to work in C#/ASP. The code works but when I click on the button to generate the PDF it brings up a window to save the PDF file instead of streaming the document directly to the browser. This is what I am using. qp.CompressContent(); Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", "attachment; filename=test.pdf"); Response.BinaryWrite(qp.SaveToVariant()); Response.End(); I want this to stream the PDF to the browser. If anyone could help me out I would greatly appreciate it. Halv
|
|
![]() |
|
AndrewC
Moderator Group
Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
Quote Reply
Posted: 21 Sep 12 at 3:08AM |
|
I assume you are using the ActiveX version of Quick PDF Library. I have no experience with ASP.net but they are writing their data to Reponse.OutputStream ? Your code looks like it should work also. Andrew.
Edited by AndrewC - 25 Sep 12 at 2:26AM |
|
![]() |
|
samb
Beginner
Joined: 09 Feb 11 Status: Offline Points: 8 |
Post Options
Thanks(0)
Quote Reply
Posted: 24 Sep 12 at 5:46PM |
|
I believe the important part is changing attachment to inline in Content-Disposition. Not sure if all the flushing and clearing is required, but this is what I have used in the past and it seems to work ok.
Response.Clear(); Response.ClearHeaders(); Response.ClearContent(); Response.Buffer = true; Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", "inline;filename=" + fileName);Response.AddHeader("Content-Length", fileContents.Length.ToString()); Response.Flush(); Response.BinaryWrite(fileContents); Edited by samb - 24 Sep 12 at 5:50PM |
|
![]() |
|
Halv
Beginner
Joined: 17 Sep 12 Status: Offline Points: 9 |
Post Options
Thanks(0)
Quote Reply
Posted: 25 Sep 12 at 1:39AM |
|
Greetings,
Thanks samb! Your line of code got it working the way I wanted so now the PDF file shows up on the browser instead of prompting to save. Regards, Halv
|
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() 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 |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store