Label printing method and device, electronic equipment and storage medium

By automatically calculating the instruction position of the label printer, the problems of complex instruction positioning and inefficient development in the prior art are solved, and efficient label printing development and accurate printing effects are achieved.

CN120335737APending Publication Date: 2025-07-18ZHOUPU DATA TECH NANJING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510408255.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-02
Publication Date
2025-07-18

AI Technical Summary

Technical Problem

When using TSPL instructions for label printing and development, the command positioning is complex, the development efficiency is inefficient and the calibration process is cumbersome, which leads to developers facing great challenges.

Method used

By obtaining the configuration data of the printing label paper, including line spacing, the horizontal coordinates and vertical coordinates of each instruction are automatically calculated, and the vertical coordinates of the previous instruction are combined, the automatic layout management is realized, and the vertical coordinates of subsequent instructions are automatically calculated, which improves development efficiency and printing accuracy.

Benefits of technology

It realizes automatic layout of the printing position of the instructions, improves development efficiency and printing accuracy, and solves the problems of complex command positioning and cumbersome calibration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120335737A_ABST
    Figure CN120335737A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a label printing method and device, electronic equipment and a storage medium. The method comprises the following steps: acquiring configuration data of printing label paper, wherein the configuration data at least comprises line spacing; determining the horizontal coordinate of the ith line of printing content according to the alignment mode of the ith line of printing content and the attribute data of the ith line of printing content; determining the ordinate of the ith line of printing content according to the ordinate of the (i-1) th line of printing content, the attribute data of the (i-1) th line of printing content and the line spacing; and printing the ith line of printing content by adopting the abscissa and the ordinate of the ith line of printing content. Through automatic layout management, on the basis of the ordinate and the row height of the previous instruction, in combination with the row spacing, the ordinate of the subsequent instruction is automatically calculated, automatic calculation of the coordinate position of each instruction in the content is achieved, automatic layout of the printing position of the instruction is achieved, and therefore the development efficiency and the printing precision are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of computer technology, and particularly to a label printing method, apparatus, electronic device, and storage medium. Background Art

[0002] In a warehouse operation scenario, after operations such as picking and shelving are completed, a label paper needs to be printed and pasted on a box. The content of the label paper is dynamic, and in different business scenarios, the layout of the printed label content is diverse, and the size of the label paper is also different. The App (Application) needs to support a thermal label printer and at the same time adapt to label papers of different sizes. The device supports two printing methods, one is a picture, and the other is the TSPL (Thermal Sticker Printer Language) general instruction set. According to actual business, label printing dynamics, efficiency, and other requirements, the label printing function usually adopts the second solution to achieve label content printing through the arrangement of the TSPL instruction set.

[0003] In the process of implementing the present invention, the inventors found the following technical problems in the prior art: It is necessary to manually instruct the XY coordinate positions of each instruction to achieve content layout and printing, resulting in problems such as complex instruction positioning, low development efficiency, and cumbersome calibration processes. These problems pose great challenges to developers when using TSPL for label printing development. Summary of the Invention

[0004] The embodiments of the present invention provide a label printing method, apparatus, electronic device, and storage medium, which solve the problems of complex instruction positioning, low development efficiency, and cumbersome calibration processes in the process of using TSPL instructions for label printing development.

[0005] In a first aspect, the embodiments of the present invention provide a label printing method, which includes:

[0006] Obtain configuration data of the printed label paper, where the configuration data includes at least line spacing;

[0007] Determine the abscissa of the printing content in the i-th row according to the alignment method of the printing content in the i-th row and the attribute data of the printing content in the i-th row;

[0008] Determine the ordinate of the printing content in the i-th row according to the ordinate of the printing content in the (i - 1)-th row, the attribute data of the printing content in the (i - 1)-th row, and the line spacing;

[0009] Print the printing content in the i-th row using the abscissa and the ordinate of the printing content in the i-th row.

[0010] Second aspect, an embodiment of the present invention further provides a label printing device, which includes:

[0011] A configuration data acquisition module, configured to acquire configuration data of a printed label paper, where the configuration data at least includes a line spacing;

[0012] An abscissa determination module, configured to determine the abscissa of the printed content of the i-th row according to the alignment method of the printed content of the i-th row and the attribute data of the printed content of the i-th row;

