|
-
Jul 31st, 2005, 08:52 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] how to print jpg
hi,
Is anyone knw how to print jpg?
Popskie
-
Jul 31st, 2005, 09:27 PM
#2
Re: how to print jpg
You need to make sure there is an application associated with the Print action for that file type first. To check, open the Folder Options applet from the Control Panel and select the File Types tab. Scroll down to the JPG extension, click it and click the Advanced button. If there is no entry in the list for Print then you need to add one. You may also be able to achieve this through your chosen application itself.
Assuming you do have an application associated with the action you can use this code:
VB Code:
ProcessStartInfo psi = New ProcessStartInfo(filePath);
psi.Verb = "Print";
Process.Start(psi);
where filePath is the fully qualified path to the file you want to print.
Edit:
Once you create a ProcessStartInfo object for a document, you can determine what actions you can perform in this manner by examining the Verbs property, which is an array of Strings corresponding to the list of actions you would have seen by following the instructions I gave above. This way you could write your code to check whether the user's machine has an application associated with the Print verb. If they do then you can use it but if they don't then you could just open the file and let them print it themselves.
VB Code:
Dim psi As New ProcessStartInfo(filePath)
If Array.IndexOf(psi.Verbs, "Print") <> -1 Then
'An application is associated with the Print action so use it.
psi.Verb = "Print"
End If
'The image will be opened with the default application if there is no verb.
Process.Start(psi)
Last edited by jmcilhinney; Jul 31st, 2005 at 09:38 PM.
-
Jul 31st, 2005, 09:40 PM
#3
Thread Starter
Fanatic Member
Re: how to print jpg
Sory im not using vb. Ok i solve it.
Last edited by popskie; Jul 31st, 2005 at 09:57 PM.
-
Jul 31st, 2005, 10:02 PM
#4
Re: how to print jpg
Oops. The first section is in C# but it's just in vbcode tags. I'm so used to posting in VB I did forget when I added the edit though. It's virtually exactly the same in C# anyway. I've simply added an If statement, which I'm sure you can do yourself in C#:
VB Code:
ProcessStartInfo psi = new ProcessStartInfo(filePath);
if (Array.IndexOf(psi.Verbs, "Print") != -1)
{
// An application is associated with the Print action so use it.
psi.Verb = "Print";
}
// The image will be opened with the default application if there is no verb.
Process.Start(psi);
-
Jul 31st, 2005, 10:43 PM
#5
Thread Starter
Fanatic Member
Re: how to print jpg
Ok the codes was very great. thanks very much.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|