473,729 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checking for a PDF reader

Hi,

I've been asked to write a WinForms app which will create reports as PDF
documents.

The client has agreed that all desktops (WinXP Pro, 32-bit Vista Business)
*will* have Adobe Acrobat Reader installed but, in the interests of
robustness, I want to check for this when the app loads.

Would you recommend checking for the Adobe Acrobat Reader specifically, or
just checking that the .pdf file extension has a valid association?

Any assistance gratefully received.

Mark
--
http://www.markrae.net

Jun 10 '07 #1
3 4085
Mark,

Personally, I would do neither. I would create an install package which
includes the install for the Adobe Acrobat reader so that you can make the
assumption that it is installed.

If you can't do this for some reason or another, and you are embedding
the reader in your app as an ActiveX control, then you could try and create
an instance of the control, and if it fails, you know it's not installed
(you will have to have an interop assembly as a reference in your app for
this).

If you are using the reader externally, then I would go with checking to
see if the extension is mapped to anything. However, I would consider this
solution to be very brittle, and my last resort. After all, a different app
could be registered to handle the PDF extension.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Mark Rae" <ma**@markNOSPA Mrae.netwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Hi,

I've been asked to write a WinForms app which will create reports as PDF
documents.

The client has agreed that all desktops (WinXP Pro, 32-bit Vista Business)
*will* have Adobe Acrobat Reader installed but, in the interests of
robustness, I want to check for this when the app loads.

Would you recommend checking for the Adobe Acrobat Reader specifically, or
just checking that the .pdf file extension has a valid association?

Any assistance gratefully received.

Mark
--
http://www.markrae.net
Jun 10 '07 #2
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omwrote in
message news:F5******** *************** ***********@mic rosoft.com...
Personally, I would do neither. I would create an install package which
includes the install for the Adobe Acrobat reader so that you can make the
assumption that it is installed.
Hmm - OK...
If you are embedding the reader in your app as an ActiveX control
I'm not doing that...
If you are using the reader externally, then I would go with checking to
see if the extension is mapped to anything. However, I would consider
this solution to be very brittle, and my last resort. After all, a
different app could be registered to handle the PDF extension.
OK.
--
http://www.markrae.net

Jun 10 '07 #3
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omwrote in
message news:F5******** *************** ***********@mic rosoft.com...
If you are using the reader externally, then I would go with checking
to see if the extension is mapped to anything. However, I would consider
this solution to be very brittle, and my last resort. After all, a
different app could be registered to handle the PDF extension.
Hello Nicholas,

I'm interested in this and wanted to find out more about it so I Googled
around a bit and the only methods I could find for this in C# seem to use
unmanaged code via pinvoke e.g.
http://www.pinvoke.net/default.aspx/...eryString.html

I've tried the code from the above page and it certainly works, but can you
please tell me:

1) Is this the "right" way to check for a file association in C#? Is there
something in the Framework which I could use instead?

2) If I deliberately ask for the file assocation of a filetype which I know
doesn't exist e.g. *.zzz, the method returns "shell32.dl l". Therefore, would
the correct logic be that if the code returns a string which contains
"shell32.dl l" then there is no association for that extension? How reliable
is this?

3) Will there be any problems running this code on Vista i.e. will it need
to be run with elevated privileges or even as administrator?

Thanks

DJ
Jun 11 '07 #4

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

Similar topics

2
2300
by: threeflush | last post by:
I have some code that checks to see if a document object exists in a sibling frame before continuing processing like: if (parent.frames.document){ .... } However, sometimes the frame I'm checking has an Adobe Reader 7.0 pdf file in it. If it does, and when it hits the above line of code, the error message:
8
2530
by: Todd Bright | last post by:
Is there a way to get the current XmlNode from the reader while in the validation event handler? What I'd like to do is display the error message along with the name of its parent node. In my XML format, there are parent nodes named differently with some of the same names for child nodes, so when I get an error message that references the 'LOGICALPOCKET' node that could be under more than one different parent node. I need to be able to...
1
1970
by: Aaron | last post by:
I asked for a script that can read info inside a specific xml tag and someone gave me this example. XmlReader reader = new XmlTextReader( filename ); while ( reader.Read() ) { if ( reader.NodeType == XmlNodeType.Element ) { string val; switch ( reader.Name )
12
11175
by: Jerry Camel | last post by:
Not sure if this is a good place to post this... I'm writing and ASP.net app using vb .net. I need to interact with a credit card reader. I have one that sits inline with the keyboard. Works great, except for the fact that no matter what field the user is in on the transaction page (Name, Address, Credit Card number) the reader will dump the data at the cursor. So, if the user is in the name field and they happen to swipe the card,...
5
21717
by: Dylan Parry | last post by:
Hi, At the moment I use code like the following: string myString = this.dataReader.IsDBNull(2) ? null : this.dataReader.GetString(2); With a record from the DB that looks like: ..---------------------------.
42
2800
by: =?Utf-8?B?UGxheWE=?= | last post by:
I have an if statement that isn't working correctly and I was wondering how I check for a blank string. My Code Example if me.fieldname(arrayIndex) = "" then ----- end if When I do this and there is no characters in the variable it does not enter my IF statement like I would think it should. How do I properly check for a
1
4093
by: vbDavidC | last post by:
Hi, I am fairly new to .net and objects. I learned to create a reader object in method 1, however if I wanted to create multiple select queries in the same module I did not know how to reuse the same code, I would like to verify if method 2 is the right way to reuse the same reader object. If this is the case could I open a reader object (that is global) at
0
222
by: Edwin.Madari | last post by:
os.paht.gmtime(path) returns the last modification of path. check out http://docs.python.org/lib/module-os.path.html regards Edwin -----Original Message----- From: python-list-bounces+edwin.madari=verizonwireless.com@python.org On Behalf Of William Purcell Sent: Tuesday, August 12, 2008 1:47 PM To: Python List
0
1820
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi all people, everybody, We have multiple versions of Acrobat Reader from 5.x to 8.x, I want to create a method in C# or VB.NET to check to see if the registry key for the versions exists, and if so uninstall it, then install the latest
0
8917
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9426
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9281
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8148
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6022
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();...
0
4525
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...
1
3238
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
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2163
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 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...

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.