[0013] An ordinate determination module, configured to determine the ordinate of the printed content of the i-th row according to the ordinate of the printed content of the (i - 1)-th row, the attribute data of the printed content of the (i - 1)-th row, and the line spacing;

[0014] A printing module, configured to print the printed content of the i-th row by using the abscissa and the ordinate of the printed content of the i-th row.

[0015] Third aspect, an embodiment of the present invention further provides an electronic device, which includes:

[0016] At least one processor; and

[0017] A memory communicatively connected to the at least one processor; wherein,

[0018] The memory stores a computer program executable by the at least one processor, and when the computer program is executed by the at least one processor, the at least one processor is caused to implement the label printing method provided by any embodiment of the present invention.

[0019] Fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which computer instructions are stored, and when the computer instructions are used by a processor, the label printing method provided by any embodiment of the present invention is implemented.

[0020] In an embodiment of the present invention, configuration data of a printed label paper is obtained, and the configuration data at least includes line spacing; the abscissa of the printed content in the i-th row is determined according to the alignment mode of the printed content in the i-th row and the attribute data of the printed content in the i-th row; the ordinate of the printed content in the i-th row is determined according to the ordinate of the printed content in the (i - 1)-th row, the attribute data of the printed content in the (i - 1)-th row, and the line spacing; the printed content in the i-th row is printed using the abscissa and the ordinate of the printed content in the i-th row. Through automated layout management, based on the ordinate and line height of the previous instruction, combined with the line spacing, the ordinate of the subsequent instruction is automatically calculated, solving the problems of complex instruction positioning, low development efficiency, and cumbersome calibration process during the development of label printing using TSPL instructions, realizing the automatic calculation of the coordinate position of each instruction in the content, realizing the automatic layout of the printing position of the instructions, thereby improving the development efficiency and printing accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 It is a flowchart of a label printing method provided in Embodiment 1 of the present invention;

[0022] Figure 2 It is an effect diagram of the output of the label paper of the Bluetooth label printer of the present invention;

[0023] Figure 3 It is a flowchart of a label printing method provided in Embodiment 2 of the present invention;

[0024] Figure 4 It is a schematic structural diagram of a label printing device provided in Embodiment 3 of the present invention;

[0025] Figure 5 It is a schematic structural diagram of an electronic device provided in Embodiment 4 of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0026] The present invention will be further described in detail below with reference to the drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the present invention, rather than limiting the present invention. Additionally, it should be noted that, for the sake of description, only parts related to the present invention are shown in the drawings, rather than all the structures.

[0027] Before introducing the embodiments of the present invention, an exemplary description of the application scenarios that the embodiments of the present invention may involve will be given to better understand the label printing process described in the following embodiments.

[0028] When using TSPL (Thermal Sticker Printer Language) for label template development, the existing technology mainly relies on manually specifying the XY position coordinates of each instruction to realize the typesetting and printing of content. Specifically, in TSPL, developers need to calculate the position coordinates of each element on the label paper according to the size and design requirements of the label paper, and write them into the instructions. For example, if a developer needs to print a product label, it is necessary to calculate the alignment offset and accumulate the coordinates line by line to obtain the XY coordinates of each line of printed content. In this case, if the second line of printed content is deleted, the Y coordinate of the third line needs to be recalculated. If the third line of printed content is adjusted, the width needs to be recalculated and the X coordinate needs to be adjusted. This method is cumbersome to calculate and difficult to adjust in linkage. And because it is difficult to ensure the accuracy of the printed content by manually specifying the position coordinates, developers usually need to calibrate the label after printing.

[0029] The existing technology realizes the layout and printing of label content by manually specifying the XY position coordinates of each instruction. Although it can meet basic printing needs, it has problems such as complex instruction positioning, low development efficiency and cumbersome calibration process. These problems make developers face great challenges when using TSPL for label template development.

[0030] Embodiment 1

[0031] Figure 1 This is a flowchart of a label printing method provided in the first embodiment of the present invention. This embodiment is applicable to the case where a label printer is used to print labels. The method can be executed by the label printing device provided in the embodiment of the present invention. The device can be implemented in software and / or hardware. Figure 1 The label printing method provided in this embodiment includes:

[0032] Step S110: Acquire configuration data for printing label paper, wherein the configuration data at least includes line spacing.

