IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C# Discussion :

e.Graphics.DrawString() sans Font


Sujet :

C#

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Inscrit en
    Mars 2007
    Messages
    48
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 48
    Par défaut e.Graphics.DrawString() sans Font
    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.

  2. #2
    Membre expérimenté
    Profil pro
    Mangeur de gauffre
    Inscrit en
    Octobre 2007
    Messages
    4 413
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations professionnelles :
    Activité : Mangeur de gauffre

    Informations forums :
    Inscription : Octobre 2007
    Messages : 4 413
    Par défaut
    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

  3. #3
    Membre averti
    Inscrit en
    Mars 2007
    Messages
    48
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 48
    Par défaut
    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 : 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 de cardDocument_Page(....)
    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);
    Code qui envoie la commande directement à l'imprimante:
    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);
    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
    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);
    }
    Moi je veux qu'il imprime tout les éléments sur la méme page, mais ils sont imprimés sur 2 pages.

    Merci boucoup de votre aide.

Discussions similaires

  1. [JavaScript] Police Numérique digitale sans font(pour compteur par exemple)
    Par SpaceFrog dans le forum Contribuez
    Réponses: 7
    Dernier message: 03/08/2010, 09h55
  2. Problème effacement après Graphics.DrawString
    Par Algernon2 dans le forum C#
    Réponses: 12
    Dernier message: 30/06/2010, 17h39
  3. Wrap de text avec Graphics.DrawString
    Par olibara dans le forum C#
    Réponses: 0
    Dernier message: 16/12/2008, 12h49
  4. Graphics.Drawline sans "cassures"
    Par olibara dans le forum C#
    Réponses: 12
    Dernier message: 15/09/2008, 14h15
  5. Réponses: 2
    Dernier message: 06/08/2006, 00h08

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo