Bonjour,
Je souhaite imprimer un document PDF par une imprimante X, est ce que c'est possible ? Merci d'avance de votre aide.
Version imprimable
Bonjour,
Je souhaite imprimer un document PDF par une imprimante X, est ce que c'est possible ? Merci d'avance de votre aide.
Salut
oui c'est possible, et si tu fais une recherche sur le forum tu devrais trouvé un post de la semaine derniere donnant la solution.
Bon courage
Bonsoir,
Je ne trouve pas comment appeler une imprimante en c# pour imprimer n'importe quel type de document, merci d'avance de votre aide.
Personnellement, j'utilise la Classe DialogPrint mais je me demande si elle n'est pas réservée pour le WPF, ensuite je pense qu'il y a mieux car, par exemple, je n'ai pas trouvé comment forcer l'impression en paysage.
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 private static void PrintPdf(string Path) { string value = null; string commandPath = null; string arguments = null; RegistryKey regedit = null; try { regedit = RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.ClassesRoot, "").OpenSubKey(".pdf"); value = System.Convert.ToString(regedit.GetValue("")); if (value != null) { regedit = RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.ClassesRoot, "").OpenSubKey(value + @"\shell\printto\command"); value = System.Convert.ToString(regedit.GetValue("")); if (value != null) { if (value.IndexOf("/") > 0) commandPath = value.Substring(0, value.IndexOf("/")); else commandPath = value.Substring(0, value.IndexOf(" ")); arguments = value.Substring(commandPath.Length).Trim(); commandPath = commandPath.Replace("%SystemRoot%", System.Environment.GetEnvironmentVariable("SystemRoot")).Trim(); } else { } } else { } } finally { if (regedit != null) regedit.Close(); } Process printer = new Process(); printer.StartInfo.UseShellExecute = true; printer.StartInfo.CreateNoWindow = true; printer.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; printer.StartInfo.Arguments = arguments.Replace("%1", Path).Replace("%2", Printer).Replace(" \"%3\"", string.Empty).Replace(" \"%4\"", string.Empty); printer.StartInfo.FileName = commandPath; printer.Start();