[0033] Among them, the configuration data of the printed label paper includes at least the height, width, line spacing, and top margin of the printed label paper. Read the configuration data of the printed label paper and initialize the basic information such as the height, width, line spacing, and top margin of the printed label paper. The top margin is used to determine the ordinate of the first-line printed content, which is usually a default value marginTop (default top margin). If the alignment method of the printed page is not specified, the ordinate of the first-line printed content is determined according to marginTop. Exemplarily, if the top margin is default to 0, the ordinate of the first-line printed content is 0. In addition, the top margin can also be dynamically adjusted according to the alignment method of the printed page. For example, if the printed page, that is, the entire printed page of the printed label paper (including the printed content of all lines), adopts vertical center alignment, the top margin needs to be re-determined.

[0034] Step S120: Determine the abscissa of the i-th line printed content according to the alignment method of the i-th line printed content and the attribute data of the i-th line printed content.

[0035] Among them, i is an integer greater than 1. The alignment method of the printed content mainly refers to the arrangement method of text, images, or other elements on the page, such as left alignment, center alignment, and right alignment, etc. The default alignment method of the printed content is left alignment. According to the specific alignment method and combined with the attribute data of each line of printed content, the abscissa of each line of printed content under different alignment methods can be determined. When the alignment method specified for the i-th line printed content is left alignment, the default value marginLeft (default left margin) can be directly used to determine the abscissa of the i-th line printed content. If the alignment method of the first line printed content is left alignment and marginLeft is 5, the abscissa of the first line printed content is 5.

[0036] Optionally, determining the abscissa of the i-th line printed content according to the alignment method of the i-th line printed content and the attribute data of the i-th line printed content includes: if the alignment method of the i-th line printed content is center alignment or right alignment, determine the width of the i-th line printed content according to the attribute data of the i-th line printed content; determine the abscissa of the i-th line printed content according to the width of the printed label paper in the configuration data and the width of the i-th line printed content.

[0037] If the alignment method of the i-th line printed content is center alignment or right alignment, it is necessary to determine the width of the content of this line according to the attribute data of the i-th line printed content. The attribute data of the printed content includes the font type, font size, number of characters, etc. of the text, as well as the size of the barcode and the size of the QR code. After determining the width of the i-th line printed content and combining the width of the printed label paper in the configuration data, the abscissa of the i-th line content can be calculated. The specific calculation method will vary according to different alignment methods.

[0038] Specifically, if the alignment method specified for the printing content in the i-th row is centered alignment, then according to the width of the printing label paper and the width of the printing content in the i-th row, the abscissa of the printing content in the i-th row is determined, and the formula is as follows:

[0039]

[0040] Where X center is the abscissa of the printing content in the i-th row when centered alignment is used, W label is the width of the printing label paper, and W content is the width of the printing content in the i-th row.

[0041] If the alignment method specified for the printing content in the i-th row is right alignment, then subtract the width of the i-th printing content from the width of the printing label paper to obtain the abscissa of the printing content in the i-th row, and the formula is as follows:

[0042] X Right = W label - W content

[0043] Where X Right is the abscissa of the printing content in the i-th row when right alignment is used, W label is the width of the printing label paper, and W content is the width of the printing content in the i-th row.

[0044] Optionally, determining the width of the printing content in the i-th row according to the attribute data of the printing content in the i-th row includes: if the printing content in the i-th row is a text type, then determine the width of the printing content in the i-th row according to the font type, font size, and number of characters; if the printing content in the i-th row is an image encoding type, then determine the width of the printing content in the i-th row according to the size of the image encoding.

[0045] Among them, the types of printing content include text types and image encoding types. The image encoding types include barcodes and QR codes. The width of the printing content can be determined according to the attribute data of different types of printing content. If the printing content is a text type, the attribute data affecting the width of the printing content includes the font type, font size, number of characters, etc. of the text. The font type determines the baseline width and height of the characters, the font size directly affects the physical size of the characters, and the number of characters is the number of characters included in the printing content. If the printing content is an image encoding type, and the image encoding types include barcodes and QR codes, the attribute data affecting the width of the printing content is the size of the barcodes and QR codes.

[0046] Determining the abscissa of the printing content in the i-th row through the alignment method of the printing content in the i-th row and the attribute data of the printing content in the i-th row realizes the automatic calculation of the abscissa of the printing content, eliminating the need for developers to manually calculate the abscissa of each row of printing content and improving the development efficiency.

[0047] Step S130: Determine the ordinate of the printing content in the i-th row according to the ordinate of the printing content in the (i - 1)-th row, the attribute data of the printing content in the (i - 1)-th row, and the line spacing.

