문제

Epson "ESC/POS"프린터를 얻기 위해 고군분투하고 바코드 (Delphi 사용)를 인쇄하고 프린터에 결함이 없는지 테스트하려고합니다. "ESC/POS"에서 바코드를 인쇄 할 프로그램을 찾을 수있는 곳을 알고 있습니까? 나는 최후의 수단으로서 OPOS 프로그램도 괜찮을 것이라고 생각합니다.

또한 작동하는 데모 델파이 프로그램도 괜찮을 것입니다. 지금까지 가지고있는 모든 델파이 스 니펫은 작동하지 않습니다.

내가 사용하는 프린터는 Epson TM-L60II입니다

도움이 되었습니까?

해결책

TMT88을 위해 Delphi 5에 전체 테스트 프로그램이 작성되었지만 소스는 여기에 크게 크기 때문에 여기에는 바코드 비트가 있습니다.

전체 객체에서 나온 스 니펫으로서 일부 Vars/기능이 누락 될 수 있습니다.

바코드 숯을 얻기 위해

{**
*    @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;

프린터에 인쇄합니다

{**
*    @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;

업데이트

위의 코드에서 제어 코드 상수의 손실이 있습니다. 이름이 충분히 설명되어 있기를 바랍니다.

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

다른 팁

.NET 1.11 용 Microsoft POS를 받으십시오. POS 하드웨어에서 모든 기본 작업을 수행하는 샘플 애플리케이션이 포함 된 SDK가 있습니다. 예를 들어 현금 서랍이 잘 작동한다는 것을 테스트하기 위해 항상 사용하고 있습니다.

소스 코드도 포함되어있어 (.NET에)이를 수행하는 방법을 알 수 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top