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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Streaming the PDF document directly to the browser
  FAQ FAQ  Forum Search   Register Register  Login Login

Streaming the PDF document directly to the browser

 Post Reply Post Reply
Author
Message
Halv View Drop Down
Beginner
Beginner


Joined: 17 Sep 12
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote Halv Quote  Post ReplyReply Direct Link To This Post Topic: Streaming the PDF document directly to the browser
    Posted: 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
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 21 Sep 12 at 3:08AM
I assume you are using the ActiveX version of Quick PDF Library.

According to this your approach is correct..


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
Back to Top
samb View Drop Down
Beginner
Beginner


Joined: 09 Feb 11
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote samb Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Halv View Drop Down
Beginner
Beginner


Joined: 17 Sep 12
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote Halv Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store