A method for printing labels based on ESC\POS instructions
Patent Information
- Application Number
- CN202111457170.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-01
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2041-12-01
AI Technical Summary
但是现有研究中缺乏在同一硬件结构上基于ESC\POS指令即能够实现小票信息又能够标签信息打印的技术指导
[0027] The invention provides a method for printing labels based on ESC\POS instructions. This method independently distinguishes different printing requirements and adopts corresponding mechanism control to realize preparation and printing tasks. If it is printing a receipt, it directly waits for the user's instructions according to the instructions. The user's paper feeding instructions and printing instructions are executed sequentially. If the printing requirement is label printing, prompt information output is generated based on the printing usage record information to remind the user to complete the preparation work; different printing strategies are activated for different printing requirements, based on simple operations. Ordinary receipt printers can not only print receipts, but also print labels;
Smart Images

Figure CN116198242B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information printing application and optimization technology, and in particular to a method for printing labels based on ESC\POS instructions and applied to a thermal printer. Background Art
[0002] At present, the thermal printer industry mainly operates based on the following instruction sets: 1. ESC\POS instructions, commonly used in receipt printers; 2. TSPL instructions, commonly used in label printers; 3. CPCL, ZPL and other instructions, commonly used in mobile label printers. In actual applications, when using TSPL, ZPL and other instruction sets to print label information, because the print canvas needs to be defined in advance, a minimum memory of the canvas size is required. The larger the memory required, the higher the cost;
[0003] The researchers of the present invention considered that when the ESC\POS instruction is used to print the receipt data, it adopts a working mode of sending data and printing at the same time, because it does not need to store the print data, so the memory required is small. However, the existing research lacks technical guidance for printing both receipt information and label information based on the ESC\POS instruction on the same hardware structure.
[0004] The information disclosed in the background technology section of the present invention is only intended to deepen the understanding of the general background technology of the present invention, and should not be regarded as acknowledging or suggesting in any form that the information constitutes the prior art known to those skilled in the art. Summary of the invention
[0005] To solve the above problems, the present invention provides a method for printing labels based on ESC\POS instructions. In one embodiment, the method includes:
[0006] Step S1: after starting up, determine whether the printing requirement is receipt printing or label printing. If it is receipt printing, directly wait for the user's instruction and execute paper feeding according to the user's paper feeding instruction to realize receipt printing. If the printing requirement is label printing, generate prompt information output according to the printing use record information to remind the user to complete the preparation work;
[0007] Step S2: After the preparation work is completed, detect whether a print execution instruction is received. If received, determine the matching instruction execution mode according to the parameter content in the print execution instruction, and implement printing based on the strategy corresponding to the instruction execution mode;
[0008] Step S3, after each print execution instruction is completed, a print end instruction is generated, a paper feed instruction is automatically generated and a paper feed operation is performed.
[0009] Preferably, in one embodiment, in the step S1, the printing demand is determined according to the user's printing-related instructions, and the printing-related instructions include demand selection instructions, paper feed instructions or printing execution instructions;
[0010] The demand selection instruction is activated by a set button;
[0011] In case the user directly activates the paper feed command or the print execution command, the most recent print record is automatically obtained and the printing requirement is followed.
[0012] Furthermore, in one embodiment, in step S1, for the case where the user directly activates the paper feed instruction or the print execution instruction, the method further includes:
[0013] When automatically obtaining the most recent printing record, output the demand confirmation information to the user. If the user's confirmation feedback is received, it is confirmed to continue to perform subsequent operations according to the current printing demand. Otherwise, select another printing demand.
[0014] Specifically, in one embodiment, the following operations are performed to generate prompt information output according to the print usage record information to remind the user to complete the preparation work:
[0015] Determine whether the previous printing mode is label printing. If not, directly generate a paper feed prompt to remind the user to operate the paper feed or automatically generate a paper feed instruction. If so, further determine whether the paper bin has been opened since the last printing. If not, generate a prompt for direct printing. Otherwise, generate a paper feed prompt or automatically generate a paper feed instruction.
[0016] In an optional embodiment, for the generated paper feeding instruction, the specific paper feeding is automatically realized by identifying the position of the label paper, so that the printing start position is located at the corresponding position of the next label paper, and the preparation work is completed after completion;
[0017] Among them, the position of the label paper can be detected in real time through the paper detection sensor to achieve precise positioning of the paper feeding operation during the printing process.
[0018] In actual application, in one embodiment, the print execution instruction includes a command code, a print mode selection parameter and print content data; the print content data includes: a single-line byte print parameter, a print line number parameter and a specific content part.
[0019] Further, in one embodiment, after it is determined that a print execution instruction has been received, the following operations are performed to determine a matching instruction execution mode according to the parameter content in the print execution instruction:
[0020] A print line number parameter in the identification instruction is used. If the print line number parameter satisfies a first setting condition, a first instruction execution mode is used. If the print line number parameter satisfies a second setting condition, a second instruction execution mode is used.
[0021] When the first instruction execution mode is adopted, the printing data volume and the single label limit data volume are calculated in real time. Whenever the continuous printing data volume reaches the single label limit data volume, the connection instruction and the interruption instruction are automatically generated to activate the paper feeding operation. After the paper feeding is completed, the instruction is continued to be executed until all the data in this instruction is printed;
[0022] When the second command execution mode is adopted, the current printing execution command is directly executed once and for all until it is completed.
[0023] Optionally, in one embodiment, the method further comprises, during the printing process, identifying the type of printing paper in the paper slot, and if the type of printing paper does not match the current printing requirement, terminating the printing and outputting a reminder message;
[0024] After confirming that the printing paper matches, re-execute the current print execution instruction.
[0025] Based on other aspects of the method described in any one or more of the above embodiments, the present invention further provides a storage medium storing program codes that can implement the method described in any one or more of the above embodiments.
[0026] Compared with the closest prior art, the present invention also has the following beneficial effects:
[0027] The present invention provides a method for printing labels based on ESC\POS instructions. The method autonomously distinguishes different printing requirements and adopts corresponding mechanism control to realize preparation work and printing tasks. If it is receipt printing, the method directly waits for the user's instructions and executes the paper feeding instructions and printing instructions of the user in sequence. If the printing requirement is label printing, a prompt information output is generated according to the printing use record information to remind the user to complete the preparation work. Different printing strategies are started for different printing requirements. Based on simple operations, the ordinary receipt printer can print not only receipts but also labels.
[0028] Then, the matching instruction execution mode is determined according to the parameter content in the printing instruction, and printing is implemented according to the corresponding strategy; after the printing execution instruction is implemented, the paper feeding instruction is automatically generated based on the end instruction and the paper feeding operation is implemented. The processing details in the label printing process are fully considered. Under the premise of ensuring small running memory, matching execution strategies are designed for different printing instruction forms, ensuring the accuracy and flexibility of label content printing, realizing the diversification of printing equipment functions, and ensuring the practicality and reliability of multiple functions.
[0029] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0031] Figure 1 It is a schematic diagram of the operation flow of a method for printing labels based on ESC\POS instructions provided in one embodiment of the present invention;
[0032] Figure 2 It is a flowchart of implementing paper searching in a method for printing labels based on ESC\POS instructions provided in another embodiment of the present invention. DETAILED DESCRIPTION
[0033] The following will describe the implementation methods of the present invention in detail in conjunction with the accompanying drawings and embodiments, so that the implementers of the present invention can fully understand how the present invention applies technical means to solve technical problems and achieve the implementation process of technical effects and implement the present invention specifically according to the above implementation process. It should be noted that as long as there is no conflict, the various embodiments and various features of the embodiments in the present invention can be combined with each other, and the technical solutions formed are all within the protection scope of the present invention.
[0034] Although the flowcharts describe the operations as sequential processes, many of the operations may be performed in parallel, concurrently, or simultaneously. The order of the operations may be rearranged. A process may be terminated when its operations are completed, but may also have additional steps not included in the accompanying drawings. A process may correspond to a method, function, procedure, subroutine, subprogram, etc.
[0035] The terms "first", "second", etc. may be used herein to describe various units, but these units should not be limited by these terms, and these terms are used only to distinguish one unit from another unit. The term "and / or" used herein includes any and all combinations of one or more of the listed associated items. When a unit is referred to as being "connected" or "coupled" to another unit, it can be directly connected or coupled to the other unit, or there can be intermediate units.
[0036] The terms used herein are only for describing specific embodiments and are not intended to limit exemplary embodiments. Unless the context clearly indicates otherwise, the singular forms "one", "one" and "item" used herein are also intended to include plural numbers. It should also be understood that the terms "include" and / or "comprise" used herein specify the existence of stated features, integers, steps, operations, units and / or components, without excluding the existence or addition of one or more other features, integers, steps, operations, units, components and / or combinations thereof.
[0037] At present, the thermal printer industry mainly operates based on the following instruction sets: 1. ESC\POS instructions, commonly used in receipt printers; 2. TSPL instructions, commonly used in label printers; 3. CPCL, ZPL and other instructions, commonly used in mobile label printers. In actual applications, when using TSPL, ZPL and other instruction sets to print label information, because the print canvas needs to be defined in advance, a minimum memory of the canvas size is required. The larger the memory required, the higher the cost;
[0038] The researchers of the present invention considered that when the ESC\POS instruction is used to print the receipt data, it adopts a working mode of sending data and printing at the same time, because it does not need to store the print data, so the memory required is small. However, the existing research lacks technical guidance for printing both receipt information and label information based on the ESC\POS instruction on the same hardware structure.
[0039] The present invention provides a method for printing labels based on ESC\POS instructions. By designing label printing implementation logic in a receipt printer based on ESC\POS instructions, labels can be printed under ESC\POS instructions without using a high-cost, large-memory printer, so that an ordinary receipt printer can not only print receipts but also print labels, thereby saving costs and improving efficiency, and effectively improving the market competitiveness of products.
[0040] Next, the detailed process of the method of the embodiment of the present invention is described in detail based on the accompanying drawings. The steps shown in the flowchart of the accompanying drawings can be executed in a computer system including a set of computer executable instructions. Although the logical order of each step is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0041] Embodiment 1
[0042] In actual application, the memory required for printing receipts is small because it receives print data while printing. During the printing process, the printer automatically locates the starting and ending positions of the print content. When loading paper, it automatically searches for the paper to the printing starting position of the receipt paper information content. When printing is finished, it automatically searches for the paper to the end of the information content and the starting position of the next receipt information. In receipt printing, after executing a print command, the printer only needs to stop, and at most execute a paper feed command (for example: 1B 64) at the end of the print content.
[0043] However, when implementing label printing, because it is necessary to automatically feed the paper to the specific starting position of the next label after printing is completed, it cannot be achieved by directly executing the paper feed command sent by the host computer, otherwise the printing position will deviate. When implementing label printing, the paper feed requirement is different from the paper feed for receipt printing. The paper feed for receipt printing is at any position, but the unit of label paper feed must be sheets. For example, press the paper feed button, and in the receipt printing mode, the receipt paper feeds, and releases the paper feed button, and the receipt paper stops feeding. In label mode, you need to press the paper feed button, and the printer stops after feeding exactly one label, and stops at the printing position of the next label. This is difficult to achieve based on manual control, so a corresponding control mechanism needs to be set.
[0044] Figure 1 The flowchart of the method for printing labels based on ESC\POS instructions provided in the first embodiment of the present invention is shown. Figure 1 It can be seen that, based on the above considerations, in one embodiment, the method of the present invention includes the following steps.
[0045] Step S1: after starting up, determine whether the printing requirement is receipt printing or label printing. If it is receipt printing, directly wait for the user's instruction and execute paper feeding according to the user's paper feeding instruction to realize receipt printing. If the printing requirement is label printing, generate prompt information output according to the printing use record information to remind the user to complete the preparation work;
[0046] Step S2: After the preparation work is completed, detect whether a print execution instruction is received. If received, determine the matching instruction execution mode according to the parameter content in the print execution instruction, and implement printing based on the strategy corresponding to the instruction execution mode;
[0047] Step S3, after each print execution instruction is completed, a print end instruction is generated, a paper feed instruction is automatically generated and a paper feed operation is performed.
[0048] In actual application, when the printer is turned on, it can automatically feed a label according to the situation to determine the label position. (It will automatically learn the label gap), but whether to automatically feed paper when the printer is turned on is not a necessary condition. It can also be activated by activating the paper feed key or opening and closing the printer. Even if the paper compartment was not opened when the printer was turned off last time, it is not necessary to turn on the printer to automatically feed paper.
[0049] Therefore, further, in one embodiment, a prompt information output is generated according to the print usage record information through the following operations to remind the user to complete the preparation work:
[0050] Determine whether the previous printing mode is label printing. If not, directly generate a paper feed prompt to remind the user to operate the paper feed or automatically generate a paper feed instruction. If so, further determine whether the paper bin has been opened since the last printing. If not, generate a prompt for direct printing. Otherwise, generate a paper feed prompt or automatically generate a paper feed instruction.
[0051] When printing labels, the paper feeding requirements are different from those of printing receipts. The paper feeding for printing receipts is at any position, but the paper feeding unit for labels must be sheets. For example, when the paper feed button is pressed, the receipt paper feeds in the receipt printing mode, and when the paper feed button is released, the receipt paper feed stops. In the label mode, when the paper feed button is pressed, the printer stops after feeding one label and stops at the printing position of the next label. Therefore, in one embodiment, for the generated paper feed instruction, the position of the label paper is automatically identified to realize specific paper feeding, so that the printing start position is located at the corresponding position of the nearest next label paper, and the preparation work is completed after completion.
[0052] Specifically, in one embodiment, the position of the label paper is detected in real time by a paper detection sensor, so as to achieve accurate positioning of the paper feeding operation during the printing process.
[0053] In order to realize both receipt printing and label printing in an orderly manner on the same printing device, it is necessary to accurately identify the type of printing to be performed by the user, that is, the printing demand. Preferably, in one embodiment, in the step S1, the printing demand is determined according to the user's printing-related instructions;
[0054] Considering that after operating the printing device, the user may not operate the print type selection button, but directly control to start printing, activate the paper feed instruction or the print execution instruction, therefore, in one embodiment, the printing related instruction includes a demand selection instruction or a paper feed instruction;
[0055] The demand selection instruction is activated by a set button;
[0056] In case the user directly activates the paper feed command or the print execution command, the most recent print record is automatically obtained and the printing requirement is followed.
[0057] Furthermore, considering that the previous printing demand is directly used, when the operator changes or faces different working scenes, there may be inconsistencies between the previous and next printing demands, which may lead to incorrect demand selection information. In order to ensure the reliability of the printing demand, in one embodiment, in step S1, for the case where the user directly activates the paper feed instruction or the print execution instruction, the following is also included:
[0058] When automatically obtaining the most recent printing record, output the demand confirmation information to the user. If the user's confirmation feedback is received, it is confirmed to continue to perform subsequent operations according to the current printing demand. Otherwise, select another printing demand.
[0059] Specifically, in one embodiment, the print execution instruction includes a command code, a print mode selection parameter and print content data; the print content data includes: a single-line byte print parameter, a print line number parameter and a specific content portion.
[0060] In actual application, the host computer sends a print command. Generally, the effective print command is in ESC\POS, using 1D76: The specific commands are as follows:
[0061] 1D 76 30m[xL xH yL yH d1....dk]
[0062] in:
[0063] 1D 76 30 is the command code, the format is fixed;
[0064] m is: mode selection parameter of double width and double height;
[0065] [xL xH yL yH d1.....dk] is the specific printing data, where:
[0066] xL, xH: indicates how many bytes of data are needed to print a line, xL is the low byte, xH is the high byte,
[0067] The number of bytes required to print a line = (xH*256)+(xL)
[0068] yL, yH: Indicates how many lines of printing the data in the command can support, yL is the low byte, yH is the high byte,
[0069] The number of lines that data can support printing = (yH*256)+(yL)
[0070] d1.....dk: specific data, d1 is the first byte, dk is the last byte;
[0071] k represents the total number of bytes in the command, which is calculated as follows:
[0072] K = [Number of bytes required for single-line printing] * [Number of lines that can be printed]
[0073] =[(xH*256)+(xL)]*[(yH*256)+(yL)]
[0074] Further, according to the above printing instructions, the host computer has two instruction sending methods. In actual application, which instruction sending method is specifically adopted usually depends on the configuration of the host computer. At present, when a PC is generally used for printing, the first method is more commonly used, and when a mobile phone is used for printing, the second method is more commonly used. Accordingly, the present invention designs two printing instruction execution methods:
[0075] The first is the common method of USB driver: the printing instruction is a single instruction with 3mm or 24 dots, and a whole label task is issued in multiples of 3mm. Assuming that the limit printing data volume of a label is 48*100mm, then a total of 34 printing instructions will be sent to print a label (100mm / 3mm, a total of 34 data distributions are required, and the last time 1mm of data is sent). If the paper is fed to the next label after each printing instruction in the conventional way, it is obviously wrong. Therefore, it is necessary to execute a connection instruction: 1F F0 03 00 after each unit printing instruction (1D 76 printing instruction, corresponding to the printing content in a single instruction) is sent. After the whole label is printed, execute an end command: 1F F0 05 00; the printer can automatically feed the paper to the next label only after executing the end command; this method can minimize the memory required for the upper computer to convert the print content.
[0076] The second method is to directly send the entire label content to be printed at one time through the overall 1D 76 printing instruction. There is no need for 1F F0 05 00 connection, and even no need for 1F F0 03 00 end command. After the print execution instruction is completed, the paper will be automatically fed to the next label. Among them, the instruction for sending data is 1D 76 30m[xL xH yL yHd1.....dk]), and XL XH YL YH in the instruction is the data volume this time. The method can be confirmed based on this value.
[0077] Based on the above analysis, in one embodiment, after determining that a print execution instruction is received, the design is to determine a matching instruction execution mode according to the parameter content in the print execution instruction according to the following operations:
[0078] A print line number parameter in the identification instruction is used. If the print line number parameter satisfies a first setting condition, a first instruction execution mode is used. If the print line number parameter satisfies a second setting condition, a second instruction execution mode is used.
[0079] Specifically, in one embodiment, when the first instruction execution mode is adopted, the printing data volume and the single label quota data volume are calculated in real time. Whenever the continuously printed data volume reaches the single label quota data volume, a connection instruction and an interruption instruction are automatically generated to activate the paper feeding operation. After the paper feeding is completed, the instruction is continued to be executed until all the data in this instruction is printed.
[0080] When the second command execution mode is adopted, the current printing execution command is directly executed once and for all until it is completed.
[0081] In actual applications, when the first method is used, both commands may exist, so the printer needs to automatically adapt to the two methods. In addition, the 1F F0 03 00 and 1F F0 05 00 commands are not standard ESC\POS commands. This command belongs to the data end mark, which means that the host computer tells the printer that a piece of data has ended or a label has been printed. Without these two pieces of data, the printer cannot autonomously locate the printing position relative to the label. Before each printing command is implemented, the starting point of the label needs to stop at the printing line position. After printing the label, the paper needs to be automatically fed to the tear knife position.
[0082] During actual printing, the first or second instruction sending method can also be distinguished according to the Yl YH value of the unit printing instruction. If the value is 24, it is the first instruction sending method, using the first instruction execution mode. If it is greater than 24, it is the second one.
[0083] If the first method is used to send data, the amount of data in a single instruction is usually 3mm. Therefore, it is possible to automatically distinguish whether the data is sent in the first or second method by judging whether the amount of data in the instruction is 3mm. If it is the first method, the two instructions are necessary.
[0084] The specific method to be used depends on the actual situation of the host computer. If the host computer has slow computing speed and small memory, the first method can be used. Otherwise, the second method can also be used. The second method is simpler in control and does not require complex calculations and image segmentation.
[0085] During the printing process, the paper detection sensor needs to detect the label position in real time. In order to locate the label position in real time and enhance the positioning accuracy of the label position. When the printing content is completed, if the label is still located in the label, the paper will continue to feed to the end of the label and stop at the starting position of the next label. If the label has reached the end position during printing, there are two solutions. One is to end the printing, discard the unprinted content, and the printer will still stop at the starting position of the next label. The other is to continue to complete the printing, and the remaining printed content will be printed on the second label. After printing is completed, the paper will continue to feed to the end of the second label and stop at the starting position of the third label.
[0086] How to realize label positioning depends on the type of label. Currently, the most widely used labels include die-cut labels, black label labels, and positioning hole labels. Therefore, in actual application, a photoelectric sensor can be set on the printer to determine the position of the label according to the mark on the label. Figure 2 The operating flow of realizing automatic paper feeding (paper searching) after printing is completed in an embodiment of the present invention is shown.
[0087] Furthermore, since the printing of receipt information and label information must be realized on the same printing device at the same time, and the two printing requirements require different types of printing paper, when the printing requirements and the printing paper do not correspond, although the printing action can be realized, the printing result is invalid, which not only wastes printing consumables, but also causes the printing device to perform redundant work, resulting in a double waste of resources and time. Therefore, in order to ensure that when there is a mismatch between the printing requirements and the printing paper, it can be discovered and handled in time by the operator, preferably, in one embodiment, the method also includes, during the printing process, real-time identification of the type of printing paper in the paper slot, if the type of printing paper does not match the current printing requirements, terminating printing and outputting a reminder message;
[0088] After confirming that the printing paper matches, re-execute the current print execution instruction.
[0089] Based on the label printing mechanism based on ESC\POS instructions provided in the above embodiments of the present invention, labels can be printed under ESC\POS instructions without using a high-cost, large-memory printer, so that ordinary receipt printers can not only print receipts but also print labels, overcoming the limitations of existing label printing mechanisms such as large memory and high cost, effectively improving the market competitiveness of products, and expanding the functional diversification of printing equipment.
[0090] In addition, combined with actual needs, technicians can also set up two label printing mechanisms, ESC\POS instructions and TSPL instructions, on synonymous printing devices at the same time according to needs; when applied to printing labels, the two instruction sets of ESC\POS instructions and TSPL instructions are different. ESC\POS instructions often start with hexadecimal 1F, 1B and other commands, while TSPL instructions start with characters. For example, the text printing instruction is: TEXT 5,80,"0",0,1,1,"Producer". In the ESC\POS instruction, text printing is WYSIWYG printing. As long as the characters in the font library are available, they can be printed directly. Therefore, if it is set to ESC\POS instructions, it cannot be compatible with TSPL instructions. The instructions will be output as text on the printing paper, but when it is set to TSPL instructions, it can be compatible with all other ESC\POS instructions except text printing. When the two instructions coexist, they can be set to TSPL instructions by default, which can be compatible with most of the two instructions. No manual intervention is required.
[0091] For the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the order of the actions described, because according to the present invention, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0092] It should be pointed out that, in other embodiments of the present invention, the method can also obtain a new label printing method by combining one or several of the above embodiments.
[0093] It should be noted that, based on the method in any one or more of the above-mentioned embodiments of the present invention, the present invention also provides a storage medium, on which is stored a program code that can implement the method as described in any one or more of the above-mentioned embodiments, and when the code is executed by the operating system, it can implement the method of printing labels based on ESC\POS instructions as described above.
[0094] It should be understood that the embodiments disclosed in the present invention are not limited to the specific structures, processing steps or materials disclosed herein, but should be extended to equivalent substitutions of these features understood by ordinary technicians in the relevant field. It should also be understood that the terms used herein are only used for the purpose of describing specific embodiments and are not meant to be limiting.
[0095] The "one embodiment" mentioned in the specification means that a particular feature, structure or characteristic described in conjunction with the embodiment is included in at least one embodiment of the present invention. Therefore, the phrase "one embodiment" appearing in various places throughout the specification does not necessarily refer to the same embodiment.
[0096] Although the embodiments disclosed in the present invention are as above, the above contents are only embodiments adopted for facilitating the understanding of the present invention and are not intended to limit the present invention. Any technician in the technical field to which the present invention belongs can make any modifications and changes in the form and details of the implementation without departing from the spirit and scope disclosed in the present invention, but the patent protection scope of the present invention shall still be subject to the scope defined in the attached claims.
Claims
1. A method for printing labels based on ESC\POS instructions, characterized in that: The method comprises: Step S1: after starting up, determine whether the printing requirement is receipt printing or label printing. If it is receipt printing, directly wait for the user's instruction and execute paper feeding according to the user's paper feeding instruction to realize receipt printing. If the printing requirement is label printing, generate prompt information output according to the printing use record information to remind the user to complete the preparation work; Step S2: After the preparation work is completed, detect whether a print execution instruction is received. If received, determine the matching instruction execution mode according to the parameter content in the print execution instruction, and implement printing based on the strategy corresponding to the instruction execution mode; Step S3, after each print execution instruction is completed, a print end instruction is generated, a paper feed instruction is automatically generated and a paper feed operation is performed; In the step S1, the printing demand is determined according to the user's printing-related instructions, wherein the printing-related instructions include a demand selection instruction, a paper feed instruction or a printing execution instruction; The demand selection instruction is activated by a set button; When the user directly activates the paper feed command or print execution command, the most recent print record is automatically obtained and the printing requirement is used; Wherein, for the case where the user directly activates the paper feed instruction or the print execution instruction, it also includes: When automatically obtaining the most recent printing record, output the demand confirmation information to the user. If the user's confirmation feedback is received, it is confirmed to continue to perform subsequent operations according to the current printing demand, otherwise, another printing demand is selected; For the generated paper feeding instruction, the specific paper feeding is automatically realized by identifying the position of the label paper, so that the printing start position is located at the corresponding position of the next label paper. After completion, the preparation work is completed; Among them, the position of the label paper is detected in real time by the paper detection sensor, so as to realize the precise positioning of the paper feeding operation during the printing process.
2. The method according to claim 1, characterized in that The following operations are performed to generate prompt information output based on the print usage record information to remind the user to complete the preparation work: Determine whether the previous printing mode is label printing. If not, directly generate a paper feed prompt to remind the user to operate the paper feed or automatically generate a paper feed instruction. If so, further determine whether the paper bin has been opened since the last printing. If not, generate a prompt for direct printing. Otherwise, generate a paper feed prompt or automatically generate a paper feed instruction.
3. The method according to claim 1, characterized in that: The print execution instruction includes a command code, print mode selection parameters and print content data; The print content data includes: single-line byte print parameters, print line number parameters and specific content parts.
4. The method according to claim 1, characterized in that After confirming that the print execution command has been received, follow the steps below to determine the matching command execution mode based on the parameter content in the print execution command: A print line number parameter in the identification instruction is used. If the print line number parameter satisfies a first setting condition, a first instruction execution mode is used. If the print line number parameter satisfies a second setting condition, a second instruction execution mode is used.
5. The method according to claim 4, characterized in that When the first instruction execution mode is adopted, the printing data volume and the single label limit data volume are calculated in real time. Whenever the continuous printing data volume reaches the single label limit data volume, the connection instruction and the interruption instruction are automatically generated to activate the paper feeding operation. After the paper feeding is completed, the instruction is continued to be executed until all the data in this instruction is printed; When the second command execution mode is adopted, the current printing execution command is directly executed once and for all until it is completed.
6. The method according to claim 1, characterized in that The method further includes, during the printing process, identifying the type of printing paper in the paper slot, and if the type of printing paper does not match the current printing requirement, terminating the printing and outputting a reminder message; After confirming that the printing paper matches, re-execute the current print execution instruction.
7. A storage medium, characterized in that: The storage medium stores program codes that can implement the method as claimed in any one of claims 1 to 6.
