Bonjour,
Est ce qu'il n'y a pas une fonction comme:
e.Graphics.DrawString () qui ne requiert pas le paramétre Font, car je vx envoyer une commande PCL directement à mon imprimante sans font.
Merci d'avance.
Bonjour,
Est ce qu'il n'y a pas une fonction comme:
e.Graphics.DrawString () qui ne requiert pas le paramétre Font, car je vx envoyer une commande PCL directement à mon imprimante sans font.
Merci d'avance.
Si je percois bien ce que tu veux faire DrawString n'est d'aucune utilité dans tons cas
DrawString transforme une chaine en Image dans un Graphics selon le font choisi !!
Si tu veux envoyer directement du PCL a l'imprimante , tu dois creer une methode qui encapsulera ta chaine en PCL
Bonjour et Merci pour votre réponse.
Dans mon application, je vx imprimer des informations.
En fait j'ai réussi à le faire via e.Graphics.DrawString () selon des cordonnées bien dénie.
Mais le probléme c'est que je vx imprimer dans la méme page oû se trouvent les informations imprimées par e.Graphics.DrawString () une commande PCL alors comme résultat j'ai 2 page:
Une contient les infos de e.Graphics.DrawString ().
Et l'autre contient la commande PCL.
Moi je veux que la commande s'imprime sur la méme page.
Je vous file quelque portion de mon probléme:
code qui utilise e.Graphics.DrawString ():
Code de cardDocument_Page(....)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 PrintDocument Page = new PrintDocument(); Page.PrintPage += new PrintPageEventHandler(cardDocument_Page); Page.Print();
Code qui envoie la commande directement à l'imprimante:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 e.Graphics.DrawString("String1", cardFont, Brushes.Black, 400, 300); e.Graphics.DrawString("String2", cardFont, Brushes.Black, 500, 300);
les classes utilisé par PrintDirect:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 System.IntPtr lhPrinter = new System.IntPtr(); DOCINFO di = new DOCINFO(); int pcWritten = 0; PrintDirect.OpenPrinter("\\\\10.1.0.40\\HPLaserJ", ref lhPrinter, 0); PrintDirect.StartDocPrinter(lhPrinter, 1, ref di); PrintDirect.StartPagePrinter(lhPrinter); string st1; st1 = "\x1b**1M\x1b(14Y\x1b(s0p8.00h12.0v0s0b105T" + Strin+ "\x1b**0M"; PrintDirect.WritePrinter(lhPrinter, st1, st1.Length, ref pcWritten); PrintDirect.EndPagePrinter(lhPrinter); PrintDirect.EndDocPrinter(lhPrinter); PrintDirect.ClosePrinter(lhPrinter);
Moi je veux qu'il imprime tout les éléments sur la méme page, mais ils sont imprimés sur 2 pages.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 public struct DOCINFO { [MarshalAs(UnmanagedType.LPWStr)] public string pDocName; [MarshalAs(UnmanagedType.LPWStr)] public string pOutputFile; [MarshalAs(UnmanagedType.LPWStr)] public string pDataType; } public class PrintDirect { [DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)] public static extern long OpenPrinter(string pPrinterName, ref IntPtr phPrinter, int pDefault); [DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)] public static extern long StartDocPrinter(IntPtr hPrinter, int Level, ref DOCINFO pDocInfo); [DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] public static extern long StartPagePrinter(IntPtr hPrinter); [DllImport("winspool.drv", CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] public static extern long WritePrinter(IntPtr hPrinter, string data, int buf, ref int pcWritten); [DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] public static extern long EndPagePrinter(IntPtr hPrinter); [DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] public static extern long EndDocPrinter(IntPtr hPrinter); [DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] public static extern long ClosePrinter(IntPtr hPrinter); }
Merci boucoup de votre aide.
Partager