Print data generation device, print data generation method, data generation device for generating print data, and data generation method for generating print data
By using a template-based method with specified repetition ranges and field data, print data generation systems efficiently handle variable numbers of elements, simplifying code and enhancing readability.
Patent Information
- Application Number
- JP2023218981
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2023-12-26
- Publication Date
- 2025-07-08
AI Technical Summary
Existing print data generation systems require repetitive code structures for generating print data with a variable number of elements, leading to non-intuitive and difficult-to-understand program code.
Generate print data using a template and field data, where the template includes generation commands in the smallest unit without repetitions, and specify a repetition range based on the variable number of print elements, replacing insertion fields with print element data to create print data with a variable number of elements.
This approach allows for the generation of print data with a variable number of elements without the need for repetitive code in the application, improving code readability and simplifying the process of insert printing.
Smart Images

Figure 2025101894000001_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a print data generation device, a print data generation method, a data generation device for print data generation, and a data generation method for print data generation. In particular, it is suitable for use in a device and method for generating print data for insert printing, and a device and method for generating data for print data generation for generating the print data.
Background Art
[0002] Conventionally, in a system that transmits receipt print data from a POS terminal to a printer to execute printing, there is known a configuration in which print data including commands such as character decoration and paper cutting is transmitted in addition to a print instruction (for example, see Patent Document 1). FIG. 4 of Patent Document 1 shows print data including a plurality of character string print-related command groups composed of a combination of a character string print instruction command including a dedicated instruction code and string information and a character string decoration command. For each character string print-related command group, the printer converts each character code included in the character string print instruction command into each corresponding font data, and then performs decoration specified by the character string decoration command to execute printing.
[0003] When generating print data including a plurality of commands corresponding to a print element with a variable number of elements (for example, the item part of a receipt) as shown in FIG. 4 of Patent Document 1, on the application side that generates the print data, the number of elements is obtained from field data in which information of the character string to be printed is recorded, and the generation of commands is repeatedly executed by that number of elements to generate print data.
[0004] However, when repeatedly executing the generation of commands a plurality of times, in the program code of the application that generates the print data, it is necessary to incorporate descriptions such as loops and conditional branches, resulting in a problem that the code becomes non-intuitive and difficult to understand.
Prior Art Documents
Patent Documents
[0005] [Patent Document 1] Japanese Patent No. 7006096 [Summary of the Invention] [Problems to be Solved by the Invention]
[0006] The present invention has been made to solve such problems, and without incorporating descriptions necessary for repeatedly generating commands in the program code of an application that generates print data, it is an object of the present invention to be able to generate print data with a variable number of print elements and execute insert printing. [Means for Solving the Problems]
[0007] In order to solve the above-described problems, in the present invention, print data including a plurality of print-related commands is generated using a template and field data including data of print elements to be inserted into the insertion fields of the template. The template includes one or more generation commands for generating print-related commands, and the one or more generation commands are composed of commands in the smallest unit that do not include repetitions according to the variable number of print elements. Then, based on the contents of both the template and the field data or the contents of the template, the range of the generation commands for repeatedly executing the process a number of times according to the variable number of print elements is specified from within the template, and including the replacement of repetitions within the specified range, the insertion fields included in the generation commands are replaced with the data of the print elements, and print data including print-related commands into which the data of the print elements is inserted is generated using a plurality of generation commands including the replaced generation commands. [Effects of the Invention]
[0008] According to the present invention configured as described above, based on a template in which one or more generation commands are composed of commands in the smallest unit without repetition, including the generation commands in a state where the insertion fields are replaced with the data of the print elements, print data is generated which is described so that the generation commands are repeatedly executed the number of times corresponding to the variable number of print elements. Thereby, it is possible to generate print data with a variable number of print elements and execute insert printing without incorporating the description necessary for repeatedly generating commands in the program code of the application for generating the print data.
Brief Description of the Drawings
[0009]
Figure 1
Figure 2
Figure 3
Figure 4
Figure 5
Figure 6
Figure 7
Figure 8
Figure 9
Figure 10A
Figure 10B
Figure 11
Figure 12
Figure 13
Figure 14A
Figure 14B
Figure 15
Figure 16A
Figure 16B
Figure 16C
Figure 17
Figure 18
Figure 19A
Figure 19B
Figure 19C
Figure 19D
Figure 19E
Figure 19F
Figure 19G
Figure 19H
Figure 20
MODE FOR CARRYING OUT THE INVENTION
[0010] Hereinafter, an embodiment of the present invention will be described with reference to the drawings. FIG. 1 is a diagram showing an overall schematic configuration example of the printing system of the present embodiment. As shown in FIG. 1, the printing system according to the present embodiment includes a host device 10 and a printer 20. In the configuration shown in FIG. 1, the host device 10 includes a printing data generation device and a data generation device for printing data generation of the present embodiment. In the present embodiment, as an example of the data for printing data generation, a printing data generation API including a plurality of API call commands is used. The API call command is an example of the "generation command" described in the claims.
[0011] Between the host device 10 and the printer 20, for example, they are connected by a wired interface cable such as a serial cable, Ethernet (registered trademark) or USB (Universal Serial Bus). Alternatively, the host device 10 and the printer 20 may be connected via a wireless communication network such as Bluetooth (registered trademark) or Wi-Fi (registered trademark), wireless LAN. Alternatively, the host device 10 and the printer 20 may be connected via a communication network such as the Internet.
[0012] FIG. 2 is a diagram showing an example of the hardware configuration of the printing system according to the present embodiment. As shown in FIG. 2, the host device 10 includes a control unit 101, a storage unit 102, an input unit 103, a display unit 104, and an I / F 105 as hardware components. Further, the printer 20 includes a control unit 201, a storage unit 202, an I / F 203, and a printing unit 204 as hardware components.
[0013] The control unit 101 of the host device 10 is configured by a microcomputer including, for example, a CPU, a RAM, and a ROM, operates according to the operating system and other programs stored in the storage unit 102, and executes information processing using various data stored in the storage unit 102. In addition to the microcomputer, a DSP (Digital Signal Processor) or the like may be provided.
[0014] The storage unit 102 is configured by a computer-readable storage medium. For example, the storage unit 102 includes a ROM, a RAM, a hard disk, or a semiconductor memory. Various programs executed by the control unit 101 are stored in the storage unit 102. Among the various programs, there are an application program for generating field data to be inserted into the insertion field when executing the insert printing, a print data generation program for generating print data using the field data, and the like. The field data includes data of one or more print elements, and is variable data indicating how many print elements are included (the number of print elements, that is, the number of elements of the insert printing).
[0015] In addition, the storage unit 102 stores various types of data including data used in the processing of the control unit 101 and data generated during the processing. Among the various types of data, there are templates and field data used when generating print data, print data generation APIs (also referred to as replaced templates) generated by inserting field data into insertion fields included in the templates, and command-based print data generated by executing the print data generation APIs. Details of the templates and field data will be described later.
[0016] The input unit 103 is composed of, for example, a keyboard, a mouse, or a touch panel, etc., and inputs data corresponding to a user's operation input to the control unit 101. The display unit 104 is composed of, for example, a liquid crystal display, etc., and displays information according to an instruction input from the control unit 101. The I / F 105 is composed of a communication module that exchanges data with the printer 20, and outputs various types of data to the printer 20 according to an instruction input from the control unit 101.
[0017] In this embodiment, the data to be printed generated by the application program in the storage unit 102 based on the control of the control unit 101 is converted into command-based print data that can be understood by the printer 20, and the converted print data is output from the I / F 105 to the printer 20. When executing insert printing, the control unit 101 generates print data including a plurality of print-related commands using the template and the field data. As an example, receipt print data including the name and price of purchased items as print elements with a variable number of elements is generated by the host device 10, and a receipt is printed by the printer 20 based on this print data.
[0018] The control unit 201 of the printer 20 is composed of a microcomputer including, for example, a CPU, a RAM, and a ROM, and performs overall control of the printer 20 according to a program stored in the storage unit 202. In addition to the microcomputer, a DSP or the like may be provided. The storage unit 202 includes a ROM, a RAM, a semiconductor memory, or the like, and stores various programs and data necessary for printing execution.
[0019] The I / F 203 is composed of a communication module that exchanges data with the host device 10, receives print data transmitted from the host device 10, and outputs it to the control unit 201. The printing unit 204 executes printing according to a print-related command indicated by the print data sent from the host device 10 under the control of the control unit 201, thereby forming an image based on the print data on a recording medium such as printing paper.
[0020] FIG. 3 is a block diagram showing a functional configuration example of the host device 10. As shown in FIG. 3, the host device 10 of the present embodiment includes a print API generation unit 11, a print data generation unit 12, a field data generation unit 13, a template storage unit 14, and a field data storage unit 15. The processes of the print API generation unit 11, the print data generation unit 12, and the field data generation unit 13 are executed by programs stored in the control unit 101 and the storage unit 102 of FIG. 2. The template storage unit 14 and the field data storage unit 15 are configured by the storage unit 102 of FIG. 2.
[0021] The field data generation unit 13 generates field data including data of print elements to be inserted into the insertion fields of the template stored in the template storage unit 14 by the operation of the application program stored in the storage unit 102. The field data generated by the field data generation unit 13 is stored in the field data storage unit 15.
[0022] The printing element consists of a combination of an item name and an insertion value (such as a character string, a numeric string, or a combination thereof) into an insertion field. As shown in Fig. 4(a), the printing elements include a printing element (hereinafter referred to as an array element) in which one or more insertion values are arranged and printed on the printing paper, and a printing element (hereinafter referred to as a single element) in which only one insertion value is arranged and printed on the printing paper. The number of elements (the number of insertion values) of the array element is variable. On the other hand, the number of elements of the single element is always single and fixed. For example, when printing a receipt, the name and price of purchased items are examples of array elements, and the store name and purchase date and time are examples of single elements.
[0023] The template storage unit 14 stores a template used when generating print data using the field data. The template includes a plurality of API call commands for generating print-related commands. The print-related commands include a command for instructing printing (hereinafter referred to as a print instruction command) and a command for instructing decoration (hereinafter referred to as a decoration instruction command).
[0024] The API call command is a command for instructing the call of an API library configured to generate print-related commands. As shown in Fig. 4(b), the API call commands include a command for calling a library for generating a print instruction command (hereinafter referred to as a print instruction API call command) and a command for calling a library for generating a decoration instruction command (hereinafter referred to as a decoration instruction API call command).
[0025] The print instruction API call commands include those containing a replacement rule for inserting a printing element into an insertion field and those not containing a replacement rule. For the print instruction API call commands containing a replacement rule, there are cases where the data of the array element is inserted into the insertion field according to the replacement rule and cases where the data of the single element is inserted into the insertion field. On the other hand, the decoration instruction API call commands do not contain a replacement rule.
[0026] FIG. 5 is a diagram for explaining an example of template replacement. As shown in FIG. 5, in the present embodiment, a portion starting with the symbol ${ and ending with the symbol} is set as an insertion field, and the string of the insertion field is replaced with an insertion value of a print element obtained from field data using the string inside the ${} as a key. That is, the following replacement rule is adopted. FIG. 5 shows an example of replacing the insertion field of a print instruction API call command with data of a single element.
[0027] The plurality of API call commands included in the template are composed of a group of commands of the minimum unit that does not include a number of repetitions corresponding to the variable number of print elements. The group of commands of the minimum unit that does not include a repetition means that, for a print instruction API call command including a replacement rule, even when inserting a plurality of insertion values repeatedly with array elements, the API call commands are not included as many as the number of array elements.
[0028] The print API generation unit 11 corresponds to the data generation unit for generating print data in the claims. Based on both the contents of the template and the field data or the content of the template, from among the plurality of API call commands included in the template, a range of API call commands (which may be abbreviated as "repetition range" in the following description) that repeatedly execute processing a number of times corresponding to the variable number of print elements is specified, and by replacing the insertion fields included in the API call commands with data of print elements including the repeated replacement within the specified range, a print data generation API (replaced template) including a plurality of API call commands is generated. The plurality of API call commands include a print instruction API call command (corresponding to the replaced generation command described in the claims) in which the insertion field is replaced with data of a print element, a print instruction API call command without an insertion field, and a decoration instruction API call command.
[0029] The print data generation unit 12 generates print data including print-related commands with print element data inserted therein by executing the print data generation API generated by the print API generation unit 11. That is, the print data generation unit 12 calls an API library configured to generate print-related commands according to a plurality of API call commands included in the print data generation API, and executes the processes defined in the API library to generate print data including a plurality of print-related commands. Then, the generated print data is output to the printer 20.
[0030] Three embodiments regarding the processing of the print API generation unit 11 will be described below. The first embodiment specifies the range of repetition of API call commands based on the content of the template. The second and third embodiments specify the range of repetition of API call commands based on the content of both the template and the field data.
[0031] (First Embodiment) In the first embodiment, the template has a hierarchical structure of a plurality of API call commands and includes a repeat start flag at any hierarchy. The print API generation unit 11 specifies the range of repetition based on the repeat start flag and the hierarchical structure. The hierarchical structure is generally used to specify the range to which character decoration is applied in the print data generation API. That is, in the print data generation API, the character decoration specified by the decoration instruction API call command at a certain hierarchy is applied to that hierarchy and the hierarchies below it, while it is not applied to the hierarchies above it. In the first embodiment, this mechanism is utilized to specify the range of repetition.
[0032] FIG. 6 is a diagram for explaining the processing content of the print API generation unit 11 according to the first embodiment. In FIG. 6, the decoration instruction API call command is indicated by a dotted line frame, and the print instruction API call command is indicated by a solid line frame. Among the print instruction API call commands, those including a replacement rule are indicated by a thick solid line frame, and those not including a replacement rule are indicated by a thin solid line frame. The execution order of the API call commands is shown from the top to the bottom of the figure, and the fact that the hierarchy becomes deeper from the left to the right of the figure is shown. Note that "\n" included in the API call command means an instruction for line feed. The same applies to the figures listed below.
[0033] FIG. 6(a) shows an example of a template and field data having a hierarchical structure, and the repeating range RR specified by the print API generation unit 11 is shown by a rectangular frame in the template. The template includes a hierarchical control function. In the figure, the symbol "↓" means lowering the hierarchy, and the symbol "↑" means raising the hierarchy. The repeating range RR also includes a hierarchical control function. FIG. 6(b) shows an example of a print data generation API (replaced template) generated by replacing the insertion fields included in the API call command with the data of the print elements included in the field data, including the repetition replacement in the specified range. In the present embodiment, an example in which the field data is configured in the JSON format is shown, but it is not limited thereto. For example, the field data can be configured in any data format such as XML, CSV, and Flat file.
[0034] In the example of FIG. 6, the template is composed of three layers. From the beginning of the first layer, a decoration instruction API call command and a printing instruction API call command are each described. After a repeat start flag SF is described at the beginning of the subsequent second layer, a decoration instruction API call command and a printing instruction API call command are each described. Further, after entering the third layer and a decoration instruction API call command and a printing instruction API call command are each described, it returns to the first layer and a printing instruction API call command is described.
[0035] As shown in FIG. 6(a), the API generation unit 11 for printing specifies the API call commands included in the second layer including the repeat start flag SF and the third layer below it as the range of the API call command for executing repeat replacement (repeat range RR). That is, the decoration instruction API call command and the printing instruction API call command included in the second layer and the decoration instruction API call command and the printing instruction API call command included in the third layer are specified as the repeat range RR. The repeat range RR also includes the hierarchical control functions related to the API call commands specified as described above. The hierarchical control functions related to the specified API call commands mean the hierarchical control functions (in the example of FIG. 6(a), the four hierarchical control functions indicated by the symbols "↓" and "↑" in the first layer and the second layer) that control the transition to the layer (in the example of FIG. 6(a), the second layer and the third layer) in which the specified API call command is included or the transition from that layer.
[0036] Then, the printing API generation unit 11 generates a printing data generation API (replaced template) by replacing the insertion fields of a plurality of print instruction API call commands included in the template with the data (insertion values) of the printing elements included in the field data. At this time, as shown in FIG. 6(b), the printing API generation unit 11 copies the API call commands included in the specified repetition range RR and the hierarchical control functions related thereto so that the number thereof is the same as the number of array elements included in the field data, and repeatedly executes the process of replacing the insertion fields of the print instruction API call commands with the data of the array elements the number of times corresponding to the number of array elements. The number of array elements can be grasped by referring to the field data with the internal string enclosed in ${} as a key.
[0037] As shown in FIG. 6(a), the field data includes one single element SE and two array elements AE. In the example of FIG. 6(a), one single element SE is the store name, and the two array elements AE are the product name and the price. The number of elements (the number of insertion values) of both of the two array elements AE is two. When the field data is configured in this way, the printing API generation unit 11 copies a set of a plurality of API call commands included in the repetition range RR, and repeats the replacement process of the insertion values of the insertion fields for the print instruction API call commands twice. The printing data generation API generated as a result of this process is shown in FIG. 6(b).
[0038] That is, the insertion field "${store_name}" of the print instruction API call command in the first layer shown in FIG. 6(a) is replaced with the data "Star Store" of the single element SE included in the field data. The data "Star Store" of the single element SE used for this replacement is obtained from the field data using the internal string enclosed by ${} as the key (the same applies to the following API call commands). Further, the insertion field "${items.name}" of the print instruction API call command in the second layer included in the repetition range RR is replaced twice with the data "T shirt" and "Denim" of the array element AE included in the field data, and the insertion field "${items.price}" of the print instruction API call command in the third layer is replaced twice with the data "10.99" and "29.99" of the array element AE included in the field data.
[0039] Regarding the API call command including the replacement rule of the array element and the related decoration instruction API call command, it is necessary to repeatedly execute them for the number of array elements. However, in this embodiment, the print data generation API is generated by copying the API call commands as many as necessary. Therefore, in the calling source application (print data generation program), it is only necessary to execute the plurality of API call commands included in the generated print data generation API one by one in order from the top as shown in FIG. 6(b). As a result, there is no need to incorporate the description necessary for repeatedly calling the API call command into the program code of the calling source application. This also applies to the second and third embodiments described later.
[0040] FIG. 7 is a diagram showing a printing result when the printing data generated by the printing data generation unit 12 based on the printing data generation API shown in FIG. 6(b) is output to the printer 20. As described above, as a result of the replacement process of the printing instruction API call commands of the second and third layers being repeatedly executed twice within the repetition range RR, "T shirt" and "Denim" are printed as the product names "name" of the second layer, and "10.99" and "29.99" are printed as the prices "price" of the third layer. Since the API call command of the second layer does not include "\n", the "name" of the second layer and the "price" of the third layer are printed without line breaks.
[0041] In the example of the printing data generation API shown in FIG. 6(b), since the character decoration of "left alignment" is specified at the beginning of the first layer, all the character strings printed based on the printing instruction commands generated from the printing instruction API call commands described below the first layer are applied with the character decoration of "left alignment". Also, since the character decoration of "bold" is specified in the second layer, all the character strings printed based on the printing instruction commands generated from the printing instruction API call commands described below the second layer are applied with the character decoration of "bold". Also, since the character decoration of "underline" is specified in the third layer, the character decoration of "underline" is applied to the character string printed based on the printing instruction command generated from the printing instruction API call command described in the third layer.
[0042] (Second Embodiment) In the second embodiment, the template does not have a hierarchical structure and does not include the repeat start flag SF. The printing API generation unit 11 identifies the repeat range RR based on both the types of API call commands and the field data included in the template.
[0043] FIG. 8 is a diagram for explaining the processing content of the printing API generation unit 11 according to the second embodiment. For easy understanding of the explanation, ascending indexes IDX starting from "0" are assigned to the plurality of API call commands included in the template. i(i = 0, 1, 2, ···) is set.
[0044] FIG. 8(a) shows an example of a template and field data that do not have a hierarchical structure, and the repeated range RR specified by the print API generation unit 11 is shown as a rectangular frame in the template. Since there is no hierarchical structure for specifying the application range of character decoration, the template includes a decoration instruction API call command for canceling the application of character decoration in addition to the decoration instruction API call command for instructing the application of character decoration. The field data is the same as that shown in FIG. 6(a). FIG. 8(b) shows an example of a print data generation API (replaced template) generated by replacing the insertion fields included in the API call command with the data of the print elements included in the field data, including the replacement of the repetition within the specified range.
[0045] As shown in FIG. 8(a), the print API generation unit 11 determines, from the print instruction API call commands including the replacement rule by the repeated array elements among the plurality of print elements included in the field data, all the API call commands included up to immediately before the print instruction API call command that does not include the replacement rule by the array elements, and the decoration instruction API call commands existing before the print instruction API call command including the replacement rule by the array elements as the repeated range RR. Among the plurality of API call commands included in the template, which one is the print instruction API call command including the replacement rule by the array element AE can be determined by referring to the field data using the string of the insertion field of the print instruction API call command as a key.
[0046] In the template shown in Fig. 8(a), the API call commands with indexes IDX0 and IDX2 are decoration instruction API call commands that exist before the print instruction API call commands including the replacement rule by the array element AE. Therefore, these two are included in the repetition range RR. The API call command with index IDX1 is a print instruction API call command, but by referring to the field data using the string "store_name" of the insertion field as a key, it is determined that the print element corresponding to the string "store_name" is not the array element AE. Therefore, the API call command with index IDX1 is not included in the repetition range RR.
[0047] The API call command with index IDX3 is a print instruction API call command, and by referring to the field data using the string "items.name" of the insertion field as a key, it is determined that the print element corresponding to the string "items.name" is the array element AE. Therefore, the print API generation unit 11 determines that the API call command with index IDX3 is a print instruction API call command including the replacement rule by the array element AE, and starts searching for the repetition range RR starting from this position.
[0048] The API call commands with indexes IDX4, IDX5, and IDX7 after index IDX3 are decoration instruction API call commands. Also, the API call command with index IDX6 is a print instruction API call command, but by referring to the field data using the string "items.price" of the insertion field as a key, it is determined that the print element corresponding to the string "items.price" is the array element AE. Therefore, the print API generation unit 11 determines that the API call commands with indexes IDX4 to IDX7 are within the repetition range RR and none of them indicate the end position of the repetition range RR.
[0049] The API call command of index IDX8 is a printing instruction API call command, and the character string "Thank you" is not enclosed by the replacement rule "${}". Therefore, the printing API generation unit 11 determines that the API call command of index IDX8 is a printing instruction API call command that does not include the replacement rule by the array element AE, and specifies the API call command of index IDX7 immediately before this as the end position of the repetition range RR.
[0050] Then, the printing API generation unit 11 generates a print data generation API (replaced template) by replacing the insertion fields of a plurality of printing instruction API call commands included in the template with the data (insertion values) of the printing elements included in the field data. At this time, as shown in FIG. 8(b), the printing API generation unit 11 copies the API call commands included in the specified repetition range RR so that the number is the same as the number of array elements included in the field data, and repeats the process of replacing the insertion fields of the printing instruction API call commands with the data of the array elements the number of times corresponding to the number of array elements.
[0051] FIG. 9 is a diagram showing a printing result when the print data generated by the print data generation unit 12 based on the print data generation API shown in FIG. 8(b) is output to the printer 20. In the example of the print data generation API shown in FIG. 8(b), after canceling the "bold" character decoration for the product name "name", the "underline" character decoration for the price "price" is set. Therefore, the product name is printed only with the bold character decoration, and the price is printed only with the underline character decoration.
[0052] FIGS. 10A and 10B are flowcharts showing operation examples of the printing API generation unit 11 according to the second embodiment. FIG. 11 is a diagram showing an example of a replaced template in the generation process by the processing according to this flowchart. Hereinafter, the operation will be described with reference to FIGS. 10A, 10B, and 11.
[0053] First, the printing API generation unit 11 initializes the value of the repetition start index IDX S used as a parameter to "-1" (step S1). Next, the printing API generation unit 11 determines whether there is a next API call command in the template (step S2). If not, the processes in the flowcharts shown in FIGS. 10A and 10B are terminated.
[0054] When there is a next API call command, the printing API generation unit 11 acquires the next API call command from the template (step S3), and determines whether the value of the current repetition start index IDX S is "-1" (step S4). When the value of the repetition start index IDX S is "-1", the printing API generation unit 11 determines whether the API call command acquired in step S3 includes a replacement rule for array elements (step S5).
[0055] When the API call command does not include a replacement rule for array elements, the printing API generation unit 11 determines whether the API call command includes a replacement rule for a single element (step S6). When the API call command includes a replacement rule for a single element, the printing API generation unit 11 acquires the data of the single element specified by the replacement rule from the field data, and replaces the insertion field of the API call command with the acquired data of the single element (step S7). Then, the API call command is added to the replaced template (step S8).
[0056] On the other hand, if it is determined in step S6 that the API call command does not include a replacement rule for a single element, the process of step S7 is skipped, and the API call command acquired in step S3 is directly added to the replaced template (step S8). After the process of step S8, the process returns to step S2, and if there is a next API call command, it is acquired (step S3).
[0057] When the API call commands of indexes IDX0 and IDX2 shown in Fig. 8(a) are acquired in step S3, the process of step S7 is skipped, and the API call command is directly added to the replaced template (step S8). Also, when the API call command of index IDX1 shown in Fig. 8(a) is acquired in step S3, after replacing the insertion field of the API call command with the data of a single element specified by the replacement rule (step S7), the API call command is added to the replaced template (step S8). Up to this stage, the replaced template is configured as shown in Fig. 11(a).
[0058] In step S5 above, when it is determined that the API call command includes a replacement rule for array elements, the value of the repeat start index IDX S is updated with the value of the index IDX i of the current API call command (step S9). Then, the process returns to step S2. When the API call command of index IDX3 is acquired in step S3, since it is determined that the API call command includes a replacement rule for array elements, the value of the repeat start index IDX S is updated with index IDX3. This index IDX3 will indicate the search start position of the repeat range RR.
[0059] When the value of the repeat start index IDX S is updated, in step S4 after returning to step S2, it is determined that the value of the repeat start index IDX S is not "-1". In this case, the print API generation unit 11 determines whether the API call command acquired in step S3 is a print instruction command that does not include a replacement rule for array elements (step S10). Here, when it is determined that it is not a print instruction command that does not include a replacement rule for array elements, the process returns to step S2. When the API call commands of indexes IDX4 to IDX7 are acquired in step S3, the determination in step S10 is No.
[0060] On the one hand, in step S10, when it is determined that the printing instruction command does not include the replacement rule of array elements, the printing API generation unit 11 extracts the following repeated replacement target API call commands from the template (step S11). · The decoration instruction API call commands included from the beginning of the template to one before the repeated start index IDX S · All API call commands included from the repeated start index IDX S to one before the current index IDX i · All API call commands included from the repeated start index IDX S to one before the current index IDX i
[0061] In the example of FIG. 8(a), at the stage where the API call command of index IDX8 is obtained in step S3, it is determined that it is a printing instruction command that does not include the replacement rule of array elements. Therefore, the printing API generation unit 11 obtains the decoration instruction API call commands included in indexes IDX0 to IDX2 from the beginning of the template to one before the repeated start index IDX3, and all API call commands included in indexes IDX3 to IDX7 from the repeated start index IDX3 to one before the current index IDX8. The plurality of API call commands obtained here become the repeated range RR.
[0062] Next, the printing API generation unit 11 copies the plurality of API call commands obtained in step S11 so that the number is the same as the number of array elements included in the field data, and repeatedly executes the process of replacing the insertion field of the printing instruction API call command with the data of the array elements the number of times corresponding to the number of array elements. Then, the plurality of API call commands after execution are added to the replaced template (step S12). At this stage, the replaced template is configured as shown in FIG. 11(b).
[0063] Next, the print API generation unit 11 determines whether the API call command of the index IDX8 acquired in step S3 includes a single-element replacement rule (step S13). If the API call command includes a single-element replacement rule, the print API generation unit 11 acquires the data of the single element specified by the replacement rule from the field data, and replaces the insertion field of the API call command with the acquired single-element data (step S14). Then, the API call command is added to the replaced template (step S15).
[0064] On the other hand, if the API call command does not include a single-element replacement rule, the process of step S14 is skipped, and the API call command acquired in step S3 is directly added to the replaced template (step S15). By executing the process of step S15, the replaced template becomes the state shown in FIG. 8(b). After that, the print API generation unit 11 returns the value of the repeat start index IDX S to the initial value "-1" (step S16), and then returns to step S2. In the example of the template shown in FIG. 8(a), since there is no API call command after the index IDX8, the processes of the flowcharts shown in FIGS. 10A and 10B are terminated.
[0065] (Third Embodiment) In the third embodiment, the template has a hierarchical structure but does not include the repeat start flag SF. In the third embodiment, the repeat range RR is specified based on both the types of API call commands and field data included in the template and the hierarchical structure of the API call commands.
[0066] FIG. 12 is a diagram for explaining the processing content of the print API generation unit 11 according to the third embodiment. FIG. 12(a) shows an example of a template and field data having a hierarchical structure, and the repeated range RR specified by the print API generation unit 11 is shown as a rectangular frame in the template. The template includes a hierarchical control function. In the figure, the symbol "↓" means to lower the hierarchy, and the symbol "↑" means to raise the hierarchy. The repeated range RR also includes a hierarchical control function. The field data is the same as that shown in FIG. 6(a). FIG. 12(b) shows an example of a print data generation API (replaced template) generated by replacing the insertion fields included in the API call command with the data of the print elements included in the field data, including the repetition replacement in the specified range.
[0067] As shown in FIG. 12(a), the print API generation unit 11 specifies, as the repeated range RR, the highest hierarchy among the hierarchies including the print instruction API call command including the replacement rule by the repeated array elements among the plurality of print elements included in the field data and the API call commands included in the hierarchies below that. The repeated range RR also includes a hierarchical control function related to the API call command specified as described above. In the example of FIG. 12(a), as the related hierarchical control function, the hierarchical control function (the four hierarchical control functions indicated by the symbols "↓" and "↑" in the first and second hierarchies) that controls the transition to and from the second and third hierarchies in which the specified API call command is included is included in the repeated range RR. Among the plurality of API call commands included in the template, which one is the print instruction API call command including the replacement rule by the array element AE can be determined by referring to the field data using the character string of the insertion field of the print instruction API call command as a key.
[0068] In the template shown in FIG. 12(a), there is no print instruction API call command including a replacement rule by the array element AE in the first layer, and there are print instruction API call commands including a replacement rule by the array element AE in the second and third layers. Therefore, the print API generation unit 11 specifies, as the repetition range RR, the decoration instruction API call command and the print instruction API call command including the replacement rule of the array element among the API call commands included in the second layer and below, and the hierarchical control function related thereto. In the example shown in FIG. 12(a), since there is no print instruction API call command including a replacement rule by a single element SE in the second layer and below, all the API call commands in the second layer and below are included in the repetition range RR.
[0069] Then, the print API generation unit 11 generates a print data generation API (replaced template) by replacing the insertion fields of a plurality of print instruction API call commands included in the template with the data (insertion value) of the print elements included in the field data. At this time, as shown in FIG. 12(b), the print API generation unit 11 copies the API call commands included in the specified repetition range RR and the hierarchical control function related thereto so that the number is the same as the number of array elements included in the field data, and repeatedly executes the process of replacing the insertion fields of the print instruction API call commands with the data of the array elements the number of times corresponding to the number of array elements.
[0070] FIG. 13 is a diagram showing a print result when the print data generated by the print data generation unit 12 based on the print data generation API shown in FIG. 12(b) is output to the printer 20. In the example of the print data generation API shown in FIG. 12(b), since character decoration of "bold" for the product name "name" is specified in the third layer and then character decoration of "underline" for the price "price" is specified in the second layer, the product name is printed only with bold character decoration, and the price is printed only with underline character decoration.
[0071] FIG. 14A and FIG. 14B are flowcharts showing operation examples of the print API generation unit 11 according to the third embodiment. In this flowchart, a range search flag RF indicating whether or not a repetition range RR is being searched and a top-level variable AP indicating the top level of the repetition range RR are used as parameters. FIG. 15 is a diagram showing an example of a template after replacement in the generation process by the processing according to this flowchart. Hereinafter, the operation will be described with reference to FIGS. 14A, 14B, and 15. In FIG. 15, symbols "↑" and "↓" indicating a hierarchical control function are omitted from the illustration.
[0072] First, the print API generation unit 11 initializes the value of the range search flag RF to "No" (step S21). Next, the print API generation unit 11 determines whether or not the next API call command exists in the template (step S22). If not, the processing of the flowchart shown in FIGS. 14A and 14B ends.
[0073] If the next API call command exists, the print API generation unit 11 acquires the next API call command from the template (step S23), and determines whether or not the value of the current range search flag RF is "No" (step S24). If the value of the range search flag RF is "No", the print API generation unit 11 determines whether or not the API call command acquired in step S23 includes an array element replacement rule (step S25).
[0074] When the API call command does not include the replacement rule for array elements, the print API generation unit 11 determines whether the API call command includes the replacement rule for a single element (step S26). When the API call command includes the replacement rule for a single element, the print API generation unit 11 acquires the data of the single element specified by the replacement rule from the field data, and replaces the insertion field of the API call command with the acquired data of the single element (step S27). Then, the API call command is added to the replaced template (step S28). At this time, if there is a hierarchical control function related to the API call command, it is also added to the replaced template.
[0075] On the other hand, when it is determined in step S26 that the API call command does not include the replacement rule for a single element, the process of step S27 is skipped, and the API call command acquired in step S23 is directly added to the replaced template (step S28). At this time, if there is a hierarchical control function related to the API call command, it is also added to the replaced template. After the process of step S28, the process returns to step S22, and if there is a next API call command, it is acquired (step S23).
[0076] At the stage where the API call commands of indexes IDX0 and IDX2 shown in FIG. 12(a) are acquired in step S23, the process of step S27 is skipped, and the API call command is directly added to the replaced template (step S28). At this time, the hierarchical control function related to the API call command of index IDX2 is also added to the replaced template. Also, at the stage where the API call command of index IDX1 shown in FIG. 12(a) is acquired in step S23, after replacing the insertion field of the API call command with the data of the single element specified by the replacement rule (step S27), the API call command is added to the replaced template (step S28). Up to this stage, the replaced template is configured as shown in FIG. 15(a).
[0077] In the above step S25, when it is determined that the API call command includes the replacement rule of the array element, the value of the range search flag RF is updated to "Yes", and the top-level variable AP is set to the value of the hierarchy of the current API call command (step S29). Then, the process returns to step S22. When the API call command of the index IDX3 is obtained in step S23, since it is determined that the API call command includes the replacement rule of the array element, the value of the range search flag RF is updated to "Yes", and the value "3" indicating the third layer is set as the value of the top-level variable AP.
[0078] When the value of the range search flag RF is updated to "Yes", in step S24 after returning to step S22, it is determined that the value of the range search flag RF is not "No". In this case, the print API generation unit 11 determines whether the API call command obtained in step S23 is a print instruction command (step S30). Here, when it is determined that it is not a print instruction command, the print API generation unit 11 directly adds the API call command obtained in step S23 to the replaced template (step S31). At this time, if there is a hierarchical control function related to the API call command, it is also added to the replaced template. Until the API call command of the index IDX4 is obtained, the replaced template is configured as shown in FIG. 15(b). At this time, the hierarchical control function related to the API call command of the index IDX4 is also added to the replaced template.
[0079] After that, the printing API generation unit 11 determines whether the value of the current layer is smaller than the value of the top layer variable AP (step S32). If it is smaller, the value of the top layer variable AP is updated with the value of the current layer (step S33). After that, the process returns to step S22. On the other hand, if the value of the current layer is not smaller than the value of the top layer variable AP, the process of step S33 is skipped and the process returns to step S22. When the API call command of index IDX4 is acquired in step S23, the process of step S33 is executed and the value of the top layer variable AP is updated to the value "2" of the current layer.
[0080] In step S30 above, when it is determined that the API call command acquired in step S23 is a printing instruction command, the printing API generation unit 11 continues to determine whether the printing instruction API call command includes an array element replacement rule (step S34). Here, if it is determined that the array element replacement rule is included, the process proceeds to step S32. When the API call command of index IDX5 is acquired in step S23, since the array element replacement rule is included, the process proceeds to step S32. In this case, since the value of the current layer is not smaller than the value of the top layer variable AP, the process of step S33 is skipped and the process returns to step S22.
[0081] On the other hand, in step S34, if it is determined that the array element replacement rule is not included, the printing API generation unit 11 repeatedly extracts the API call commands to be replaced and the hierarchical control functions related to them from the template (step S35). In the third embodiment, among the API call commands included in the layer below the top layer indicated by the top layer variable AP, the decoration instruction API call command, the printing instruction API call command including the array element replacement rule, and the hierarchical control functions related to them are extracted from the template. In the example of Fig. 12(a), the API call commands of indexes IDX2 to IDX5 and the hierarchical control functions related to them are extracted from the template. The plurality of API call commands and hierarchical control functions extracted here become the repetition range RR.
[0082] Next, the printing API generation unit 11 copies the plurality of API call commands and the hierarchical control functions acquired in step S35 so that the number is the same as the number of array elements included in the field data, and repeats the process of replacing the insertion field of the print instruction API call command with the data of the array elements the number of times corresponding to the number of array elements. Then, the plurality of API call commands and hierarchical control functions after execution are added to the replaced template (step S36). At this stage so far, the replaced template is configured as shown in FIG. 15(c).
[0083] Next, the printing API generation unit 11 determines whether the API call command of the index IDX6 acquired in step S23 includes a replacement rule for a single element (step S37). If the API call command includes a replacement rule for a single element, the printing API generation unit 11 acquires the data of the single element specified by the replacement rule from the field data, and replaces the insertion field of the API call command with the acquired data of the single element (step S38). After that, the API call command is added to the replaced template (step S39). At this time, if there is a hierarchical control function related to the API call command, it is also added to the replaced template.
[0084] On the other hand, when the API call command does not include a replacement rule for a single element, the process of step S38 is skipped, and the API call command obtained in step S23 is directly added to the replaced template (step S39). At this time, if there is a hierarchical control function related to the API call command, it is also added to the replaced template. By executing the process of step S39, the replaced template becomes the state shown in FIG. 12(b). Thereafter, after the print API generation unit 11 returns the value of the range search flag RF to the initial value "No" (step S40), it returns to step S22. In the example of the template shown in FIG. 12(a), since there is no API call command after index IDX6, the processes of the flowcharts shown in FIGS. 14A and 14B are terminated.
[0085] As described in detail above, in the present embodiment, print data including a plurality of print-related commands is generated using a template and field data including data of print elements to be inserted into insertion fields of API call commands included in the template. The template is composed of a plurality of API call commands by a minimum unit command group that does not include a number of repetitions corresponding to the number of variable print elements. Then, the repetition range RR is specified from among the plurality of API call commands included in the template, and the insertion fields included in the API call commands are replaced with the data of the print elements, including the replacement of repetitions within the specified range, thereby generating a print data generation API including a plurality of API call commands. By executing the generated print data generation API, print data including print-related commands into which the data of the print elements is inserted is generated.
[0086] According to the present embodiment configured as described above, for the print instruction API call command including the replacement rule of array elements and the related decoration instruction API call command, after copying the necessary number according to the number of array elements, the data of the array elements is inserted into the insertion field and the print data generation API is generated, and print data is generated by executing this print data generation API. Therefore, in the calling source application (print data generation program), it is only necessary to execute the API call commands included in the generated print data generation API one by one in order from the beginning. As a result, it is possible to generate print data with variable numbers of print elements and execute insert printing without incorporating the descriptions necessary for repeatedly calling the API call commands into the program code of the calling source application. As a result, the readability of the program code of the API calling source application can be improved.
[0087] In addition, in the above first embodiment, the repeat start flag SF may be set at a plurality of locations within the template. For example, when arranging print elements with a fixed number of elements after print elements with a variable number of elements, and further arranging print elements with a variable number of elements thereafter to perform insert printing, it is possible to set the repeat start flag SF at two locations corresponding to each of the first print element with a variable number of elements and the next print element with a variable number of elements.
[0088] Also, in the above second and third embodiments, an example of specifying the repeat range RR based on both the type of the API call command and the field data has been described, but the repeat range RR may be specified without referring to the field data. For example, the type of the API call command may be determined based on the character string of the API call command, and the repeat range RR may be specified based on the type of the API call command. In this case, the association of which character string corresponds to which type of API call command is defined in advance, and the template and the program of the template reference source are created according to the definition.
[0089] Also, in the above-described third embodiment, an example has been described in which, among the API call commands included in the layers below the top layer indicated by the top-level variable AP, the decoration instruction API call command and the print instruction API call command including the replacement rule of array elements are extracted from the template to specify the repetition range RR. However, the same may be applied to the first embodiment. That is, among the API call commands included in the layers below the layer including the repetition start flag SF, the decoration instruction API call command and the print instruction API call command including the replacement rule of array elements may be specified as the repetition range RR.
[0090] Also, in the above-described first to third embodiments, a configuration in which a plurality of API call commands are included in the template has been described. However, a configuration in which only one API call command is included in the template may also be used. In this case, for example, the print API generation unit 11 determines whether the API call command included in the template is a print instruction API call command including a replacement rule by repeated array elements. If it is determined that the API call command is a print instruction API call command including a replacement rule by the array elements, it is specified as the repetition range of the API call command.
[0091] Also, in the above-described first to third embodiments, an example in which an API call command is used as an example of the generation command and the template is configured to include one or more API call commands (hereinafter referred to as the API call format) has been described. However, the template is not limited to this format. Any data structure or format that can define a replacement rule can be used as a template. For example, it may be a template in a format in which instructions for generating print-related commands are described in a markup language (hereinafter referred to as the markup language format), or it may be a template in a format in which instructions for generating print-related commands are described in a printer command (hereinafter referred to as the printer command format).
[0092] Here, a markup language refers to a language that describes, together with text, specifications regarding the logical structure, decoration information, and supplementary information of text within text data. In the case of a markup language format, a text file in which commands for generating printing instructions and decoration instructions are marked up with predetermined symbols, etc. (the marked-up part becomes metadata) is used as a template. The instruction content including replacement rules is described as text in the text file. For example, a command for generating a printing instruction including a replacement rule is marked up with the symbol ${}, and the instruction content of the replacement rule is represented by the internal character string surrounded by ${}. Also, a command for generating a decoration instruction is marked up with the symbol [], and the instruction content is represented by the internal character string surrounded by []. Hereinafter, a command for generating marked up with a predetermined symbol, etc. is referred to as a markup command.
[0093] In the case of the printer command format, each character to be printed and each character representing a replacement rule are represented by text (for example, ASCII characters), and binary data representing commands for generating printing instructions and decoration instructions with predetermined control characters that the printer 20 can understand is used as a template. The print data (generated by the print data generation unit 12) transmitted from the host device 10 to the printer 20 is a mixture of the text of the characters to be printed and the commands of the control characters. Therefore, it is possible to configure a template in the printer command format by including replacement rules in the text part of this print data. Note that Table 1 shows an example of printer commands (control characters).
[0094]
Table 1
[0095] Regarding both the markup language format and the printer command format, the first to third embodiments described using the API call format can be similarly applied. FIGS. 16A to 16C are diagrams showing examples in which the template and the replaced template shown in FIG. 8 in the second embodiment are represented in the API call format, the markup language format, and the printer command format, respectively.
[0096] FIG. 16A is a rewrite of the template and the replaced template schematically shown in FIG. 8 in the form of program code. In FIG. 16A(a) showing the template in this API call format, “.styleAlignment(···)”, “.styleBold(···)”, and “.styleUnderline(···)” are decoration instruction API call commands, and “.actionPrintText(···)” is a print instruction API call command. FIG. 16A(b) is a replaced template (print data generation API) in the API call format generated from the template shown in FIG. 16A(a) and the same field data as FIG. 8(a).
[0097] On the other hand, in FIG. 16B(a) showing the template in the markup language format, the portion surrounded by ${} is a markup portion representing a generation command for a print instruction including a replacement rule, and the portion surrounded by [] is a markup portion representing a generation command for a decoration instruction. The template in the markup language format shown in FIG. 16B(a) has the same structure as the template shown in FIG. 8(a) except that the API call command is replaced with a markup command. Therefore, an algorithm similar to the flowcharts shown in FIGS. 10A and 10B can also be applied to the template in the markup language format of FIG. 16B(a).
[0098] As a result, as shown in FIG. 16B(a), a repeating range RR similar to that in FIG. 8(a) is specified, and substitution of the insertion field including substitution of the repetition in the specified range is executed. Here, if substitution is performed with the data of the printing elements included in the same field data as FIG. 8(a), the generated substituted template will be as shown in FIG. 16B(b), and will have the same structure as the substituted template shown in FIG. 8(b). Thus, when printing data is generated from the substituted template shown in FIG. 16B(b) and sent to the printer 20 for printing, the printing result will be the same as FIG. 9.
[0099] The template in printer command format is, as shown in FIG. 16C(a), binary data in which the control characters of the generation command and the text (ASCII characters) of each character are mixed. When this is classified and organized into control characters and text, it becomes as shown in FIG. 16C(b). This is because the API call command is only replaced with control characters and text, and has the same structure as the template shown in FIG. 8(a). Therefore, it is possible to apply an algorithm similar to the flowcharts shown in FIGS. 10A and 10B to the template in printer command format in FIG. 16C(a).
[0100] As a result, as shown in FIG. 16C(b), a repeating range RR similar to that in FIG. 8(a) is specified, and substitution of the insertion field including substitution of the repetition in the specified range is executed. Here, if substitution is performed with the data of the printing elements included in the same field data as FIG. 8(a), the generated substituted template will be as shown in FIG. 16C(c), and will have the same structure as the substituted template shown in FIG. 8(b). Thus, when printing data is generated from the substituted template shown in FIG. 16C(c) and sent to the printer 20 for printing, the printing result will be the same as FIG. 9.
[0101] Here, an example was shown in which the template of FIG. 8(a) described in the second embodiment is configured in a markup language format or a printer command format. Similarly, the template of FIG. 6(a) described in the first embodiment and the template of FIG. 12(a) described in the third embodiment can also be configured in a markup language format or a printer command format.
[0102] In the first and third embodiments, a hierarchical control function is included in the template, and in the first embodiment, a repeat start flag SF is further included in the template. FIG. 17 is a diagram showing an example in which the template of FIG. 6(a) schematically shown in the first embodiment is represented in an API call format, a markup language format, and a printer command format. In FIG. 17, indentation is added corresponding to the hierarchy so that the hierarchy is easier to see. Here, the hierarchical control function and the repeat start flag SF not included in FIGS. 16A to 16C will be described.
[0103] As shown in FIG. 17(a), in the case of the API call format, the hierarchical control function is represented by the add function. By calling the add function, the hierarchy of the API call command group specified in its argument becomes one level deeper. And with the end of the add function, the hierarchy of the API call command group specified in its argument becomes one level shallower (returns to the original). Here, the symbol "↓" shown in FIG. 6(a) is represented as ".add(", and the symbol "↑" is represented as ")". The sixth string ".setRepeat(true)" from the top indicates the repeat start flag SF.
[0104] As shown in FIG. 17(b), in the case of the markup language format, the hierarchy becomes one level deeper with the string "decorationblock:start" included within the brackets [] indicating the markup location, and the hierarchy becomes one level shallower (returns to the original state) with the string "decorationblock:end". That is, the symbol "↓" shown in FIG. 6(a) is represented by the string [decorationblock:start], and the symbol "↑" is represented by the string [decorationblock:end]. Also, the string "repeat true" included in the third markup location from the top indicates the repeat start flag SF.
[0105] As shown in FIG. 17(c), in the case of the printer command format, the hierarchy becomes one level deeper with the hierarchy addition command "0x1b 0x1d 0x72 0x6b 0x01", and the hierarchy becomes one level shallower (returns to the original state) with the hierarchy end command "0x1b 0x1d 0x72 0x6b 0x00". By the hierarchy end command, the cancellation of the decoration set in the lower layer than the current hierarchy is performed inside the printer 20. Also, the command "0x1b 0x1d 0x72 0x70 0x01" indicates the repeat start flag SF.
[0106] Also, in the above first to third embodiments, an example has been described in which a replaced template having a structure in the same format as the template is used as data for generating print data (print data generation API) by replacing the insertion field included in the API call command with the data of the print element. However, the present invention is not limited to this. The replaced template may be a data structure or format having the data of the print element replaced with the field data and information sufficient for the print data generation unit 12 to convert it into a printer command. Therefore, the template before replacement and the replaced template do not necessarily have to have the same format structure.
[0107] For example, as a substituted template generated by replacing an insertion field with print element data, data for generating print data may be generated, which consists of the type of instruction by a print-related command, the type of instruction, and a structure representing the print element data. As an example, as shown in Fig. 18(a), a substituted template may be configured by a data structure similar to a structure in the C++ programming language that has a type member for classifying print instructions and decoration instructions, a name member of a character string indicating the type of instruction, and an info member of a dictionary for storing information necessary for the instruction. The substituted template consisting of this data structure may be converted into print data including print-related commands. This is applicable to any of the first to third embodiments described above.
[0108] When using the substituted template of the data structure shown in Fig. 18(a), for example, information corresponding to the print instruction API call command "actionPrintText" of the substituted template shown in Fig. 5 can be stored with values as shown in Fig. 18(b) for the data structure of Fig. 18(a). Also, information corresponding to the decoration instruction API call command "styleAlignment" of the substituted template shown in Fig. 5 can be stored with values as shown in Fig. 18(c) for the data structure of Fig. 18(a).
[0109] Here, an example of generating a C++-formatted substituted template from an API call format template has been described, but it is also possible to generate a C++-formatted substituted template from a markup language format or printer command format template. Also, the C++ format is an example of a format different from the template before substitution, and is not limited to this format. For example, a substituted template in a markup language format or printer command format may be generated from an API call format template, or a substituted template in an API call format or printer command format may be generated from a markup language format, or a substituted template in an API call format or markup language format may be generated from a printer command format.
[0110] In addition, in the first to third embodiments described above, an example was described in which a replaced template was generated by replacing the insertion fields included in the API call command with the data of the printing elements, and then data for generating print data (print data generation API) was generated from the replaced template. However, the present invention is not limited to this. For example, by replacing the insertion fields with the data of the printing elements including repeated replacement within a specified range, a plurality of API call commands including the replaced API call command are sequentially generated, and each time an API call command is generated, print-related commands (printer commands) are sequentially generated from the API call command to generate print data.
[0111] For example, when generating print data from the template and field data shown in FIG. 6(a) in the first embodiment, the processing may be executed in the following procedure. (0) First, set the set value of the decoration information to the initial value. For example, set the specification of alignment to "Left", the specification of bold to "false", and the specification of underline to "false". (1) By executing the decoration instruction API call command "Alignment Left", a left-aligned printer command is generated, and the set value of the first-level alignment specification is set to "Left" (no change from the initial value). (2) By executing the printing instruction API call command "Text \"${store_name}\n\"" including the replacement rule for a single element, a printer command for printing "Star Store\n" of the printing element is generated.
[0112] Next, in steps (3) to (8), the first-time processing is executed for the repetition range specified by the repetition start flag SF. (3) By executing the decoration instruction API call command "Bold", a printer command with bold enabled is generated, and the setting value of the bold specification in the second layer is set to "true". (4) By executing the printing instruction API call command "Text"${items.name}"", which includes a replacement rule based on repeated array elements, a printer command for printing "T shirt" of the printing element is generated. (5) By executing the decoration instruction API call command "Underline", a printer command with underline enabled is generated, and the setting value of the underline specification in the third layer is set to "true". (6) By executing the printing instruction API call command "Text"${items.price}\n"", which includes a replacement rule based on repeated array elements, a printer command for printing "10.99\n" of the printing element is generated. (7) When exiting the third layer, since the setting value "true" of the underline specification in the third layer is different from the setting value "false" of the underline specification in the second layer, a printer command with underline disabled is generated to be the setting value of the underline specification in the second layer. (8) When exiting the second layer, since the setting value "true" of the bold specification in the second layer is different from the setting value "false" of the bold specification in the first layer, a printer command with bold disabled is generated to be the setting value of the bold specification in the first layer.
[0113] Next, in steps (9) to (14), the second processing is executed for the repetition range specified by the repetition start flag SF. (9) By executing the decoration instruction API call command "Bold", a printer command with bold enabled is generated, and the setting value of the bold specification in the second layer is set to "true". (10) By executing the printing instruction API call command "Text"${items.name}"", which includes a replacement rule based on repeated array elements, a printer command for printing "Denim" of the printing element is generated. (11) Generate a printer command with underlining enabled by executing the decoration instruction API call command "Underline", and set the setting value of the underline specification in the third layer to "true". (12) Generate a printer command for printing "29.99\n" in the print element by executing the print instruction API call command "Text \"${items.price}\n\"" that includes a replacement rule with repeated array elements. (13) When exiting the third layer, since the setting value "true" of the underline specification in the third layer is different from the setting value "false" of the underline specification in the second layer, generate an underline-disabled printer command to be the setting value of the underline specification in the second layer. (14) When exiting the second layer, since the setting value "true" of the bold specification in the second layer is different from the setting value "false" of the bold specification in the first layer, generate a bold-disabled printer command to be the setting value of the bold specification in the first layer.
[0114] (15) Finally, generate a printer command for printing "Thank you\n" by executing the print instruction API call command "Text \"Thank you\n\"" that does not include a replacement rule.
[0115] Here, an example of sequentially generating printer commands from the template of FIG. 6(a) described in the first embodiment is shown. Similarly, for the template of FIG. 8(a) described in the second embodiment and the template of FIG. 12(a) described in the third embodiment, it is also possible to sequentially generate printer commands from these templates. Also, here an example of sequentially generating printer commands from a template in the form of an API call is shown, but it is similarly possible to sequentially generate printer commands from a template in the form of a markup language or a printer command.
[0116] In the above first to third embodiments, as shown in FIGS. 1 and 3, the host device 10 includes a print API generation unit 11, a print data generation unit 12, a template storage unit 14, and a field data storage unit 15. In the host device 10, a print data generation API (data for generating print data) and print data are generated, and the generated print data is transmitted from the host device 10 to the printer 20 to execute printing. Although the system configuration has been described, the present invention is not limited to this system configuration. For example, a system configuration as shown in FIGS. 19A to 19H may be used.
[0117] In the system configuration shown in FIG. 19A, while the host device 10 includes a field data storage unit 15, the printer 20 includes a print API generation unit 11, a print data generation unit 12, and a template storage unit 14. Then, in the printer 20, the template held by itself and the field data transmitted from the host device 10 are combined to execute the processes of the print API generation unit 11 and the print data generation unit 12, and printing is executed based on the generated print data.
[0118] In the system configuration shown in FIG. 19B, the host device 10 includes a field data storage unit 15, and a server (for example, a server on the cloud or a server on the LAN; the same applies hereinafter) includes a template storage unit 14, while the printer 20 includes a print API generation unit 11 and a print data generation unit 12. Then, in the printer 20, the template transmitted from the server and the field data transmitted from the host device 10 are combined to execute the processes of the print API generation unit 11 and the print data generation unit 12, and printing is executed based on the generated print data.
[0119] In the system configuration shown in FIG. 19C, the host device 10 includes a template storage unit 14, the server includes a field data storage unit 15, while the printer 20 includes a print API generation unit 11 and a print data generation unit 12. Then, in the printer 20, the field data transmitted from the server and the template transmitted from the host device 10 are combined to execute the processes of the print API generation unit 11 and the print data generation unit 12, and printing is executed based on the generated print data.
[0120] In the system configuration shown in FIG. 19D, the printer 20 includes a print API generation unit 11 and a print data generation unit 12, while the server includes a template storage unit 14 and a field data storage unit 15, and the host device 10 issues only an execution command for plug-in printing to the printer 20. Upon receiving this print execution command, the printer 20 acquires the specified template and field data from the server, combines them, executes the processes of the print API generation unit 11 and the print data generation unit 12, and executes printing based on the generated print data.
[0121] In the system configuration shown in FIG. 19E, the printer 20 includes a print API generation unit 11, a print data generation unit 12, and a template storage unit 14, while the server includes a field data storage unit 15, and the host device 10 issues only an execution command for plug-in printing to the printer 20. Upon receiving this print execution command, the printer 20 combines the template it holds with the field data acquired from the server, executes the processes of the print API generation unit 11 and the print data generation unit 12, and executes printing based on the generated print data.
[0122] The system configuration shown in Fig. 19F is a modified pattern of the system configuration shown in Fig. 19D, and is designed to issue an execution command for plug-in printing from the host device 10 to the printer 20 via the cloud server. In the system configuration shown in Fig. 19F, in addition to the host device 10 and the printer 20, a POS service cloud server and a print job management cloud server are provided, and the print job management cloud server includes a template storage unit 14 and a field data storage unit 15. The host device 10 issues an execution command for plug-in printing to the printer 20 via the POS service cloud server and the print job management cloud server. Upon receiving this print execution command, the printer 20 acquires the template and field data specified by the print job management cloud server, combines them, executes the processing of the print API generation unit 11 and the print data generation unit 12, and executes printing based on the generated print data. Note that a configuration similar to this can also be applied as a modified pattern of the system configuration shown in Fig. 19E.
[0123] In the system configuration shown in Fig. 19G, in addition to the host device 10 and the printer 20, a print job management cloud server and a print job reception terminal are provided. While the print job reception terminal includes a print API generation unit 11 and a print data generation unit 12, the print job management cloud server includes a template storage unit 14 and a field data storage unit 15. The host device 10 and the print job reception terminal are connected via, for example, a wired / wireless LAN, Bluetooth (registered trademark), or Wi-Fi (registered trademark). The printer 20 and the print job reception terminal are connected via, for example, a serial cable, USB, Bluetooth (registered trademark), etc., and unlike Figs. 19B to 19F, the printer 20 does not need to be connected to the Internet or the like. The host device 10 only issues an execution command for plug-in printing to the print job reception terminal. Upon receiving this print execution command, the print job reception terminal acquires the template and field data specified by the print job management cloud server, combines them, executes the processing of the print API generation unit 11 and the print data generation unit 12, and transmits the generated print data to the printer 20 to execute printing.
[0124] The system configuration shown in FIG. 19H is such that the cloud server is equipped with a template editor, and the host device 10 can access the cloud server to create a template. In the system configuration shown in FIG. 19H, a template is created on the host device 10 using the template editor of the cloud server (FIG. 19H(a)), and the created template is uploaded from the host device 10 to the cloud server (FIG. 19H(b)). In the system configuration shown in FIG. 19H, the host device 10 is provided with a field data storage unit 15, and the cloud server is provided with a print API generation unit 11, a print data generation unit 12, and a template storage unit 14. The template storage unit 14 stores the template uploaded from the host device 10. As shown in FIG. 19H(c), the host device 10 uploads field data to the cloud server and issues a command to execute insertion printing. Upon receiving this print execution command, the cloud server combines the template it holds with the field data acquired from the host device 10, executes the processing of the print API generation unit 11 and the print data generation unit 12, and transmits the generated print data to the printer 20 to execute printing.
[0125] In the system configurations shown in FIGS. 1 and 19A to 19H, a configuration is shown in which one device (either the host device 10, the printer 20, the server, or the print job reception terminal) is provided with both the print API generation unit 11 and the print data generation unit 12. However, the print API generation unit 11 and the print data generation unit 12 may be provided separately in different devices. For example, as a modified pattern for the system configuration of FIG. 1, while the host device 10 is provided with the print API generation unit 11, the printer 20 is provided with the print data generation unit 12, and the print data generation API (replaced template) generated by the host device 10 is transmitted to the printer 20, and the printer 20 may generate print data by executing the print data generation API. This can be similarly applied to the system configurations shown in FIGS. 19A to 19H.
[0126] Also, in the system configurations shown in FIGS. 19A to 19H, it is also possible to use a template in a markup language format or a printer command format instead of a template in an API call format. Also, in the system configurations shown in FIGS. 19A to 19H, it is also possible to use a replaced template in a C++ format instead of a replaced template in an API call format.
[0127] Also, in the first to third embodiments described above, the format of the string after replacement may be specified according to the replacement rule of the API call command included in the template. For example, the insertion field of the replacement rule starting with the symbol ${ and ending with the symbol} is configured as follows (the symbols "" and + are for explanation and are not actually described), and according to the content of the format specifier, the expression or layout of the string when the field data is inserted into the insertion field may be specified. "${" + "key" + "format specifier" + "}"
[0128] As the format specifier, for example, the following can be used. (A) Format specifiers for numerical field data When the field data is numerical, it can be specified using format specifiers used in functions such as the printf function in the C language as to what kind of string it will be replaced with. Some specific examples are as follows. %d: Convert to a signed decimal integer string. %f: Convert to a decimal string. %1d: Convert to a 1-digit signed decimal integer string. %5.2f: Convert to a decimal with a total of 5 digits including the decimal point and 2 digits after the decimal point.
[0129] (B) Format specifiers for specifying the number of characters The number of characters after replacement and the presence or absence of omission can be specified by a format specifier. Some specific examples are as follows. %digit=4,last: Set the number of characters after replacement to 4. Delete the end of the field data. %digit=10,last,ellipsis: Set the number of characters after replacement to 10. Delete the end of the field data and append an ellipsis (...). %digit=10,middle,ellipsis: Set the number of characters after replacement to 10. Delete the middle of the field data and append an ellipsis (...). %digit=10,first,ellipsis: Set the number of characters after replacement to 10. Delete the beginning of the field data and append an ellipsis (...).
[0130] In this way, for example, when the field data is a numerical value, it is possible to control what kind of character string it will become when inserted into the template's insertion field. For example, when there is field data of the value of pi, 3.14159265359, it is possible to specify in the template whether to print the value as "3", "3.14", or "3.14159265359". Also, when the width of the printing paper is narrow and there is a limit to the number of characters that can fit in one line, it is possible to prevent unintentional line breaks such as when the character string of the field data is too long to fit in one line and the printing wraps to the next line, through the specification of the template.
[0131] Specific embodiments will be described below. Here, an example will be described where the printing paper is a receipt and the printing of a character string including an item list is performed. Assume that the number of characters that can be printed in one line of the receipt is 32 characters, and it is desired to keep the number of characters for one line of the printing data within 32 characters. In this case, for example, prepare a template with format specifications as shown in Figure 20(a).
[0132] In the template shown in Fig. 20(a), the part "${items.name%digit=23,last,ellipsis}" specifies that the product name should be 23 characters, and if it doesn't fit, the end should be truncated and "..." should be added. Up to this point, the number of characters printed in one line is 23 characters / 32 characters. The next part " x" is a fixed string placed before the replacement rule for the quantity. Up to this point, the number of characters printed in one line is 25 characters / 32 characters. The next part "${items.quantity%1d}" specifies that the numerical value of the quantity should be converted to a one-character decimal integer as a string. Up to this point, the number of characters printed in one line is 26 characters / 32 characters. The next part " " is a fixed string placed before the replacement rule for the unit price. Up to this point, the number of characters printed in one line is 27 characters / 32 characters. The next part "${items.price%5.2f}\n" specifies that the numerical value of the unit price should be converted to a string with a total of 5 characters including the decimal point and 2 digits after the decimal point. Up to this point, the number of characters printed in one line is 32 characters / 32 characters. The last "\n" causes a line break.
[0133] When the template in Fig. 20(a) is combined with the field data in Fig. 20(b) and used, the printing result in Fig. 20(c) can be obtained. In this way, by specifying the number of characters in the replacement rule of the template, the layout of the character string in one line can be flexibly specified. Also, the numerical values of the field data can be converted to strings in a form along the receipt layout.
[0134] In addition, each of the above embodiments is merely an example of the implementation of the present invention, and the technical scope of the present invention should not be construed in a limited manner by this. That is, the present invention can be implemented in various forms without departing from its gist or its main features.
Explanation of Reference Numerals
[0135] 10 Host device 11 API generation unit for printing (data generation unit for printing data generation) 12 Printing data generation unit 13 Field data generation unit 14 Template storage unit 15 Field data storage unit 20 Printer
Claims
1. A print data generation device that generates print data including a plurality of print-related commands using a template and field data including data of print elements to be inserted into the insertion fields of the template, wherein the template includes one or more generation commands for generating the print-related commands, and the one or more generation commands are composed of commands in a minimum unit that do not include repetitions according to the variable number of print elements, identifies a range of generation commands that repeatedly execute processing a number of times according to the variable number of print elements from among the templates based on the contents of both the template and the field data or the contents of the template, and replaces the insertion fields included in the generation commands with the data of the print elements including replacement of repetitions within the identified range, and generates the print data including print-related commands into which the data of the print elements are inserted using a plurality of generation commands including the replaced generation commands A print data generation device characterized by the above.
2. A print data generation data generation unit that generates print data generation data having a structure in the same format as the template and including the plurality of generation commands by replacing the insertion fields included in the generation commands with the data of the print elements including replacement of repetitions within the identified range, A print data generation device according to claim 1, comprising: a print data generation unit that generates the print data using the print data generation data generated by the print data generation data generation unit.
3.
3. A print data generation data generation unit that generates print data generation data having a structure in a different format from the template and including the plurality of generation commands by replacing the insertion fields included in the generation commands with the data of the print elements including replacement of repetitions within the identified range, A print data generation device according to claim 1, comprising: a print data generation unit that generates the print data using the print data generation data generated by the print data generation data generation unit.
4.
4. By replacing the interpolation fields included in the generation command with the data of the printing elements, including repeated replacement within the specified range, a plurality of generation commands including the replaced generation command are sequentially generated. Each time one of the plurality of generation commands is generated, the printing data is generated by sequentially generating the printing-related commands from the generation command. The printing data generation device according to claim 1, characterized in that.
5. The template is a template in a format including an API call command for calling and executing an API in which a process for generating the printing-related commands is described as the generation command, according to any one of claims 1 to 4. The printing data generation device described.
6. The template is a template in a format in which an instruction for generating the printing-related commands is described in a markup language as the generation command, according to any one of claims 1 to 4. The printing data generation device described.
7. The template is a template in a format in which an instruction for generating the printing-related commands is described in a printer command as the generation command, according to any one of claims 1 to 4. The printing data generation device described.
8. A printing data generation method for generating printing data including a plurality of printing-related commands using a template and field data including data of printing elements to be inserted into the interpolation fields of the template, The template includes one or more generation commands for generating the printing-related commands, and the one or more generation commands are composed of commands in a minimum unit that do not include a number of repetitions according to the variable number of printing elements. The control unit of the print data generation device specifies the range of generation commands that repeatedly execute processing a number of times corresponding to the variable number of print elements from among the above templates based on the contents of both the above template and the above field data or the contents of the above template, and replaces the above insertion fields included in the above generation commands with the data of the above print elements, including repeated replacement within the specified range, and generates the above print data including print-related commands into which the data of the above print elements are inserted using a plurality of generation commands including the replaced generation commands. A print data generation method characterized by the above. **Claim 9** A print data generation data generation device that generates print data generation data including a plurality of generation commands using a template and field data including data of print elements to be inserted into the insertion fields of the template, The above template includes one or more generation commands for generating print-related commands included in print data, and the one or more generation commands are composed of minimum unit commands that do not include repetitions according to the variable number of print elements. A print data generation data generation unit that generates print data generation data including a plurality of generation commands by specifying the range of generation commands that repeatedly execute processing a number of times corresponding to the variable number of print elements from among the above templates based on the contents of both the above template and the above field data or the contents of the above template, and replacing the above insertion fields included in the above generation commands with the data of the above print elements, including repeated replacement within the specified range. A print data generation data generation device characterized by the above. **Claim 10** A print data generation data generation method that generates print data generation data including a plurality of generation commands using a template and field data including data of print elements to be inserted into the insertion fields of the template, The above template includes one or more generation commands for generating print-related commands included in print data, and the one or more generation commands are composed of minimum unit commands that do not include repetitions according to the variable number of print elements. The data generation unit for print data of the print data generation device generates data for print data generation including a plurality of generation commands by specifying a range of generation commands that repeatedly execute a process the number of times corresponding to the variable number of print elements from among the templates based on the contents of both the template and the field data or the content of the template, and replacing the insertion fields included in the generation commands with the data of the print elements including repeated substitution within the specified range. A method for generating data for print data generation, characterized by the above.
Citation Information
Patent Citations
Information processing device and control method for information processing device
JP7006096B2