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

Composants FMX Delphi Discussion :

Impression avec Delphi FMX Cross-plateforme


Sujet :

Composants FMX Delphi

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Webmaster
    Inscrit en
    Février 2017
    Messages
    43
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Congo-Brazzaville

    Informations professionnelles :
    Activité : Webmaster

    Informations forums :
    Inscription : Février 2017
    Messages : 43
    Par défaut Impression avec Delphi FMX Cross-plateforme
    Bonjour à tous ! J'utilise delphi 10.4 (Sydney) la version Community Édition et j'ai une application en FMX déployée sur Windows et Android.

    Je voudrais que mon application peu importe la plateforme puisse faire l'impression (ticket de caisse) avec comme option : l'impression automatique, voir ce qui sera imprimé et la génération d'un pdf (pour peut-être l'envoyer par mail). Alors ma question est comment faire, du moins quel outils ou méthode utilisé pour mon besoin ?

    Ce n'est pas par faute d'avoir cherché, mais j'ai vu pas mal d'outils telle que FastReport ou Rave ou encore TMS, mais, en fonction de ma licence (Community, donc gratuit) et de la licence de ces outils (de préférence gratuit aussi), je ne connais pas vraiment les limites ou encore jusqu'a où je peux aller voire si c'est vraiment adapté à ce que je veux faire, pour rappel ce que je veux reste assez simple (je pense), mais on ne sait jamais.

  2. #2
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 658
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 658
    Billets dans le blog
    65
    Par défaut
    Bonjour,

    Pour avoir fait les deux, tickets de caisse et Pdf j'écrirais que :
    - pour les tickets reine ne vaut l'envoi direct (au besoin je peux retrouver mon code pas si vieux)
    - pour Pdf FastReport convient parfaitement à l'objectif. (bon, là n'ayant pas de version community je ne peux être sûr de moi quant à l'installation : obtention par Getit ou directe par le site de fastReport).
    NB. L'obtention par Getit n'est peut-être que pour la version VCL ? (c'est pour moi, invérifiable sauf à aller dans la description des licences et matrices fonctionnelles)

  3. #3
    Expert éminent
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 56
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Par défaut
    idem

    je n'ai pas de version mobile, mais une version VCL pour la caisse et FMX Windows pour une borne interactive.

    dans les deux cas j'ai un code d'impression sur un Bitmap qui me sert pour l'aperçu...et pour l'impression j'encode le Bitmap dans le format d'impression EPSON et je balance directement sur l'imprimante en USB ou TCP/IP

    Notez que pour FMX j'ai redéveloppé un Canvas et Printer façon VCL pour porter un code existant car je restais sous Windows et qu'en recréant les 2/3 fonctions que j'utilise, ça allait plus vite que d'adapter mon code à FMX

    sur Mobile je partirais donc sur la même chose...une impression Bitmap et un envoie TCP/IP vers l'imprimante.
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  4. #4
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 658
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 658
    Billets dans le blog
    65
    Par défaut
    Suite au message de Paul cela m'a fait penser que j'avais posté quelque chose à ce sujet ici

  5. #5
    Expert éminent
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 56
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Par défaut
    Citation Envoyé par SergioMaster Voir le message
    Suite au message de Paul cela m'a fait penser que j'avais posté quelque chose à ce sujet ici
    ah et je donne aussi mon code
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  6. #6
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 658
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 658
    Billets dans le blog
    65
    Par défaut
    Je suis allé à la pêche à ma solution, tout par escape code Epson (sans logo dessin cela dit)

    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
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
     
    const
         escNewLine      = AnsiChar(10);  // New line (LF line feed)
         escUnerlineOn   = AnsiChar(27) + AnsiChar(45) + AnsiChar(1);  // Unerline On
         escUnerlineOnx2 = AnsiChar(27) + AnsiChar(45) + AnsiChar(2);  // Unerline On x 2
         escUnerlineOff  = AnsiChar(27) + AnsiChar(45) + AnsiChar(0);  // Unerline Off
         escBoldOn       = AnsiChar(27) + AnsiChar(69) + AnsiChar(1);  // Bold On
         escBoldOff      = AnsiChar(27) + AnsiChar(69) + AnsiChar(0);  // Bold Off
         escNegativeOn   = AnsiChar(29) + AnsiChar(66) + AnsiChar(1);  // White On Black On'
         escNegativeOff  = AnsiChar(29) + AnsiChar(66) + AnsiChar(0);  // White On Black Off
         esc8CpiOn       = AnsiChar(29) + AnsiChar(33) + AnsiChar(16); // Font Size x2 On
         esc8CpiOff      = AnsiChar(29) + AnsiChar(33) + AnsiChar(0);  // Font Size x2 Off
         esc16Cpi        = AnsiChar(27) + AnsiChar(77) + AnsiChar(48); // Font A  -  Normal Font
         esc20Cpi        = AnsiChar(27) + AnsiChar(77) + AnsiChar(49); // Font B - Small Font
         escReset        = AnsiChar(27) + AnsiChar(64); //AnsiChar(27) + AnsiChar(77) + AnsiChar(48); // Reset Printer
         escFeedAndCut   = AnsiChar(29) + AnsiChar(86) + AnsiChar(65)+ AnsiChar(20); // Partial Cut and feed
         escFormFeed     = AnsiChar(12);
         escAlignLeft    = AnsiChar(27) + AnsiChar(97) + AnsiChar(0); // Align Text to the Left  (ancien 48)
         escAlignCenter  = AnsiChar(27) + AnsiChar(97) + AnsiChar(1); // Align Text to the Center
         escAlignRight   = AnsiChar(27) + AnsiChar(97) + AnsiChar(2); // Align Text to the Right
         gsFeedandCut    = AnsiChar(29) + AnsiChar(86) + AnsiChar(48) ;
     
     
    ...
     
    procedure TDatas.EnteteTicket(const Hprinter : THandle; var D : TDateTime; const NoTicket : String = '0');
    var LogoFileName,s : String;
        Sl : TStringList;
        i : integer;
        dwBytesWritten: DWord;
        DocumentDataAnsi: AnsiString;
    begin
    if d=0 then d:=now;
     
    s:=ligne(nbcticket,'',Noticket);
    s:=ligne(nbcticket,s,formatdateTime('dd/mm/yy hh:nn',D),TAlignLayout.Right);
    DocumentDataAnsi:=esc16cpi+escAlignLeft+AnsiString(s)+escNewLine;
    WritePrinter(hPrinter, @DocumentDataAnsi[1],Length(DocumentDataAnsi),dwBytesWritten);
     
    LogoFileName:=System.IOUtils.TPath.Combine(Datas.parametres.DepotPref,'Logo.txt');
    Sl:=TStringList.Create;
    try
      sl.LoadFromFile(LogoFileName);
       for i:=0 to sl.Count-1 do
       begin
         if i=0 then DocumentDataAnsi:=esc16cpi+escAlignLeft+escBoldOn+AnsiString(sl[i])+escboldoff+escnewline
                else DocumentDataAnsi := esc20Cpi+AnsiString(sl[i])+escNewLine;
         WritePrinter(hPrinter, @DocumentDataAnsi[1],Length(DocumentDataAnsi),dwBytesWritten);
       end;
    finally
      sl.Free;
    end;
    // ligne vide
    DocumentDataAnsi := esc20Cpi+escNewLine;
    WritePrinter(hPrinter, @DocumentDataAnsi[1],Length(DocumentDataAnsi),dwBytesWritten);
    end;
     
     
    procedure TDatas.imprimerticket(const numero : integer=0);
    var hPrinter: THandle;
        DocInfo: TDocInfo1;
        dwBytesWritten: DWord;
        DocumentDataAnsi: AnsiString;
        s : string;
        d : tdateTime;
        total,tva : currency;
        {$IFDEF DEBUG}F : TextFile; {$ENDIF}
    begin
       total:=0;
       tva:=0;
       fdlignesTicket.Open('',[numero]);
       fdLignesTicket.First;
     
     {$IFDEF DEBUG}
        AssignFile(f,'ticket'+numero.ToString+'.txt');
        rewrite(f);
        while not fdLignesTicket.eof do
        begin
          if FDLignesTicketSOLDE.AsString='N' then s:=' ' else s:=AnsiChar(169);
     
     
          s:=ligne(nbcticket,'',format('%s%s-%s %s',[s,fdLignesTicketMODELE.asString,
                                                       fdLignesTicketASSORTIMENT.asString,
                                                       fdLignesTicketPOINTURE.asString]));
          s:=Ligne(nbcticket,s,Format('%3.2f',[fdlignesTicketPRIX_TTC.asCurrency]),TalignLayout.Right);
          Writeln(f,s);
          s:=AnsiString(' '+fdlignesTicketDESCRIPTION.asString);
          Writeln(f,s);
          if FDLignesTicketMNT_REMISE.AsCurrency>0 then
            begin
              s:=Ligne(nbcticket,'',Format('Remise -%3.2f',[fdlignesTicketMNT_REMISE.asCurrency]),TalignLayout.Right);
              writeln(f,s);
            end;
          writeln(f,'');
          total:=total+fdlignesTicketPRIX_TTC.asCurrency-fdlignesTicketMNT_REMISE.asCurrency;
          tva:=tva+FDLignesTicketTVA.AsCurrency;
          fdlignesTicket.Next;
        end;
     
     
        s:=ligne(nbcticket,'',format('TOTAL          %7.2f',[total]),TalignLayout.Right);
        writeln(f,s);
     
        s:=ligne(nbcticket,'',format('Dont T.V.A     %7.2f',[tva]),TalignLayout.Right);
        writeln(f,s);
        Closefile(f);
     
      {$ELSE}
     
       OpenPrinter(PChar(parametres.Imprimante), hPrinter, nil);
       DocInfo.pOutputFile:= nil;
       DocInfo.pDatatype:= 'RAW';
       DocInfo.pDocName:= PChar('Ticket '+Numero.ToString);
       StartDocPrinter(hPrinter, 1, @DocInfo);
       StartPagePrinter(hPrinter);
       if fdLignesTicketDATE_VENTE.IsNull
         then d:=now
         else d:=fdLignesTicket.FieldByName('DATE_VENTE').AsDateTime;
       EnteteTicket(hprinter,d,numero.ToString);
    { imprimer lignes}
     
       while not fdLignesTicket.eof do
        begin
          if FDLignesTicketSOLDE.AsString='N' then s:=' ' else s:=AnsiChar(169);
     
     
          s:=ligne(nbcticket,'',format('%s%s-%s %s',[s,fdLignesTicketMODELE.asString,
                                                       fdLignesTicketASSORTIMENT.asString,
                                                       fdLignesTicketPOINTURE.asString]));
          s:=Ligne(nbcticket,s,Format('%3.2f',[fdlignesTicketPRIX_TTC.asCurrency]),TalignLayout.Right);
     
          DocumentDataAnsi:=escAlignLeft+esc20cpi+AnsiString(s)+escNewLine;
          WritePrinter(hPrinter,@DocumentDataAnsi[1],length(DocumentDataAnsi),dwBytesWritten);
     
    //      DocumentDataAnsi := esc20Cpi+escAlignRight+System.AnsiStrings.Format('%3.2f',[fdlignesTicketPRIX_TTC.asCurrency])+escNewLine;
    //      WritePrinter(hPrinter,@DocumentDataAnsi[1],length(DocumentDataAnsi),dwBytesWritten);
     
          DocumentDataAnsi := esc20Cpi+escAlignLeft+AnsiString(' '+fdlignesTicketDESCRIPTION.asString)+escNewLine;
          WritePrinter(hPrinter,@DocumentDataAnsi[1],length(DocumentDataAnsi),dwBytesWritten);
          if FDLignesTicketMNT_REMISE.AsCurrency>0 then
            begin
              s:=Ligne(nbcticket,'',Format('Remise -%3.2f',[fdlignesTicketMNT_REMISE.asCurrency]),TalignLayout.Right);
              DocumentDataAnsi := esc20Cpi+escAlignLeft+AnsiString(s)+escNewLine;
              WritePrinter(hPrinter,@DocumentDataAnsi[1],length(DocumentDataAnsi),dwBytesWritten);
            end;
          DocumentDataAnsi :=escNewLine;
          WritePrinter(hPrinter,@DocumentDataAnsi[1],length(DocumentDataAnsi),dwBytesWritten);
          total:=total+fdlignesTicketPRIX_TTC.asCurrency-fdlignesTicketMNT_REMISE.asCurrency;
          tva:=tva+fdlignesTicketTVA.asCurrency;
          fdlignesTicket.Next;
        end;
     
       DocumentDataAnsi := esc20Cpi+escAlignRight+AnsiString(StringofChar('-',20))+escNewLine+escAlignLeft;
       WritePrinter(hPrinter,@DocumentDataAnsi[1],length(DocumentDataAnsi),dwBytesWritten);
     
       s:=ligne(nbcticket,'',format('TOTAL          %7.2f',[total]),TalignLayout.Right);
       documentDataAnsi := esc16Cpi+escBoldOn+escAlignCenter+AnsiString(s)+escboldoff+escNewLine;
       WritePrinter(hPrinter,@DocumentDataAnsi[1],length(DocumentDataAnsi),dwBytesWritten);
     
       s:=ligne(nbcticket,'',format('Dont T.V.A     %7.2f',[tva]),TalignLayout.Right);
       documentDataAnsi := esc16Cpi+escAlignCenter+AnsiString(s)+escNewLine;
       WritePrinter(hPrinter,@DocumentDataAnsi[1],length(DocumentDataAnsi),dwBytesWritten);
     
       documentDataAnsi := escNewLine+escNewLine;
       WritePrinter(hPrinter,@DocumentDataAnsi[1],length(DocumentDataAnsi),dwBytesWritten);
       DocumentDataAnsi := escFeedAndCut;
       WritePrinter(hPrinter,@DocumentDataAnsi[1],length(DocumentDataAnsi),dwBytesWritten);
     
       DocumentDataAnsi :=chr(13);
       WritePrinter(hPrinter,@DocumentDataAnsi[1],1,dwBytesWritten);
     
       EndPagePrinter(hPrinter);
       EndDocPrinter(hPrinter);
       ClosePrinter(hPrinter);
       {$ENDIF}
    end;

Discussions similaires

  1. Impression avec FastReport FMX
    Par Wachter dans le forum FastReport
    Réponses: 1
    Dernier message: 18/05/2016, 13h16
  2. Impression avec delphi Xe2
    Par mario9 dans le forum Débuter
    Réponses: 2
    Dernier message: 19/01/2012, 15h13
  3. État d'impression avec Delphi 5
    Par boudjamel dans le forum Delphi
    Réponses: 1
    Dernier message: 06/02/2007, 14h48
  4. Impression avec Delphi
    Par fga1987 dans le forum Delphi
    Réponses: 1
    Dernier message: 01/02/2007, 15h32
  5. Problème d'impression avec delphi
    Par Bourak dans le forum Langage
    Réponses: 1
    Dernier message: 12/11/2005, 17h13

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