[0048] Among them, the ordinate of the (i - 1)-th row refers to the starting position of the content of that row on the printing label paper. The attribute data includes the height, font size, alignment method, etc. of that row. Next, the ordinate of the i-th row needs to be determined according to the position and attributes of the (i - 1)-th row. The logic is that the starting position of the i-th row is equal to the starting position of the (i - 1)-th row plus the height of the (i - 1)-th row, plus the line spacing. For example, if the height of the (i - 1)-th row is H i-1 , and the line spacing is S, then the starting Y coordinate Y i of the i-th row = Y i-1 + H i-1 + S. This can ensure that there is no overlap between rows and a certain spacing is maintained. However, there may be other factors to consider here. For example, the attribute data of the (i - 1)-th row may affect the calculation of the line spacing. For example, if a larger font or an image is used in the (i - 1)-th row, a larger line spacing may be required. Or, if some rows require special alignment methods, such as vertical center alignment, it may affect the positions of subsequent rows.

[0049] In addition, the line spacing may not be a fixed value but is dynamically adjusted according to the content. For example, when the total height of the content exceeds the height of the label paper, the line spacing may need to be compressed to fit. In this case, the line spacing may be adjusted according to the remaining space, rather than just a fixed configuration value.

[0050] Optionally, the method further includes: determining the ordinate of the printing content in the first row according to the top margin in the configuration data; where, when the alignment method of the page to be printed is vertical center alignment, the top margin is determined according to the difference between the total height of the printing content and the height of the printing label paper.

[0051] Among them, the alignment method of the printing page refers to the position of the entire page on the printing label paper, such as whether the page should be vertically centered. The total height of the printing content is the sum of the heights of the printing content in all rows. If the vertical center alignment is enabled for the page to be printed, calculate the difference between the total height of the printing content and the height of the printing label paper, and dynamically adjust the top margin. The formula is as follows:

[0052]

[0053] Among them, marginTop is the top margin, H label is the height of the printing label paper, and H content_total is the total height of the printing content.

[0054] By determining the ordinate of the first-line printed content through the top margin in the configuration data, the vertical position of the printed content on the page can be precisely controlled. Moreover, without the need for users to manually measure and adjust the top margin, the system can dynamically adjust the top margin according to the alignment of the printed page, thereby flexibly adjusting the position of the first-line printed content to meet diverse printing requirements.

[0055] Step S140: Print the i-th line of printed content using the abscissa and ordinate of the i-th line of printed content.

[0056] Convert the abscissa and ordinate of each line of printed content processed by calculation into an instruction string recognizable by the label printer, establish a Bluetooth connection, convert the instruction string into a byte array, and send it to the Bluetooth label printer for printing at one time. As Figure 2 , which is the effect diagram of the label paper output by the Bluetooth label printer of this application.

[0057] In the embodiment of the present invention, by obtaining the configuration data of the printed label paper, the configuration data at least includes the line spacing; determine the abscissa of the i-th line of printed content according to the alignment of the i-th line of printed content and the attribute data of the i-th line of printed content; determine the ordinate of the i-th line of printed content according to the ordinate of the (i - 1)-th line of printed content, the attribute data of the (i - 1)-th line of printed content, and the line spacing; print the i-th line of printed content using the abscissa and ordinate of the i-th line of printed content. Through automated layout management, based on the ordinate and line height of the previous instruction, combined with the line spacing, automatically calculate the ordinate of the subsequent instruction, which solves the problems of complex instruction positioning, low development efficiency, and cumbersome calibration process in the process of using TSPL instructions for label printing development, realizes the automatic calculation of the coordinate position of each instruction in the content, and realizes the automatic layout of the printing position of the instructions, thereby improving the development efficiency and printing accuracy.

[0058] Embodiment 2

[0059] Figure 3 As shown in the flowchart of an object conversion method provided by the second embodiment of the present invention, on the basis of the above embodiment, the determination of "determine the ordinate of the i-th line of printed content according to the ordinate of the (i - 1)-th line of printed content, the attribute data of the (i - 1)-th line of printed content, and the line spacing" is refined.

[0060] As Figure 3 shown, the method includes:

[0061] Step S210: Obtain the configuration data of the printed label paper, and the configuration data at least includes the line spacing.

