even i am facing the same problem and after trying your solution also i am getting the (open/Save dialog) when i try to open a pdf file from DB. can you help me on this...
my code is...
if (Request.QueryString["QuestionID"] !=
null)
{
long FileID =
long.Parse(Request.QueryString["QuestionID"]);
DataTable dtbl_Attachment = Table2.Select(FileID);
string sContentType=string.Empty;
string sHeader1 =
string.Empty;
string sHeader2 =
string.Empty;
if (dtbl_Attachment.Rows[0]["FileType"].ToString().ToUpper().Equals("PDF"))
i m trying to send my report to pdf in .net. i get the pdf file on the screen. what my prob is that when i close the pdf, i get blank web page. any help
is appreciated. Thanks in advnce. pls guide me with proper code.
sbadriprasad
Member
274 Points
305 Posts
Re: Problem Streaming PDF File to IE Browsers
Sep 03, 2007 05:58 AM|LINK
hi,
even i am facing the same problem and after trying your solution also i am getting the (open/Save dialog) when i try to open a pdf file from DB. can you help me on this...
my code is...
if (Request.QueryString["QuestionID"] != null){
long FileID = long.Parse(Request.QueryString["QuestionID"]); DataTable dtbl_Attachment = Table2.Select(FileID); string sContentType=string.Empty; string sHeader1 = string.Empty; string sHeader2 = string.Empty; if (dtbl_Attachment.Rows[0]["FileType"].ToString().ToUpper().Equals("PDF")){
sContentType = "application/octet-stream";sHeader1 =
"content-disposition"; sHeader2 = "inline; filename=MyPDF.PDF";}
else if (dtbl_Attachment.Rows[0]["FileType"].ToString().ToUpper().Equals("DOC")){
sContentType =
"application/msword"; sHeader1 = "content-disposition";sHeader2 = "inline; filename=MyDoc.DOC";}
else if (dtbl_Attachment.Rows[0]["FileType"].ToString().ToUpper().Equals("XLS")){
sContentType =
"application/x-excel"; sHeader1 = "content-disposition";sHeader2 = "inline; filename=MyExcel.XLS";}
else if (dtbl_Attachment.Rows[0]["FileType"].ToString().ToUpper().Equals("TXT")){
sContentType =
"text/plain"; sHeader1 = "content-disposition";sHeader2 = "inline; filename=MyTXT.TXT";}
else if (dtbl_Attachment.Rows[0]["FileType"].ToString().ToUpper().Equals("RTF")){
sContentType =
"application/rtf"; sHeader1 = "content-disposition";sHeader2 = "inline; filename=MyRTF.RTF";}
elsesContentType =
"application/pdf"; byte[] bData = ((byte[])dtbl_Attachment.Rows[0]["FileContent"]);Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = sContentType;
Response.AddHeader(sHeader1, sHeader2);
Response.AddHeader("content-length", bData.Length.ToString());Response.Charset =
"";Response.BinaryWrite((
byte[])dtbl_Attachment.Rows[0]["FileContent"]);Response.Flush();
Response.End();
}
}
Judyjoy
Member
2 Points
1 Post
Re: Problem Streaming PDF File to IE Browsers
Sep 10, 2007 11:44 AM|LINK
Hi Lordshaper,
Looks like a strange solution, but it works!
I had the same problem. I appended .pdf to my url, as you mentioned in your post and now everything works like a charm! Thanks for your post!
jmace
Member
99 Points
91 Posts
Re: Problem Streaming PDF File to IE Browsers
Sep 12, 2007 06:44 PM|LINK
I'm trying to stream a PDF to the user, but all it does is just bleep. Any ideas?
Flying Ace Enterprises LLC
jezanet
Member
2 Points
1 Post
Re: Problem Streaming PDF File to IE Browsers
Oct 04, 2007 02:23 AM|LINK
I had a similar issue with the document being corrupted when streaming the pdf directly to the user, so it didn't need to touch the disk.
In the end all i needed was a
response.flush
resonse.close
response.end
I was not including the .flush and .close only the .end, once i added these it was all good.
chirag_madi
Member
4 Points
2 Posts
Re: Problem Streaming PDF File to IE Browsers
Nov 01, 2007 09:47 AM|LINK
objReport.SetDataSource(dt)
Dim s1 As System.IO.MemoryStream = objReport.ExportToStream(ExportFormatType.PortableDocFormat)With HttpContext.Current.Response.ClearContent()
.ContentType =
"application/pdf" .AddHeader("Content-Disposition", "inline; filename=Report.pdf").BinaryWrite(s1.ToArray)
.Flush()
.Close()
End Withtry this code for the your problem it'll really helps you
manjirishevd...
0 Points
1 Post
Re: Problem Streaming PDF File to IE Browsers
Sep 26, 2008 12:42 PM|LINK
hello all,
i m trying to send my report to pdf in .net. i get the pdf file on the screen. what my prob is that when i close the pdf, i get blank web page. any help
is appreciated. Thanks in advnce. pls guide me with proper code.
asuranceturi...
Member
2 Points
1 Post
Re: Problem Streaming PDF File to IE Browsers
Mar 05, 2013 12:06 PM|LINK
WORKING FOR ME !!!!
Problem: IE6 6.0.2900.5512 doesn't show pdf file content (stream)
I just add the parameter file=xxx.pdf at the end of querystring and the problem was solved.
Thank you
Roberto