Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Open Source > Perl
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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 Display Modes
  #1 (permalink)  
Old May 9th, 2008, 03:42 PM
Registered User
 
Join Date: May 2008
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old May 11th, 2008, 07:03 AM
Friend of Wrox
Points: 1,515, Level: 15
Points: 1,515, Level: 15 Points: 1,515, Level: 15 Points: 1,515, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2003
Location: Oxford, , United Kingdom.
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
Reply With Quote
  #3 (permalink)  
Old May 12th, 2008, 04:45 PM
Registered User
 
Join Date: May 2008
Location: , , .
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!
Reply With Quote
Reply


Thread Tools
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
Closing parent window from child window arnabghosh Javascript How-To 1 December 26th, 2007 12: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 10:38 AM



All times are GMT -4. The time now is 03:03 AM.


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