[0062] Step S220: Determine the abscissa of the print content in the i-th row based on the alignment of the print content in the i-th row and the attribute data of the print content in the i-th row.

[0063] Step S230: Determine whether the print content in the (i - 1)-th row is a text type. If so, continue to execute Step S240; if not, that is, the print content in the (i - 1)-th row is an image code type, then jump to execute Step S250.

[0064] Among them, the types of print content include text types and image code types. The image code types include barcodes and QR codes.

[0065] Step S240: Determine the height of the print content in the (i - 1)-th row according to the font type, font size, and number of characters.

[0066] For text type content, the attribute data affecting the height of the print content includes the font type, font size, number of characters, etc. of the text. The height of the print content in this row can be determined according to the font type, font size, and number of characters of the print content in this row.

[0067] Step S250: Determine the height of the print content in the (i - 1)-th row according to the size of the image code.

[0068] For image code type content, the attribute data affecting the height of the print content includes the size of the image code. The height of the print content in this row can be determined according to the size of the image code in this row, such as the size of the barcode and the size of the QR code.

[0069] Step S260: Add the ordinate of the print content in the (i - 1)-th row, the height of the print content in the (i - 1)-th row, and the line spacing to obtain the ordinate of the print content in the i-th row.

[0070] Determine the height of the print content in the (i - 1)-th row through the print type of the print content in the (i - 1)-th row, and combine the ordinate of the print content in the (i - 1)-th row and the line spacing to determine the ordinate of the print content in the i-th row, realizing the automatic calculation of the ordinate of the print content, without the need for developers to manually calculate the ordinate of each row of print content, improving the development efficiency.

[0071] In addition, when using TSPL for label printing development, if the print content exceeds the label height, if not processed, it will cause text / barcodes to be truncated, resulting in the loss of key information, such as missing order numbers, incomplete barcodes, etc., and further leading to invalid printing and wasting label paper resources. To solve this problem, this application can also combine the height of the print content and the height of the print label paper to determine whether the print content overflows the print label paper and when to trigger a page change operation, that is, let the printer advance to the starting position of the next label.

[0072] In this embodiment, optionally, after determining the ordinate of the printing content in the i-th row, the method further includes: determining whether the printing content in the i-th row meets the content overflow condition according to the ordinate of the printing content in the i-th row, the height of the printing content in the i-th row, and the height of the printing label paper in the configuration data; if the content overflow condition is met, generating and displaying candidate methods; the candidate methods include paging printing or compressing the line spacing for printing; in response to the target method selected from the candidate methods, adjusting the ordinate of the printing content in the i-th row.

[0073] Among them, the content overflow condition is that the sum of the ordinate of the printing content in the i-th row and the height of the printing content is greater than the height of the printing label paper. If the sum of the ordinate of the printing content in the i-th row and the height of the printing content is greater than the height of the printing label paper, it is determined that the printing content in the i-th row meets the content overflow condition. At this time, candidate methods can be generated and displayed. The candidate methods include paging printing or compressing the line spacing for printing, to prompt the user that the printing content overflows the printing label paper. The user can select the most suitable processing method according to the specific actual situation to adjust the ordinate of the printing content, which increases flexibility. For example, if the content slightly exceeds, compressing the line spacing may be more appropriate than splitting into two pages, saving label paper. Paging printing is suitable for cases where there is more content to ensure readability.

[0074] This application can avoid truncation of the printing content by automatically detecting whether the printing content overflows, ensuring the integrity of information. It also provides candidate methods for the user to process the printing content, increasing flexibility and improving the user experience. And after this application responds to the target method selected by the user from the candidate methods, it can automatically adjust the ordinate, improving the printing efficiency and reducing the time and errors of manual adjustment.

[0075] Step S270: Print the printing content in the i-th row using the abscissa and the ordinate of the printing content in the i-th row.

[0076] In an embodiment of the present invention, by obtaining configuration data of a printed label paper, the configuration data at least includes a line spacing; determining the width of the printed content in the i-th row according to the print type of the printed content in the i-th row, and determining the abscissa of the printed content in the i-th row in combination with the width of the printed label paper in the configuration data; determining the height of the printed content in the (i - 1)-th row according to the print type of the printed content in the (i - 1)-th row, and determining the ordinate of the printed content in the i-th row in combination with the ordinate of the printed content in the (i - 1)-th row and the line spacing; printing the printed content in the i-th row using the abscissa and the ordinate of the printed content in the i-th row. Through automated layout management, based on the ordinate and line height of the previous instruction, combined with the line spacing, the ordinate of the subsequent instruction is automatically calculated, solving the problems of complex instruction positioning, low development efficiency, and cumbersome calibration process during the development of label printing using TSPL instructions, realizing the automatic calculation of the coordinate positions of each instruction in the content, realizing the automatic layout of the printing positions of the instructions, and thus improving the development efficiency and printing accuracy.

