Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 2nd, 2005, 05:35 AM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Opening of New Window to show a .pdf report

The Background:
---------------
1. A user clicks on a Menu 'List of Employees' and my menu.aspx page redirects him to 'ListofEmployees.aspx'.
2. In this page, I ask for From-To Employee No. range e.g. say 125 to 167.
3. I Then access database, use dataset, sqldataadapter *.rpt etc. and create a crystal report.
4. Here, itself, I export this report to Acrobat pdf file which is created in a \ZTemp directory on the server as say ListEmp.pdf.
5. Then I use following code:

        Me.Response.ClearContent()
        Me.Response.ClearHeaders()
        Me.Response.ContentType = "application/pdf"
        Me.Response.WriteFile(strDiskPrintImageFileName)
        Me.Response.Flush()
        Me.Response.Close()

   This code correctly displays the report in acrobat reader which is opened in the same browser window ('ListofEmployees.aspx') and I am able to do many things such as search, print, save file to local disk etc.

BUT, THIS SPOILS MY 'ListofEmployees.aspx' WINDOW.

The Problem:
------------

1. I want to Open a new window just before sending this report and display this report in a new window so that I have my original From-To range window as a parent window and report(*.pdf) window as a child window.

2. The user then can close child window(*.pdf) and return to parent window to give another range.

How to do this?
----------------



Reply With Quote
  #2 (permalink)  
Old February 2nd, 2005, 06:19 AM
Authorized User
 
Join Date: Oct 2004
Location: , , India.
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
Use following code
Response.AppendHeader("content-disposition","attachment;filename="& strFileName)
Response.WriteFile(LStrPath)
Response.End (Very Important to End)

Hopefuly will work

Amit
Reply With Quote
  #3 (permalink)  
Old February 4th, 2005, 05:34 AM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Amit,

Thanks for your help. But, I still face a problem.
While the code given by you works for saving a file, when I click on Open Button(Open-Save-Cancel are three buttons displayed), it says that the file could not be opened and it forces me to save it.

I have checked that the acrobat plug-in is wery much there.

So where is the problem.

Regards,
Dilip Nagle


Reply With Quote
  #4 (permalink)  
Old February 4th, 2005, 09:49 AM
Authorized User
 
Join Date: Oct 2004
Location: , , India.
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Dilip,

Is saved PDF file opening in Acrobat properly?
check the path for file location.It should not give problem in opening.

regards
Amit

Reply With Quote
  #5 (permalink)  
Old December 21st, 2006, 01:16 AM
Registered User
 
Join Date: Dec 2006
Location: Chennai, , India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Amit,

I too tried giving the same. its not opening in new window its opening in the same window.

Please help.Very urgent.

Response.Clear();
Response.ContentType = "application/x-msexcel";
Response.AddHeader("Content-Disposition", "inline; filename=Report.xls");
Response.WriteFile(strReportFile);
Response.End();
Reply With Quote
  #6 (permalink)  
Old March 8th, 2007, 01:25 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This may work :-

oStream = (MemoryStream)objSr.ExportToStream(CrystalDecision s.Shared.ExportFormatType.PortableDocFormat);

Response.ClearContent();
Response.ClearHeaders();
Response.Buffer= true;
Response.ContentType = "Application/PDF";
Response.BinaryWrite(oStream.ToArray());
Response.Flush();
Response.Close();











Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error while opening the pdf file jijish ASP.NET 2.0 Professional 3 November 23rd, 2007 10:07 AM
Opening PDF files comicghozt ASP.NET 1.0 and 1.1 Professional 11 October 23rd, 2006 04:06 AM
opening of pdf file viren_balaut Pro JSP 2 August 23rd, 2004 06:43 AM
Close Parent window on opening child window pkdev Javascript How-To 8 April 11th, 2004 12:06 PM
Show PDF without a webpage?? morpheus Classic ASP Basics 2 March 6th, 2004 09:05 AM



All times are GMT -4. The time now is 04:43 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.