473,503 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Display a PDF in a new browser window :)

11 New Member
I am trying to re-work a Visual Basic (ASP .NET 2.0) application that delivers a PDF to a user based on requests. I have the appropriate MIME type (Application/pdf) specified but need to open the pdf in a new browser window. Any ideas? I appreciate any and all input
Thanks
Aug 23 '07 #1
4 1498
kadghar
1,295 Recognized Expert Top Contributor
I am trying to re-work a Visual Basic (ASP .NET 2.0) application that delivers a PDF to a user based on requests. I have the appropriate MIME type (Application/pdf) specified but need to open the pdf in a new browser window. Any ideas? I appreciate any and all input
Thanks
i dont know if this works with .net, but with vb and vba i use shellexecute:

Expand|Select|Wrap|Line Numbers
  1. 'To declare it, copy and paste this:
  2. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  3.  
  4. 'To use it, this lines would do for a pdf:
  5.  
  6. a = ShellExecute 0, vbNullString, path & "file.pdf", vbNullString, vbNullString, vbNormalFocus
  7. 'Dont forget to declare variables
  8.  
Hope that helps
Aug 23 '07 #2
mudrow1
11 New Member
i dont know if this works with .net, but with vb and vba i use shellexecute:

Expand|Select|Wrap|Line Numbers
  1. 'To declare it, copy and paste this:
  2. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  3.  
  4. 'To use it, this lines would do for a pdf:
  5.  
  6. a = ShellExecute 0, vbNullString, path & "file.pdf", vbNullString, vbNullString, vbNormalFocus
  7. 'Dont forget to declare variables
  8.  
Hope that helps

Thanks .... will work with it over the weekend !
Aug 24 '07 #3
mudrow1
11 New Member
Thanks .... will work with it over the weekend !
Expand|Select|Wrap|Line Numbers
  1. Partial Class _Default
  2.     Inherits System.Web.UI.Page
  3.     'To declare it, copy and paste this:
  4.     Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  5.  
  6.     'To use it, this lines would do for a pdf:
  7.  
  8.     Dim path As String = "C:\"
  9.  
  10.    a = ShellExecute 0, vbNullString, path & "test.pdf", vbNullString, vbNullString, vbNormalFocus 
  11.  
  12. End Class
  13.  
I tried the above code .. received a 'declaration expected' message .. I feel stupid ... sure it's something that I am not seeing clearly ... :(
Aug 27 '07 #4
kadghar
1,295 Recognized Expert Top Contributor
Try declaring the function outside the class (before it starts)

I really dont know if shellexecute works the same way with .net, so may be thats the problem.

Good Luck
Aug 27 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2417
by: Hemanth | last post by:
Hello there, I've a utility that runs on a linux machine. Basically, it opens a window, draws a figure and captures the image (screen) and stores it as a jpeg file. The utility requires a...
3
410
by: Bob | last post by:
I am pretty new at C#, so bare with me. I want to be able to read a local HTML file and display it in a browser window within my application. I also want to submit that page to my application and...
3
11698
by: VMI | last post by:
In my web app, how can I display an XML file in another browser window? Can this be done with C#? Thanks.
11
3471
by: Tina | last post by:
I'm in a button clicked event on mainpage.aspx. I want to display a new webpage that has just my image, which is a jpg. I want the page to be a ..jpg not an aspx so that it will be easy for the...
1
9390
by: chazmanian | last post by:
We have a situation where we display PDF files through IE via a method in our code-behind as follows protected void displayPDF(string exePath, string filePath { // exePath is the...
1
1076
by: acool | last post by:
I just plain forgot this setting and I have been all up and down the options and nothing works, any hel is appreciated.
2
1226
by: David Cho | last post by:
I hope I can describe the dilemma precisely. I have code to render PDF output in a browser window (using a third party control that merges PDF files and renders the PDF output in the browser...
9
2566
by: tshad | last post by:
This was posted before but the message got messed up (all NLs were stripped out for some reason). I have 2 labels that hold the name of different images on my .aspx page. <asp:Label ID="Logo"...
3
6759
by: Safalra (Stephen Morley) | last post by:
(Note: I'm not trying to do anything stupid based on the user's screen size - I'm just curious.) At work today I was looking at the visitor statistics for a client website, and noticed that...
2
8469
by: H. Rodriguez | last post by:
Hello, I would like to be able to open a new IE window on the client side and display a PDF document in the new window. Many tutorial sites that I have checked suggest opening a new IE window...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7280
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,...
0
7462
tracyyun
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...
1
5014
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...
0
4673
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...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
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 ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
382
bsmnconsultancy
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...

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.