[0077] In this embodiment, a label printing development framework is further provided, which mainly includes the following core modules: TsplLinearLayout (linear layout management), BaseTsplLayout (layout base class), TsplCmdText (text instruction generation), TsplCmdBarcode (barcode instruction generation), and TsplCmdQRcode (QR code instruction generation).

[0078] Among them, TsplLinearLayout (linear layout management module): responsible for managing the linear layout of TSPL instructions, realizing the automatic arrangement of printing elements from top to bottom, and completing the dynamic calculation method of the XY positions of line elements. BaseTsplLayout (layout base class module): as an abstract base class, defining the common layout attributes and methods of all TSPL instructions. TsplCmdText (text instruction module) function: generating TSPL instructions for single-line or multi-line text, and automatically calculating its XY positions according to the content length in combination with the label paper size. TsplCmdBarcode (barcode instruction module) function: generating barcode instructions, and automatically calculating its XY positions according to the size of the barcode configuration. TsplCmdQRcode (QR code instruction module) function: generating QR code instructions, and automatically calculating its XY positions according to the size of the QR code configuration.

[0079] These modules together implement an efficient label printing development framework. The core logic is to integrate instructions through TsplLinearLayout, realize the automatic calculation of the XY position information of each instruction in the content, realize the automatic layout of the printing positions of the instructions, and thus improve the development efficiency and printing accuracy.

[0080] Embodiment 3

[0081] Figure 4 The figure is a schematic structural diagram of a label printing device provided in Embodiment 3 of the present invention. This device can be implemented in a hardware and / or software manner, and can execute a label printing method provided in any embodiment of the present invention, and has corresponding functional modules and beneficial effects for executing the method. As Figure 4 shown, the device includes:

[0082] A configuration data acquisition module 310, configured to acquire configuration data of a printed label paper, where the configuration data at least includes a line spacing;

[0083] An abscissa determination module 320, configured to determine the abscissa of the i-th line of printed content according to the alignment mode of the i-th line of printed content and the attribute data of the i-th line of printed content;

[0084] An ordinate determination module 330, configured to determine the ordinate of the i-th line of printed content according to the ordinate of the (i - 1)-th line of printed content, the attribute data of the (i - 1)-th line of printed content, and the line spacing;

[0085] A printing module 340, configured to print the i-th line of printed content by using the abscissa and the ordinate of the i-th line of printed content.

[0086] In the embodiment of the present invention, by acquiring configuration data of a printed label paper, where the configuration data at least includes a line spacing; determining the abscissa of the i-th line of printed content according to the alignment mode of the i-th line of printed content and the attribute data of the i-th line of printed content; determining the ordinate of the i-th line of printed content according to the ordinate of the (i - 1)-th line of printed content, the attribute data of the (i - 1)-th line of printed content, and the line spacing; and printing the i-th line of printed content by using the abscissa and the ordinate of the i-th line of printed content. Through automatic layout management, based on the ordinate and line height of the previous instruction, combined with the line spacing, the ordinate of the subsequent instruction is automatically calculated, which solves the problems of complex instruction positioning, low development efficiency, and cumbersome calibration process in the process of using TSPL instructions for label printing development, realizes the automatic calculation of the coordinate position of each instruction in the content, and realizes the automatic layout of the printing position of the instructions, thereby improving the development efficiency and printing accuracy.

[0087] Based on the above technical solutions, optionally, the ordinate determination module 330 includes:

[0088] A printed content height acquisition unit, configured to, if the (i - 1)-th line of printed content is a text type, determine the height of the (i - 1)-th line of printed content according to the font type, font size, and number of characters; if the (i - 1)-th line of printed content is an image coding type, determine the height of the (i - 1)-th line of printed content according to the size of the image coding;

[0089] The vertical coordinate determination unit is configured to sum the vertical coordinate of the printing content in the (i - 1)-th row, the height of the printing content in the (i - 1)-th row, and the line spacing to obtain the vertical coordinate of the printing content in the i-th row.

