Hello all;
I gathered information from this and several other groups to write a
perl & cgi script to display a pdf document. My script works partially
and found an issue when testing.
Here is my script:
=============== =============== =============== =============== ===
#!/bin/perl
use CGI qw(:standard *table);
$q = new CGI;
my $buffer = undef;
my $pdfFile = 'test.pdf';
my $mimeType = 'text/html';
if (! -e $pdfFile){
&die_nice("Cann ot find file to open - ". $pdfFile);
}
if (! -r $pdfFile){
&die_nice("Unab le to read file - ". $pdfFile);
}
if ((-e $pdfFile) && (-r $pdfFile)){
open(pdfFile, '<', $pdfFile) || &die_nice("Cann ot open - ".$pdfFile) ;
$mimeType = 'application/pdf';
}
print $q->header(-expires=>'now', -type=>$mimeType );
binmode pdfFile;
binmode STDOUT;
while (read(pdfFile, $buffer, 4096, 0)) {
print $buffer;
}
close(pdfFile);
sub die_nice{
my $error = shift;
print $q->header(-expires=>'now', -type=>$mimeType );
print "<dl>";
print "<dt>Some error occurred:</dt>";
print "<dd><strong>$e rror</strong></dd>";
print "</dl>";
exit;
=============== =============== =============== ============
When I execute this script the test.pdf file is displayed in my
browser. If I change the my $pdfFile = 'test.pdf'; to my $pdfFile =
'test.pd';, basically deleting the last charactor forced to do
die_nice(). I see nothing in the browser.
Closed the browser, opened a new wiondow and I can see the error
message.
Now changed the file name back to it's original name, accessed the
script from the browser and the browser displays the raw data.
Can some one please help me with this issue.
Regards,
Sri. 1 1928
This is the asp.net framework newsgroup and has nothing to do with perl
or cgi. Sorry ;) by********@gmai l.com wrote: Hello all; I gathered information from this and several other groups to write a perl & cgi script to display a pdf document. My script works partially and found an issue when testing.
Here is my script: =============== =============== =============== =============== === #!/bin/perl
use CGI qw(:standard *table);
$q = new CGI;
my $buffer = undef; my $pdfFile = 'test.pdf';
my $mimeType = 'text/html';
if (! -e $pdfFile){ &die_nice("Cann ot find file to open - ". $pdfFile); }
if (! -r $pdfFile){ &die_nice("Unab le to read file - ". $pdfFile); }
if ((-e $pdfFile) && (-r $pdfFile)){ open(pdfFile, '<', $pdfFile) || &die_nice("Cann ot open - ".$pdfFile) ; $mimeType = 'application/pdf'; }
print $q->header(-expires=>'now', -type=>$mimeType );
binmode pdfFile; binmode STDOUT;
while (read(pdfFile, $buffer, 4096, 0)) { print $buffer; }
close(pdfFile);
sub die_nice{ my $error = shift; print $q->header(-expires=>'now', -type=>$mimeType );
print "<dl>"; print "<dt>Some error occurred:</dt>"; print "<dd><strong>$e rror</strong></dd>"; print "</dl>";
exit; =============== =============== =============== ============
When I execute this script the test.pdf file is displayed in my browser. If I change the my $pdfFile = 'test.pdf'; to my $pdfFile = 'test.pd';, basically deleting the last charactor forced to do die_nice(). I see nothing in the browser.
Closed the browser, opened a new wiondow and I can see the error message.
Now changed the file name back to it's original name, accessed the script from the browser and the browser displays the raw data.
Can some one please help me with this issue.
Regards, Sri. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Stephen Ferg |
last post by:
Seen in the Wall Street Journal, Monday, July 21, 2003, page B1.
Lee Gomes' "Portals" technology column: "Two Men, Two Ways to Speak
Computerese and Two Big Successes".
This is a brief, non-technical story on Guido von Rossum, inventor of
Python, and Larry Wall, inventor of Perl.
I don't think this is available online unless you are a paid
subscriber to the WSJ online edition. So here are a few quick quotes
|
by: Bart Nessux |
last post by:
Just fooling around this weekend. Wrote and timed programs in C, Perl and
Python. Each Program counts to 1,000,000 and prints each number to the
console as it counts. I was a bit surprised. I'm not an expert C or Perl
programming expery, I'm most familiar with Python, but can use the others
as well.
Here are my results:
C = 23 seconds
Python = 26.5 seconds
|
by: Xah Lee |
last post by:
# -*- coding: utf-8 -*-
# Python
# to open a file and write to file
# do
f=open('xfile.txt','w')
# this creates a file "object" and name it f.
# the second argument of open can be
|
by: Xah Lee |
last post by:
© # -*- coding: utf-8 -*-
© # Python
©
© # in Python, one can define a boxed set
© # of data and functions, which are
© # traditionally known as "class".
©
© # in the following, we define a set of data
© # and functions as a class, and name it xxx
© class xxx:
|
by: Xah Lee |
last post by:
suppose you want to do find & replace of string of all files in a
directory.
here's the code:
©# -*- coding: utf-8 -*-
©# Python
©
©import os,sys
©
©mydir= '/Users/t/web'
| |
by: dohnut |
last post by:
Here's one for some bored problem solver :)
I ran across this earlier today and fixed it, but don't exactly know
why. (that usually only happens in C :)
I'm using Perl version 5.8.0 btw.
Ok, let's start here: I end up with an array that comes from a
fetchrow_array() call to MySQL. I return the array to a function.
|
by: Justin Kozuch |
last post by:
Hi All,
How do I determine the path to Perl on a Windows 2000 server? My hosting
company has installed ActiveState Perl (latest version).
I've called them and they said the path to perl is E:\Perl, however when I
enter this into my .cgi file, it spits an error back at me.
Any ideas?
|
by: débutante |
last post by:
bonjour tout le monde
je veux installer perl soous cygwin. pour y procéder voici nles étapes ke g fait:
1) g téléchargé activeperl et je l'ai installé => résultat: c/perl
le perl toune correctement
2) g installé le cygwin
3) g essayé la comande suivante
$ brw_tools unpack
bash: ./brw_tools: /usr/local/bin/perl: bad interpreter: No such file or directo
ry
|
by: jonathan184 |
last post by:
The code seems to be working fine for some records but I am thinking it is finding some other records with special characters and so on. I am looking for a way to insert the xml string with escaping a bunch of chars
This is the message i got
DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your M
ySQL server version for the right syntax to use near 'd to test@email.com...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |