Printing of any type of file

  • Thread starter Thread starter Trev Hunter
  • Start date Start date
T

Trev Hunter

Heya All,

Recently, I've implemented a simple document storage application. To cut a
long story short, it achieves this by:

1) User opens a file
2) File is read in and stored in another location my application (on a
server)
3) Icon appears in the application for the file
4) When the user wants to view the file, they double click the icon and the
file is transferred to the temporary folder and Process.Start is used to
launch the file so whatever viewer application is registered for the file is
launched (e.g. Word, Acrobat, Notepad etc.).

This part works fine, but does anybody have any ideas on how to print the
file from the application? Considering my application doesn't know the
structure of the files (it relies on whatever viewer application is
installed to do this), I'll need some common way of telling to viewer
application to print the file, instead of opening it.

My idea would be to somehow invoke the "Print" command that appears when you
right click on a file in explorer (which obviously requires the viewer
application to register the "Print" action for that file type when it is
installed).

Is there any way of doing this? I realise that not all file types can be
printed, but If I could get a way of seeing if "Print" is a registered
action for that file type and invoking it, it would do the job.

Many thanks for your suggestions and help,

Trev.
 
Aha,

After a bit of looking I came accross the "ProcessStartInfo.Verb" property
which can be used for this purpose when launching the file.

I'll Use "ProcessStartInfo.Verbs" to see if "Print" is one of them, then
call Process.Start to launch the file with the "Print" verb.


Best Regards,

Trev.
 
Back
Top