2008-11-21 24 views
8

Staram się uzyskać drukarkę Epson "ESC/POS" do drukowania kodów kreskowych (przy użyciu Delphi) i chcę sprawdzić, czy drukarka nie jest wadliwa. Czy wiesz, gdzie mogę znaleźć program do wydrukowania kodu kreskowego w "ESC/POS"? Przypuszczam, że w ostateczności również program OPOS będzie w porządku.Gdzie mogę znaleźć program testowy kodów kreskowych Epson "ESC/POS"?

Również działający program demonstracyjny Delphi działa dobrze. Wszystkie dotychczasowe fragmenty Delphi nie działają.

Drukarka używam jest Epson TM-L60II

+0

rzucić okiem na www.epson-pos.com dla odniesienia ESC/POS – stukelly

+0

mam już odwołanie - nie działa na moim ów drukarek dlatego chcę program testowy już działa. –

+0

Mam program testowy dla drukarek szeregowych, czy twój serial jest drukowany? – stukelly

Odpowiedz

7

I Have a pełny program testów pisemnych w Delphi 5 dla TMT88 tych, ale źródło jest abit duży tu więc o to bity kodu kreskowego

Należy pamiętać, że jej fragmenty z pełnego obiektu niektóre Vars/funkcje mogą brakować

aby uzyskać znaków kodu kreskowego

{** 
* @param a ean13 barcode numeric value 
* @return the escpos code for the barcode print 
* Description uses escpos code, return code needed to print a ean13 barcode 
*} 
function TPrintEscPosToPort.getBarcodeEscPosCode(l_ean13:String):String; 
    var 
     l_return:String; 
begin 
    l_return := CHR(29) + 'k' + CHR(67) + CHR(12); 
    l_return := l_return + l_ean13; // Print bar code 
    l_return := l_return + l_ean13; // Print bar code number under thge barcode 

    Result := l_return 
end; 

wydrukować na drukarce

{** 
* @param Printer Name, Item be printed, Cut the papers after the cut, #no of copies to print 
* @return boolen, true if it printed 
* Description prints a test page to the tysso printer 
*} 
function TPrintEscPosToPort.escPosPrint(const l_printer, l_textToPrint :String;l_cutPaper:Boolean=true;l_copies:integer=1): Boolean; 
    var 
     l_pPort,l_pName,l_tmp:String; 
     i,x:integer; 
     PrinterFile: TextFile; 
begin 
    // set result to false so any thing other then a good print will be false 
    Result:= FALSE; 

    try 
     //Find if the printer exists, else set to defult -1 
     i := Printer.Printers.IndexOf(l_printer); 
     if (i > -1) then 
     begin 
      Printer.PrinterIndex := i; 
      l_pName := Printer.Printers[i]; //Get the printer name (incase its the defult and not the one passed) 
      l_pPort := Self.getPrinterPort(l_pName) ; // get the port name from the reg 
     end; 

     // If true add headers and footers to the passed text 
     if (Self.aPrintHeadersFooters) then 
     begin 
      l_tmp := Self.getHeader() 
       + l_textToPrint + Self.GetFooter(); 
     end 
     else 
     begin 
      l_tmp := l_textToPrint; 
     end; 

     //Send the Document To the printer 
     try 
      for x:= 1 to l_copies do //Print multi-copies 
      Begin    
       //Assign the file to a tmp file in the printer port 
       if (length(trim(l_pPort)) > 0) then AssignFile(PrinterFile,l_pPort) 
       else 
       begin       
        //only use if we cant get the port 
        //(may look bad as ctrl codes are still in place) 
        AssignPrn(PrinterFile); 
        l_tmp := Self.stripEscPos(l_tmp); 
       end; 

       Rewrite(PrinterFile); 

       try 
        //Send the passed Text to the printer 
        WriteLn(PrinterFile,l_tmp); 

        if (Self.aPrinterReset) then 
         WriteLn(PrinterFile,escReset); // Reset the printer alignment 

        if (l_cutPaper) then   
         WriteLn(PrinterFile,escFeedAndCut); //Cut the paper if needed 
       finally 
        CloseFile(PrinterFile); 
        Result:= true; 
       end; 
      end; 
     except 
     end; 
    except 
    end; 

end; 

Aktualizacja

Oto stracił stałych kodów sterujących z powyższym kodzie, z nadzieją, że nazwy są wystarczająco opisowe.

const 
    escNewLine = chr(10); // New line (LF line feed) 
    escUnerlineOn = chr(27) + chr(45) + chr(1); // Unerline On 
    escUnerlineOnx2 = chr(27) + chr(45) + chr(2); // Unerline On x 2 
    escUnerlineOff = chr(27) + chr(45) + chr(0); // Unerline Off 
    escBoldOn  = chr(27) + chr(69) + chr(1); // Bold On 
    escBoldOff  = chr(27) + chr(69) + chr(0); // Bold Off 
    escNegativeOn = chr(29) + chr(66) + chr(1); // White On Black On' 
    escNegativeOff = chr(29) + chr(66) + chr(0); // White On Black Off 
    esc8CpiOn  = chr(29) + chr(33) + chr(16); // Font Size x2 On 
    esc8CpiOff  = chr(29) + chr(33) + chr(0); // Font Size x2 Off 
    esc16Cpi  = chr(27) + chr(77) + chr(48); // Font A - Normal Font 
    esc20Cpi  = chr(27) + chr(77) + chr(49); // Font B - Small Font 
    escReset  = chr(27) + chr(64); //chr(27) + chr(77) + chr(48); // Reset Printer 
    escFeedAndCut = chr(29) + chr(86) + chr(65); // Partial Cut and feed 

    escAlignLeft = chr(27) + chr(97) + chr(48); // Align Text to the Left 
    escAlignCenter = chr(27) + chr(97) + chr(49); // Align Text to the Center 
    escAlignRight = chr(27) + chr(97) + chr(50); // Align Text to the Right 
+0

Dziękuję Stackowi za to, przetestuję i doradzę/oznaczę –

+1

Po prostu spędziłem trochę czasu, budując coś na tym, jest kilka rzeczy, które mogą zrobić z udokumentowaniem w powyższych kodach (procedura kodów kreskowych doesn Wydaje się, że działa, jak tam stoi). Sformalizuję to ładnie i opublikuję jako osobną odpowiedź po zakończeniu jej testowania. – robsoft

+0

Czy to działa? jeśli nie, mogę opublikować pełny kod (a nie tylko fragmenty). – Re0sless

1

Get Microsoft POS dla .NET 1.11, to musi SDK, który zawiera przykładową aplikację, która wykonuje wszystkie podstawowe operacje na sprzęcie POS. Używam go cały czas, aby przetestować, czy szuflady kasowe działają na przykład.

Zawiera również kod źródłowy (w .Net), dzięki czemu można zobaczyć, jak to robią.

+0

Cześć, dziękuję za to, ale naprawdę szukam trochę łatwiejszego sposobu niż robienie tego wszystkiego - tylko prosta aplikacja kodu kreskowego. już udowodniono, że działa. –

+0

Po pierwsze, OP pyta o aplikację delphi, a nie .NET, czy chciałbyś podać nazwę przykładowego kodu wspomnianego w twojej odpowiedzi? – AaA