Print Documents

  • Thread starter Thread starter Rainbow
  • Start date Start date
R

Rainbow

I know that print funciton will be available in the
application for each type of file.

My question is, can I print a file(any type, e.g. word,
bmp, html, etc) in program?

No printer dialog should be prompted.

Can this be done?
 
Rainbow,

It is possible, but you have to make sure that you know the item on the
list that should be used to print it. For example, for an HTML file, there
is a "print" menu item. You know that this menu item corresponds to print.

Now, once you have that, you can look up the extension .htm in
HKEY_CLASSES_ROOT and you will see that it is of type "htmfile". Looking up
"htmfile", you will find a key which has a subkey "shell". That is where
the commands are stored for the file type. Once you have that, you can see
the "print" key with the "command" key under it. The default value for this
key is the command that is executed to print.

It is not guaranteed that a dialog will not be displayed for this type,
because it is up to the program.

Now, you can do this programatically, but the key is knowing what menu
items correspond to printing.

Hope this helps.
 
Thanks Nicholas.

As you mentioned, the print dialog box prompt up. I need
to print to a default printer with default print setting
sliently. So I want to see if there is any print API can
do.

Rainbow
-----Original Message-----
Rainbow,

It is possible, but you have to make sure that you know the item on the
list that should be used to print it. For example, for an HTML file, there
is a "print" menu item. You know that this menu item corresponds to print.

Now, once you have that, you can look up the extension .htm in
HKEY_CLASSES_ROOT and you will see that it is of type "htmfile". Looking up
"htmfile", you will find a key which has a subkey "shell". That is where
the commands are stored for the file type. Once you have that, you can see
the "print" key with the "command" key under it. The default value for this
key is the command that is executed to print.

It is not guaranteed that a dialog will not be displayed for this type,
because it is up to the program.

Now, you can do this programatically, but the key is knowing what menu
items correspond to printing.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Rainbow said:
I know that print funciton will be available in the
application for each type of file.

My question is, can I print a file(any type, e.g. word,
bmp, html, etc) in program?

No printer dialog should be prompted.

Can this be done?


.
 
Back
Top