2008-11-21 27 views
8

मैं बारकोड (डेल्फी का उपयोग करके) प्रिंट करने के लिए एक ईपीएसन "ईएससी/पीओएस" प्रिंटर प्राप्त करने के लिए संघर्ष कर रहा हूं और जांचना चाहता हूं कि प्रिंटर दोषपूर्ण नहीं है या नहीं। क्या आपको पता है कि मैं "ईएससी/पीओएस" में बारकोड मुद्रित करने के लिए एक प्रोग्राम कहां पा सकता हूं? मुझे लगता है कि एक अंतिम उपाय के रूप में एक ओपीओएस कार्यक्रम भी ठीक रहेगा।मुझे "ईएससी/पीओएस" ईपीएसन बारकोड टेस्ट प्रोग्राम कहां मिल सकता है?

इसके अलावा, काम करने वाला एक डेमो डेल्फी प्रोग्राम भी ठीक होगा। मेरे पास अब तक के सभी डेल्फी स्निपेट काम नहीं कर रहे हैं।

प्रिंटर मैं उपयोग कर रहा हूँ एक Epson TM-L60II

+0

एक ESC/स्थिति संदर्भ – stukelly

+0

के लिए www.epson-pos.com पर एक नज़र मैं पहले से ही संदर्भ है - यह अपने प्रिंटर thats पर काम नहीं करता कारण है कि मैं एक पहले से ही काम कर रहे परीक्षण कार्यक्रम चाहते हैं। –

+0

मेरे पास सीरियल प्रिंटर के लिए एक टेस्ट प्रोग्राम है, क्या आपका प्रिंटर सीरियल है? – stukelly

उत्तर

7

मैं एक पूर्ण परीक्षण कार्यक्रम TMT88 के लिए डेल्फी 5 में लिखा है, लेकिन स्रोत इसलिए यहाँ यहाँ abit बड़ा है बारकोड बिट्स

कृपया ध्यान दें कि पूर्ण वस्तु कुछ वार्स/कार्य मई से स्निपेट के रूप

लापता हो बारकोड वर्ण

{** 
* @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 
+0

धन्यवाद इसके लिए एक स्टैक, मैं परीक्षण और सलाह/मार्कअप –

+1

करूँगा मैंने इस पर कुछ बनाने के दौरान थोड़ी देर बिताई है, कुछ ऐसी चीजें हैं जो ऊपर दिए गए कोड में दस्तावेज किए जाने के साथ कर सकती हैं (बारकोड रूटीन नहीं काम नहीं कर रहा है, क्योंकि यह वहां खड़ा है)। एक बार जब मैंने इसे परीक्षण करना समाप्त कर लिया है तो मैं इसे अच्छी तरह से प्रारूपित कर दूंगा और इसे एक अलग उत्तर के रूप में पोस्ट करूंगा। – robsoft

+0

क्या आप इसे काम करने के लिए मिला? यदि नहीं, तो मैं पूर्ण कोड पोस्ट कर सकता हूं (केवल स्निपेट की बजाय)। – Re0sless

1

नेट 1.11 के लिए माइक्रोसॉफ्ट पीओएस जाओ, यह एक एसडीके कि एक नमूना अनुप्रयोग है कि स्थिति हार्डवेयर पर सभी बुनियादी संचालन करता है शामिल हैं मिला है है। मैं इसका परीक्षण करने के लिए हर समय इसका उपयोग कर रहा हूं कि कैश ड्रॉर्स उदाहरण के लिए ठीक काम करते हैं।

एक स्रोत कोड भी शामिल है (.Net में), ताकि आप देख सकें कि वे इसे कैसे करते हैं।

+0

हाय, इसके लिए धन्यवाद, लेकिन मैं वास्तव में ऐसा करने की तुलना में एक आसान तरीका ढूंढ रहा हूं - बस एक साधारण बारकोड ऐप। पहले से काम करने के लिए साबित हुआ है। –

+0

सबसे पहले, ओपी डेल्फी एप्लिकेशन के लिए एक .NET नहीं मांग रहा है, क्या आप अपने उत्तर में उल्लिखित नमूना कोड का नाम निर्दिष्ट करने की भी देखभाल करेंगे? – AaA