[0090] Based on the above technical solutions, optionally, the vertical coordinate determination unit is specifically configured to:

[0091] Determine whether the printing content in the i-th row satisfies the content overflow condition according to the vertical coordinate of the printing content in the i-th row, the height of the printing content in the i-th row, and the height of the printing label paper in the configuration data; if the content overflow condition is satisfied, generate and display candidate methods; the candidate methods include paged printing or compressed line spacing printing; in response to the target method selected from the candidate methods, adjust the vertical coordinate of the printing content in the i-th row.

[0092] Based on the above technical solutions, optionally, the apparatus further includes:

[0093] The top margin determination module is configured to determine the vertical coordinate of the first row of printing content according to the top margin in the configuration data; wherein, when the alignment method of the page to be printed is vertical center alignment, the top margin is determined according to the difference between the total height of the printing content and the height of the printing label paper.

[0094] Based on the above technical solutions, optionally, the abscissa determination module 320 includes:

[0095] The printing content width acquisition unit is configured to, if the alignment method of the printing content in the i-th row is center alignment or right alignment, determine the width of the printing content in the i-th row according to the attribute data of the printing content in the i-th row;

[0096] The abscissa determination unit is configured to determine the abscissa of the printing content in the i-th row according to the width of the printing label paper in the configuration data and the width of the printing content in the i-th row.

[0097] Based on the above technical solutions, optionally, the printing content width acquisition unit is specifically configured to:

[0098] If the printing content in the i-th row is text-based, determine the width of the printing content in the i-th row according to the font type, font size, and number of characters; if the printing content in the i-th row is image-encoded, determine the width of the printing content in the i-th row according to the size of the image encoding.

[0099] Embodiment IV

[0100] Figure 5 The structural schematic diagram of an electronic device provided in Embodiment IV of the present invention is as Figure 5As shown in the figure, the electronic device includes a processor 40, a memory 41, an input device 42, and an output device 43. The number of processors 40 in the electronic device can be one or more. Figure 5 Taking one processor 40 as an example; the processor 40, memory 41, input device 42, and output device 43 in the electronic device can be connected through a bus or other means. Figure 5 Taking connection through a bus as an example.

[0101] The memory 41, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as the program instructions / modules corresponding to the label printing method in the embodiments of the present invention. The processor 40 executes various functional applications and data processing of the electronic device by running the software programs, instructions, and modules stored in the memory 41, that is, implementing the above-mentioned label printing method.

[0102] The memory 41 mainly includes a program storage area and a data storage area. Among them, the program storage area can store an operating system and application programs required for at least one function; the data storage area can store data created according to the use of the terminal, etc. In addition, the memory 41 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some instances, the memory 41 can further include a memory remotely set relative to the processor 40, and these remote memories can be connected to the electronic device through a network. Examples of the above network include but are not limited to the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.

[0103] Embodiment 5

[0104] Embodiment 5 of the present invention further provides a storage medium containing computer-executable instructions, and the computer-executable instructions are used to execute a label printing method when executed by a computer processor. The method includes:

[0105] Obtain configuration data of the printing label paper, and the configuration data at least includes line spacing;

[0106] Determine the abscissa of the printing content of the i-th row according to the alignment method of the printing content of the i-th row and the attribute data of the printing content of the i-th row;

[0107] Determine the ordinate of the printing content of the i-th row according to the ordinate of the printing content of the (i - 1)-th row, the attribute data of the printing content of the (i - 1)-th row, and the line spacing;

[0108] Print the printing content of the i-th row using the abscissa and the ordinate of the printing content of the i-th row.

[0109] Of course, for a storage medium containing computer-executable instructions provided by an embodiment of the present invention, the computer-executable instructions are not limited to the method operations described above, and can also execute relevant operations in the contract signing method provided by any embodiment of the present invention.

[0110] From the above description of the embodiments, those skilled in the art can clearly understand that the present invention can be implemented by means of software and necessary general-purpose hardware. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as a floppy disk, a read-only memory (ROM), a random access memory (RAM), a flash memory (FLASH), a hard disk, or an optical disc of a computer, etc., including several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in various embodiments of the present invention.

[0111] It should be noted that in the embodiments of the above contract signing device, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific names of the functional units are only for the convenience of mutual distinction and do not limit the protection scope of the present invention.

