Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Open Source > Perl
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Perl 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 May 9th, 2008, 03:42 PM
Registered User
 
Join Date: May 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Closing a Blank Leftover Window

Hello everyone,

I'd like to start out by saying that I'm brand new to Perl, HTML and all the rest. I have a general understanding of C++ and that's about it. So before I continue, please bear in mind I could be wrong with my "code speak" lol. On to the fun part...

I've been asked to see why this code is acting strange (I'm determined). The script that runs opens linked .pdf's from a home page. The bug was that if a .pdf was opened and you clicked the "Email" button inside Acrobat, Acrobat would attach the "read in line by line" .pdf as News.pl instead of "News-(article number).pdf". Here's the old statement:

******
print $q->header(-Disposition => "inline; name=News-$news_id.".pdf", -Type => 'application/pdf');

while (<FILE>) {
   print $_;
}

## $q being my CGI object
******

I commented the code above out and put in the following, which works for the most part but there's a slight issue that comes with it:

******
print "Content-Disposition: attachment; filename=News-$news_id.pdf";
print "Content-Type: text/html\n\n";

******
This code prompts the user with the Open, Save, Cancel or More Info box. If the user chooses Open, the window closes and the file is opened and everything works great. If the user chooses Save, the file gets saved, but there's a blank browser window that sticks around afterward. I'm trying to find a solution on how to close that left over window.

Any suggestions? I'll be watching this post like a hawk for awhile, so feel free to request more information.

Thanks oh so much,

Heff

 
Old May 11th, 2008, 07:03 AM
Friend of Wrox
 
Join Date: Dec 2003
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

erm, my guess is that changing this may help:

Code:
print "Content-Type: text/html\n\n";
To:
Code:
print "Content-Type: application/pdf\n\n";
It isn't tested though ;)

--
Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk
 
Old May 12th, 2008, 04:45 PM
Registered User
 
Join Date: May 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm pretty sure that I gave that a shot and it didn't fix it, but thanks for trying. After doing some more internet digging, I found a reference suggesting that it might be Acrobat 7 causing the issue that I'm trying to solve, so an upgrade to 8 might fix it and then my code isn't required.

So we'll see!

EDIT - Acrobat Reader 8 solves the problem! It finally realizes that we're looking at a pdf and slaps the extension on the back properly. Case closed!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing parent window from child window arnabghosh Javascript How-To 1 December 26th, 2007 01:18 AM
Closing window without prompt Sridhar Darsipudi Javascript 15 May 29th, 2006 03:21 AM
Closing window after redirection Peter Johns ASP.NET 1.0 and 1.1 Basics 0 May 13th, 2006 06:57 PM
Closing window Netscape r_ganesh76 Javascript 1 November 22nd, 2004 11:38 AM





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