Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 2nd, 2005, 05:35 AM
Authorized User
 
Join Date: Jan 2005
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?
----------------



 
Old February 2nd, 2005, 06:19 AM
Authorized User
 
Join Date: Oct 2004
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
 
Old February 4th, 2005, 05:34 AM
Authorized User
 
Join Date: Jan 2005
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


 
Old February 4th, 2005, 09:49 AM
Authorized User
 
Join Date: Oct 2004
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

 
Old December 21st, 2006, 01:16 AM
Registered User
 
Join Date: Dec 2006
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();
 
Old March 8th, 2007, 01:25 AM
Registered User
 
Join Date: Mar 2007
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();
















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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.