[0112] Note that the above is only the preferred embodiment of the present invention and the technical principles applied. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, re-adjustments, and substitutions can be made by those skilled in the art without departing from the protection scope of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments. Without departing from the concept of the present invention, more other equivalent embodiments can be included, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A label printing method, characterized in that, Including: Obtain configuration data of the printing label paper, where the configuration data at least includes line spacing; Determine the abscissa of the printing content in the i-th row according to the alignment mode of the printing content in the i-th row and the attribute data of the printing content in the i-th row; Determine the ordinate of the printing content in the i-th row according to the ordinate of the printing content in the (i - 1)-th row, the attribute data of the printing content in the (i - 1)-th row, and the line spacing; Print the printing content in the i-th row using the abscissa and the ordinate of the printing content in the i-th row.

2. The method according to claim 1, characterized in that The determining the ordinate of the printing content in the i-th row according to the ordinate of the printing content in the (i - 1)-th row, the attribute data of the printing content in the (i - 1)-th row, and the line spacing includes: If the printing content in the (i - 1)-th row is a text type, determine the height of the printing content in the (i - 1)-th row according to the font type, font size, and number of characters; If the printing content in the (i - 1)-th row is an image encoding type, determine the height of the printing content in the (i - 1)-th row according to the size of the image encoding; Sum the ordinate of the printing content in the (i - 1)-th row, the height of the printing content in the (i - 1)-th row, and the line spacing to obtain the ordinate of the printing content in the i-th row.

3. The method according to claim 2, wherein After determining the ordinate of the printing content in the i-th row, it further includes: Determine whether the printing content in the i-th row meets the content overflow condition according to the ordinate of the printing content in the i-th row, the height of the printing content in the i-th row, and the height of the printing label paper in the configuration data; If the content overflow condition is met, generate and display candidate methods; the candidate methods include paging printing or compressing line spacing printing; In response to the target method selected from the candidate methods, adjust the ordinate of the printing content in the i-th row.

4. The method according to claim 1, wherein The method further includes: Determine the ordinate of the first row of printing content according to the top margin in the configuration data; Wherein, when the alignment mode of the page to be printed is vertical center alignment, the top margin is determined according to the difference between the total height of the printing content and the height of the printing label paper.

5. The method according to claim 1, wherein The determining the abscissa of the printing content in the i-th row according to the alignment mode of the printing content in the i-th row and the attribute data of the printing content in the i-th row includes: If the alignment mode of the printing content in the i-th row is center alignment or right alignment, determine the width of the printing content in the i-th row according to the attribute data of the printing content in the i-th row; Determine the abscissa of the printing content in the i-th row according to the width of the printing label paper in the configuration data and the width of the printing content in the i-th row.

6. The method according to claim 5, where the determining the width of the printing content in the i-th row according to the attribute data of the printing content in the i-th row includes: If the printing content in the i-th row is a text type, determine the width of the printing content in the i-th row according to the font type, font size, and number of characters; If the printing content in the i-th row is an image encoding type, determine the width of the printing content in the i-th row according to the size of the image encoding.

7. A label printing device, characterized in that, Including: A configuration data acquisition module, configured to acquire configuration data of the printing label paper, where the configuration data at least includes line spacing; An abscissa determination module, configured to determine the abscissa of the printing content in the i-th row according to the alignment method of the printing content in the i-th row and the attribute data of the printing content in the i-th row; An ordinate determination module, configured to determine the ordinate of the printing content in the i-th row according to the ordinate of the printing content in the (i - 1)-th row, the attribute data of the printing content in the (i - 1)-th row, and the line spacing; A printing module, configured to print the printing content in the i-th row by using the abscissa and the ordinate of the printing content in the i-th row.

8. The device according to claim 7, characterized in that, The ordinate determination module includes: A printing content height acquisition unit, configured to, if the printing content in the (i - 1)-th row is a text type, determine the height of the printing content in the (i - 1)-th row according to the font type, font size, and number of characters; if the printing content in the (i - 1)-th row is an image coding type, determine the height of the printing content in the (i - 1)-th row according to the size of the image coding; An ordinate determination unit, configured to sum the ordinate of the printing content in the (i - 1)-th row, the height of the printing content in the (i - 1)-th row, and the line spacing to obtain the ordinate of the printing content in the i-th row.

9. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the label printing method according to any one of claims 1-6.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for implementing the label printing method according to any one of claims 1-6 when executed by a processor.