Home > Archive > PERL CGI Beginners > June 2007 > Help downloading a file
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Help downloading a file
|
|
| John Moon 2007-05-01, 6:55 pm |
| Below is code I presently use to download to clients and the generated
html. One client objects to the generated html - the
"Content-Disposition" ... Does any one have another method to download
AND display the pdf with perl.
sub Display_PDF {
my ($pdf, $pdf_size) = @_;
$|=0;
print $q->header(-type=>'application/pdf',
-attachment=>'Requested_Report.pdf',
-Content_length=>$pdf_size,
-expires=>'+1d',
-status=>'200 OK');
open REPORT, $pdf;
while (read REPORT, my $buff, 5000) {
print $buff
}
}
Generates:
Status: 200 OK
Expires: Wed, 02 May 2007 14:53:53 GMT
Date: Tue, 01 May 2007 14:53:53 GMT
Content-Disposition: attachment; filename="Requested_Report.pdf"
content-length: 92455
Content-Type: application/pdf
John W Moon
| |
| Greg Jetter 2007-05-01, 6:55 pm |
| On Tuesday May 1 2007 6:56 am, Moon, John wrote:
> Below is code I presently use to download to clients and the generated
> html. One client objects to the generated html - the
> "Content-Disposition" ... Does any one have another method to download
> AND display the pdf with perl.
>
>
> sub Display_PDF {
> my ($pdf, $pdf_size) = @_;
> $|=0;
> print $q->header(-type=>'application/pdf',
> -attachment=>'Requested_Report.pdf',
> -Content_length=>$pdf_size,
> -expires=>'+1d',
> -status=>'200 OK');
> open REPORT, $pdf;
> while (read REPORT, my $buff, 5000) {
> print $buff
> }
> }
>
> Generates:
>
> Status: 200 OK
> Expires: Wed, 02 May 2007 14:53:53 GMT
> Date: Tue, 01 May 2007 14:53:53 GMT
> Content-Disposition: attachment; filename="Requested_Report.pdf"
> content-length: 92455
> Content-Type: application/pdf
>
> John W Moon
are you using CGI.pm ?
Greg
| |
| Greg Jetter 2007-05-01, 6:55 pm |
| On Tuesday May 1 2007 6:56 am, Moon, John wrote:
> Below is code I presently use to download to clients and the generated
> html. One client objects to the generated html - the
> "Content-Disposition" ... Does any one have another method to download
> AND display the pdf with perl.
>
>
> sub Display_PDF {
> my ($pdf, $pdf_size) = @_;
> $|=0;
> print $q->header(-type=>'application/pdf',
> -attachment=>'Requested_Report.pdf',
> -Content_length=>$pdf_size,
> -expires=>'+1d',
> -status=>'200 OK');
> open REPORT, $pdf;
> while (read REPORT, my $buff, 5000) {
> print $buff
> }
> }
>
> Generates:
>
> Status: 200 OK
> Expires: Wed, 02 May 2007 14:53:53 GMT
> Date: Tue, 01 May 2007 14:53:53 GMT
> Content-Disposition: attachment; filename="Requested_Report.pdf"
> content-length: 92455
> Content-Type: application/pdf
>
> John W Moon
you must be i see $-q->header() method in there.
you could try :
print "Content-Type: application/pdf\n\n";
then just dump the contents of your pdf file to STDOUT...
with out knowing the full context of your situation , that is are you
generating the pdf file dynamically with a Perl module or are you just
serving it up to a browser connection via CGI ?
that make a difference on how to format the headers and push out the file.
Greg
| |
| Matthew Hellman 2007-05-01, 6:55 pm |
| The original intent was to generate a save-as dialog box instead of
displaying the PDF inline? I believe the problem with this is that it
can cause blank browser windows to open, which some people don't like.
This is a browser issue and I'm not aware of an alternative. Removing
the content-disposition header will cause the PDF to display inline. The
user would then have to manually save the PDF.
[color=darkred]
-----Message Disclaimer-----
This e-mail message is intended only for the use of the individual or
entity to which it is addressed, and may contain information that is
privileged, confidential and exempt from disclosure under applicable law.
If you are not the intended recipient, any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately by
reply email to Connect@principal.com and delete or destroy all copies of
the original message and attachments thereto. Email sent to or from the
Principal Financial Group or any of its member companies may be retained
as required by law or regulation.
Nothing in this message is intended to constitute an Electronic signature
for purposes of the Uniform Electronic Transactions Act (UETA) or the
Electronic Signatures in Global and National Commerce Act ("E-Sign")
unless a specific statement to the contrary is included in this message.
While this communication may be used to promote or market a transaction
or an idea that is discussed in the publication, it is intended to provide
general information about the subject matter covered and is provided with
the understanding that The Principal is not rendering legal, accounting,
or tax advice. It is not a marketed opinion and may not be used to avoid
penalties under the Internal Revenue Code. You should consult with
appropriate counsel or other advisors on all matters pertaining to legal,
tax, or accounting obligations and requirements.
| |
|
|
|
|
|
|
| Ererbunlolem85 2007-06-10, 4:42 pm |
| HaCkeD aDuLT SiTe :)
Direct access to member zone
http://uniqueadult.com/members/video.php?file=1
username: 218571
password: wanttocome
change the number in the link to get other videos! There are gigs of them! | |
|
|
|
|
|