473,513 Members | 2,576 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Opening a PDF

Hi,

I have an application that returns a PDF document to the browser (not as a
download). The document is returned in a new window. This works fine in
most installations, but I have one installation where it doesn't work in IE,
but does work in Netscape. At the installation where it doesn't work IE
returns the file download dialog box instead of just opening the file. When
I click open or save it complains that it can't find the file. I suspect
the problem is with the file name. IE is generating a very long file and
I'm guessing it is getting confused. My code did not originally set the
file name, so I'm trying to solve the problem by setting the file name.
Here's the code that I'm using, but it doesn't seem to have any affect.
Does anyone see why this doesn't work? objHttpConn is an HTTP control that
is used to retrieve the PDF document.

PS We are hosting the web sites where it does work and were it doesn't work
and I'm testing using my PC. The only difference is the version of the
application that returns the PDF document. All the machines are 2000
servers with IE 6.0 SP1.

Thanks
Jim

Response.Clear()
Response.ContentType = objHttpConn.getResponseHeader ("Content-Type")
if Instr(1,Response.ContentType,"pdf",vbTextCompare) > 0 then
Response.AddHeader "Content-Type", "application/pdf"
Response.AddHeader "Content-Disposition",
"inline;filename=Statement.pdf"
Response.BinaryWrite objHttpConn.ResponseBody
else
Response.Write objHttpConn.ResponseText
end if


Jul 19 '05 #1
3 5837
PS Here're the file names that I get when I save the documents once they
are opened in Netscape.

This is from the site that works both in IE and Netscape
C__Documents and Settings_jwillis_Application
Data_Mozilla_Profiles_default_zr4dozb8.pdf

This is from the site that only works in Netscape
C__Documents and Settings_jwillis_Application
Data_Mozilla_Profiles_default_zr4dozb8.slt_plugtmp _StatementRequest.pdf
Jul 19 '05 #2
Jim Willis" <"nospam wrote:
Hi,

I have an application that returns a PDF document to the browser (not
as a download). The document is returned in a new window. This
works fine in most installations, but I have one installation where
it doesn't work in IE, but does work in Netscape. At the
installation where it doesn't work IE returns the file download
dialog box instead of just opening the file. When I click open or
save it complains that it can't find the file. I suspect the problem
is with the file name. IE is generating a very long file and I'm
guessing it is getting confused. My code did not originally set the
file name, so I'm trying to solve the problem by setting the file
name. Here's the code that I'm using, but it doesn't seem to have any
affect. Does anyone see why this doesn't work? objHttpConn is an
HTTP control that is used to retrieve the PDF document.

PS We are hosting the web sites where it does work and were it
doesn't work and I'm testing using my PC. The only difference is the
version of the application that returns the PDF document. All the
machines are 2000 servers with IE 6.0 SP1.

Thanks
Jim

Response.Clear()
Response.ContentType = objHttpConn.getResponseHeader ("Content-Type")
if Instr(1,Response.ContentType,"pdf",vbTextCompare) > 0 then
Response.AddHeader "Content-Type", "application/pdf"
Response.AddHeader "Content-Disposition",
"inline;filename=Statement.pdf"
Response.BinaryWrite objHttpConn.ResponseBody
else
Response.Write objHttpConn.ResponseText
end if


I have seen this error before with images and text files. All incidences
share one thing with your app - they are creating on-the-fly output and
linking to it. It's a real pain to track down, but IIRC you need to ensure
the file is closed and ready before executing the link.

--
William Tasso - http://WilliamTasso.com
Jul 19 '05 #3
I was able to solve the problem. I have an include file that tries to force
the browser not to cache any of our pages. This included adding items such
as Reponse.AddHeader "pragma", "no-cache" and a few other items. I thought
the Reponse.Clear would remove these items, but after removing that include
file it fixed the problem. Also, we have a setting that controls when
caching is disabled, so that's probably why it works in one installation and
not another.
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3933
by: Jean-Fran?ois Lacrampe | last post by:
Hello, I want to write a _very_ simple text parser that would replace a string like: "This is text with /italics/, *bold* and _underline_." and generate automatically something like this: "This is text with <i>italics</i>, <b>bold</b> and <span
5
714
by: PM | last post by:
Has anyone found a way to open a file exclusively where it will fail if the file is already open, i have tried the following _FileStream = new FileStream(@"C:\Data.txt", FileMode.Open, FileAccess.ReadWrite, FileShare.None); which does not prevent me from opening the file even if another user has the file open ie Notepad, it will prevent me...
14
11021
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a window.open function? I would prefer not to create a separate HTML page. So far all I have is the basic var cwin =...
3
10571
by: Greg | last post by:
On my report I want to have an opening balance signifying all transactions up to the month selected and detailed transactions for the month selected and then a closing blance. I'm perpelexed how to do this Anyone knows how the banks do it with statement formatting? suggestions, ideas welcome.
11
3490
by: emailus | last post by:
I am webmaster for the domain <www.alpha1.org.au>. Not being an expert in html, I take advantage of my domain Registrant's web building tool, 'Instant Website'. This tool is provided as part of the fee I pay for web hosting. 'Instant Website' provides the option of having your opening page as a Flash Page, which you'll see if you visit...
9
2298
compman9902
by: compman9902 | last post by:
Hello, and thank toy for reading this post. Thus far, this website has helped me a lot, (I have finally finished my encryptor: "site removed by moderator", go to the downloads link) and I will continue asking for help (so my rank may finally increase). Right now the topic at hand for me is opening file dialogs. Right now, the issue at hand is...
15
2213
by: Umesh | last post by:
how to open a website like yahoo.com and use it as input? The following code doesn't work. #include"stdio.h" int main() { FILE *f; f=fopen("http://www.yahoo.com","r"); if(f==NULL)
3
3071
by: Luke Davis | last post by:
I'm looking for an effective way to open and close TCP ports. Can I do this through Tcpclient? And I know this is a potential security risk, so what kind of permission must the person running the application possess to handle it without errors? -- Luke Davis, MCSE: Security DEM Networks - Senior Systems Architect 7225 N First, Suite...
34
5298
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File "<pyshell#10>", line 1, in <module> os.startfile("C:\Documents and Settings\Alex\My Documents\My
3
5158
by: Paul H | last post by:
I have a transactions table and a balance table that look something like this: tblTransactions TransactionID (PK Autonumber) ClientID TransactionDate TransactionAmount (currency field, values must be >0) CRDR (indicates whether the transaction is a (credit or debit) StatementDate (Date stamp applied when the “Statement” report is run)
0
7178
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...
0
7397
Oralloy
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. ...
1
7128
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...
0
5704
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5103
isladogs
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...
0
3255
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...
0
3242
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.