Method and device for printing data item content
By dynamically adjusting the font size and paging processing, the content occlusion or loss caused by excessively long data items in the templated table is solved, and the complete and clear printing of the data item content is achieved.
Patent Information
- Application Number
- CN202111363309.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-17
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2041-11-17
AI Technical Summary
Existing printing methods cannot effectively solve the problem of occlusion or loss of content caused by excessively long data items in templated tables.
By reading the xml file, we judge whether the data item content is printed dynamically, and compare it according to the height of the content area with the size of the table area, dynamically adjust the font size, calculate the number of pages, and split or adjust the font size according to the minimum font size to ensure the content Full display.
It effectively solves the problem of content occlusion or loss caused by excessive data item content, ensuring complete and clear printing of data item content.
Smart Images

Figure CN114035756B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data printing, and in particular to a method and device for printing data item content. Background Art
[0002] The current printing method is to get a paper form template, drag and drop controls to form a data entry interface, and save it in the database; call the form from the database and print preview. Construct a PrintDocument object when the application form is initialized, add the PrintPage method of the printDocument object; read the data item content of the form in the database; draw a table format based on the read data item content and display the data item content to the corresponding position; call the Drawstring method of the Graphics class to draw according to the preset font size, and call the Print method of printDocument in the user's click event to implement the printing function.
[0003] The above printing method cannot solve the problem of content obstruction or loss caused by excessively long data items in templated tables. Summary of the invention
[0004] In view of this, an object of the present invention is to provide a method and device for printing data item content, by comparing the size of the table area and the content area, the data item content is printed out in a manner of changing the font size, thereby solving the problem of content obstruction or loss caused by excessively long data item content.
[0005] In a first aspect, an embodiment of the present invention provides a method for printing data item content, the method comprising:
[0006] Reading an XML file, wherein the XML file includes a form, and the form includes at least one data item content and a table area;
[0007] Determining whether the content of the data item is dynamically printed;
[0008] If yes, determining the content area according to the content of the data item;
[0009] Determine whether the height of the content area exceeds the table area;
[0010] If yes, adjusting the font size of the content area with the minimum font size to obtain a new content area;
[0011] Calculate the number of pages according to the new content area and the table area;
[0012] Determine whether the number of pages is greater than 1;
[0013] If yes, split the data item content according to the minimum font size, and set the minimum font size as the first required font size;
[0014] If not, the second required font size that is fully displayed in the table area is obtained by cyclically comparing the table area with the new content area.
[0015] Furthermore, the method further comprises:
[0016] Determining whether the font size of the form is consistent with the first required font size or the second required font size;
[0017] If yes, printing according to the first required font size or the second required font size;
[0018] If not, the font size of the form is reset.
[0019] Further, determining the content area according to the content of the data item includes:
[0020] The content area is determined according to the amount of content and font size of the data item.
[0021] Further, the determining whether the content of the data item is dynamically printed includes:
[0022] If not, the data item content is directly drawn and printed out.
[0023] Furthermore, the determining whether the height of the content area exceeds the table area includes:
[0024] If not, print out the data item content.
[0025] In a second aspect, an embodiment of the present invention provides a device for printing data item content, the device comprising:
[0026] A reading unit, used for reading an XML file, wherein the XML file includes a form, and the form includes at least one data item content and a table area;
[0027] A first judging unit, used to judge whether the content of the data item is dynamically printed;
[0028] A determination unit, configured to determine a content area according to the content of the data item when the content of the data item is the dynamic print;
[0029] A second judging unit, used to judge whether the height of the content area exceeds the table area;
[0030] An adjusting unit, configured to adjust the font size of the content area with a minimum font size to obtain a new content area when the height exceeds the table area;
[0031] A calculation unit, used for calculating the number of pages according to the new content area and the table area;
[0032] A third judging unit, used to judge whether the number of pages is greater than 1;
[0033] a splitting unit, configured to split the data item content according to the minimum font size when the number of pages is greater than 1, and set the minimum font size to be the first required font size;
[0034] The display unit is used for obtaining a second required font size that is fully displayed in the table area by cyclically comparing the table area with the new content area when the number of pages is not greater than 1.
[0035] Furthermore, the device also includes:
[0036] a fourth determination unit, configured to determine whether the font size of the form is consistent with the first required font size or the second required font size;
[0037] A printing unit, configured to print according to the first required font size or the second required font size when the two fonts are consistent;
[0038] The setting unit is used to reset the font size of the form in case of inconsistency.
[0039] Furthermore, the determining unit is specifically used for:
[0040] The content area is determined according to the amount of content and font size of the data item.
[0041] In a third aspect, an embodiment of the present invention provides an electronic device, including a memory and a processor, wherein the memory stores a computer program executable on the processor, and the processor implements the method described above when executing the computer program.
[0042] In a fourth aspect, an embodiment of the present invention provides a computer-readable medium having a non-volatile program code executable by a processor, wherein the program code enables the processor to execute the method as described above.
[0043] The embodiment of the present invention provides a method and device for printing data item content, including: reading an XML file, the XML file includes a form, the form includes at least one data item content and a table area; judging whether the data item content is printed dynamically; if so, determining the content area according to the data item content; judging whether the height of the content area exceeds the table area; if so, adjusting the font size of the content area with the minimum font size to obtain a new content area; calculating the number of pages according to the new content area and the table area; judging whether the number of pages is greater than 1; if so, splitting the data item content according to the minimum font size, and setting the minimum font size as the first required font size; if not, obtaining the second required font size that is fully displayed in the table area by cyclically comparing the table area with the new content area; and printing the data item content by changing the font size by comparing the size of the table area and the content area, thereby solving the problem of content obstruction or loss caused by the excessive length of the data item content.
[0044] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention are realized and obtained by the structures particularly pointed out in the description, claims and drawings.
[0045] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0047] Figure 1 A flow chart of a method for printing data item content provided in Embodiment 1 of the present invention;
[0048] Figure 2 A schematic diagram of a handover record form provided in the first embodiment of the present invention;
[0049] Figure 3 A flow chart of another method for printing data item content provided in Embodiment 2 of the present invention;
[0050] Figure 4 A schematic diagram of a device for printing data item content provided in Embodiment 3 of the present invention.
[0051] icon:
[0052] 1-reading unit; 2-first judging unit; 3-determining unit; 4-second judging unit; 5-adjusting unit; 6-calculating unit; 7-third judging unit; 8-splitting unit; 9-display unit. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0054] To facilitate understanding of this embodiment, the embodiment of the present invention is described in detail below.
[0055] Embodiment 1:
[0056] Figure 1 This is a flow chart of a method for printing data item content provided in Embodiment 1 of the present invention.
[0057] Reference Figure 1 , the method comprises the following steps:
[0058] Step S101, reading an XML (Extensible Markup Language) file, the XML file includes a form, and the form includes at least one data item content and a table area;
[0059] Here, the interface editor tool is used to design a functional interface with the same effect as the paper-based specialty form and generate an XML file, which includes a form, and the form includes at least one data item content and a table area. Among them, the XML file records the location of each data item content and the actual display size when printed.
[0060] Read the xml file to present the form interface to the software system, and then call the print interface of each control to directly achieve the same print preview effect as the input interface. The font size can be set in the print interface.
[0061] Step S102, determining whether the data item content is dynamically printed; if yes, executing step S103; if no, executing step S104;
[0062] Step S103, determining the content area according to the content of the data item;
[0063] Here, the table format is read and the size of the data item content is determined through GDI (Graphics Device Interface), thereby determining the content area.
[0064] Step S104, directly drawing the data item content, and printing out the data item content;
[0065] Step S105, determining whether the height of the content area exceeds the table area; if yes, executing step S106; if no, executing step S104;
[0066] Step S106, adjusting the font size of the content area with the minimum font size to obtain a new content area;
[0067] Step S107, calculating the number of pages according to the new content area and table area;
[0068] Step S108, determine whether the number of pages is greater than 1; if yes, execute step S109; if no, execute step S110;
[0069] Step S109, splitting the data item content according to the minimum font size, and setting the minimum font size as the first required font size;
[0070] Step S110 , obtaining a second required font size that is fully displayed in the table area by cyclically comparing the table area with the new content area.
[0071] In this application, Figure 2 Take the handover record form as an example. Assuming that the font size of the pre-hospital diagnosis and treatment content is 15, when too much content is entered, it will block the display of other data items when printing, causing text overlap and affecting the readability of the form. This application compares the height of the input content area with the height of the table area, dynamically adjusts the font size of the input content, calculates the optimal font size to match the table area, and displays the content on the table area by changing the font size.
[0072] Furthermore, the method further comprises the following steps:
[0073] Step S201, determining whether the font size of the form is consistent with the first required font size or the second required font size; if yes, executing step S202; if no, executing step S203;
[0074] Step S202, printing according to the first required font size or the second required font size;
[0075] Step S203, resetting the font size of the form.
[0076] Further, step S103 includes:
[0077] Determine the content area based on the amount of data item content and font size.
[0078] An embodiment of the present invention provides a method for printing data item content, comprising: reading an XML file, the XML file comprising a form, the form comprising at least one data item content and a table area; judging whether the data item content is printed dynamically; if so, determining the content area according to the data item content; judging whether the height of the content area exceeds the table area; if so, adjusting the font size of the content area with the minimum font size to obtain a new content area; calculating the number of pages according to the new content area and the table area; judging whether the number of pages is greater than 1; if so, splitting the data item content according to the minimum font size, and setting the minimum font size as a first required font size; if not, obtaining a second required font size that is fully displayed in the table area by cyclically comparing the table area with the new content area; and printing the data item content by changing the font size by comparing the sizes of the table area and the content area, thereby solving the problem of content obstruction or loss caused by the excessive length of the data item content.
[0079] Embodiment 2:
[0080] Figure 3 This is a flow chart of a method for printing another data item content provided in Embodiment 2 of the present invention.
[0081] Reference Figure 3 , the method comprises the following steps:
[0082] Step S301, drag and drop controls using an interface editor tool;
[0083] Step S302, exporting an XML file;
[0084] Step S303, read the XML file and generate a form interface;
[0085] Step S304, storing the data item contents of the form;
[0086] Step S305, form print preview;
[0087] Step S306, reading an XML file; wherein the XML file includes a form, and the form includes at least one data item content and a table area;
[0088] Step S307, determining whether the data item content is dynamically printed; if yes, executing step S308; if no, executing step S309;
[0089] Step S308, determining the content area according to the content of the data item;
[0090] Step S309, directly drawing the data item content;
[0091] Step S310, print out the data item content;
[0092] Step S311, determine whether the height of the content area exceeds the table area; if yes, execute step S312; if no, execute step S310;
[0093] Step S312, adjusting the font size of the content area with the minimum font size to obtain a new content area;
[0094] Step S313, calculating the number of pages according to the new content area and table area;
[0095] Step S314, determine whether the number of pages is greater than 1; if yes, execute step S315; if no, execute step S316;
[0096] Step S315, splitting the data item content according to the minimum font size, and setting the minimum font size as the first required font size;
[0097] Step S316, obtaining a second required font size that is fully displayed in the table area by cyclically comparing the table area with the new content area;
[0098] Step S317, determining whether the font size of the form is consistent with the first required font size or the second required font size; if yes, executing step S318; if no, executing step S319;
[0099] Step S318, printing according to the first required font size or the second required font size;
[0100] Step S319, reset the font size of the form.
[0101] Embodiment three:
[0102] Figure 4 A schematic diagram of a device for printing data item content provided in Embodiment 3 of the present invention.
[0103] Reference Figure 4 , the device comprises:
[0104] A reading unit 1 is used to read an XML file, wherein the XML file includes a form, and the form includes at least one data item content and a table area;
[0105] A first judging unit 2, used to judge whether the content of the data item is dynamically printed;
[0106] Determining unit 3, used to determine the content area according to the data item content when the data item content is dynamically printed;
[0107] The second judging unit 4 is used to judge whether the height of the content area exceeds the table area;
[0108] An adjustment unit 5, configured to adjust the font size of the content area with a minimum font size to obtain a new content area when the height exceeds the table area;
[0109] A calculation unit 6, used for calculating the number of pages according to the new content area and table area;
[0110] The third judging unit 7 is used to judge whether the number of pages is greater than 1;
[0111] A splitting unit 8 is used to split the data item content according to the minimum font size when the number of pages is greater than 1, and set the minimum font size to the first required font size;
[0112] The display unit 9 is used for obtaining a second required font size that is fully displayed in the table area by cyclically comparing the table area with the new content area when the number of pages is not greater than 1.
[0113] Furthermore, the device also includes:
[0114] A fourth determination unit (not shown), configured to determine whether the font size of the form is consistent with the first required font size or the second required font size;
[0115] A printing unit (not shown), used for printing according to the first required font size or the second required font size when the font size is consistent;
[0116] The setting unit (not shown) is used to reset the font size of the form in case of inconsistency.
[0117] Further, the determination unit 3 is specifically used for:
[0118] Determine the content area based on the amount of data item content and font size.
[0119] An embodiment of the present invention provides a printing device for data item content, comprising: reading an XML file, the XML file includes a form, the form includes at least one data item content and a table area; judging whether the data item content is printed dynamically; if so, determining the content area according to the data item content; judging whether the height of the content area exceeds the table area; if so, adjusting the font size of the content area with the minimum font size to obtain a new content area; calculating the number of pages according to the new content area and the table area; judging whether the number of pages is greater than 1; if so, splitting the data item content according to the minimum font size, and setting the minimum font size as the first required font size; if not, obtaining the second required font size that is fully displayed in the table area by cyclically comparing the table area with the new content area; and printing the data item content by changing the font size by comparing the sizes of the table area and the content area, thereby solving the problem of content obstruction or loss caused by the excessive length of the data item content.
[0120] An embodiment of the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for printing the data item content provided in the above embodiment are implemented.
[0121] An embodiment of the present invention further provides a computer-readable medium having a non-volatile program code executable by a processor, wherein a computer program is stored on the computer-readable medium, and when the computer program is executed by the processor, the steps of the method for printing the data item content of the above embodiment are executed.
[0122] The computer program product provided in the embodiment of the present invention includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the method described in the previous method embodiment. The specific implementation can be found in the method embodiment and will not be repeated here.
[0123] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0124] In addition, in the description of the embodiments of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0125] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.
[0126] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0127] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A method for printing data item content, characterized in that: The method comprises: Reading an XML file, wherein the XML file includes a form, and the form includes at least one data item content and a table area; Determining whether the content of the data item is dynamically printed; If yes, determining the content area according to the content of the data item; Determine whether the height of the content area exceeds the table area; If yes, adjusting the font size of the content area with the minimum font size to obtain a new content area; Calculate the number of pages according to the new content area and the table area; Determine whether the number of pages is greater than 1; If yes, split the data item content according to the minimum font size, and set the minimum font size as the first required font size; If not, the second required font size that is fully displayed in the table area is obtained by cyclically comparing the table area with the new content area.
2. The method for printing data item content according to claim 1, characterized in that: The method further comprises: Determining whether the font size of the form is consistent with the first required font size or the second required font size; If yes, printing according to the first required font size or the second required font size; If not, the font size of the form is reset.
3. The method for printing data item content according to claim 1, characterized in that: The determining of the content area according to the content of the data item comprises: The content area is determined according to the amount of content and font size of the data item.
4. The method for printing data item content according to claim 1, characterized in that: The determining whether the content of the data item is dynamically printed comprises: If not, the data item content is directly drawn and printed out.
5. The method for printing data item content according to claim 1, characterized in that: The determining whether the height of the content area exceeds the table area includes: If not, print out the data item content.
6. A device for printing data item content, characterized in that: The device comprises: A reading unit, used for reading an XML file, wherein the XML file includes a form, and the form includes at least one data item content and a table area; A first judging unit, used to judge whether the content of the data item is dynamically printed; A determination unit, configured to determine a content area according to the content of the data item when the content of the data item is the dynamic print; A second judging unit, used to judge whether the height of the content area exceeds the table area; An adjusting unit, configured to adjust the font size of the content area with a minimum font size to obtain a new content area when the height exceeds the table area; A calculation unit, used for calculating the number of pages according to the new content area and the table area; A third judging unit, used to judge whether the number of pages is greater than 1; a splitting unit, configured to split the data item content according to the minimum font size when the number of pages is greater than 1, and set the minimum font size to be the first required font size; The display unit is used for obtaining a second required font size that is fully displayed in the table area by cyclically comparing the table area with the new content area when the number of pages is not greater than 1.
7. The device for printing data item contents according to claim 6, characterized in that: The device also includes: a fourth determination unit, configured to determine whether the font size of the form is consistent with the first required font size or the second required font size; A printing unit, configured to print according to the first required font size or the second required font size when the two fonts are consistent; The setting unit is used to reset the font size of the form in case of inconsistency.
8. The device for printing data item contents according to claim 6, characterized in that: The determining unit is specifically used for: The content area is determined according to the amount of content and font size of the data item.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.
10. A computer readable medium having a non-volatile program code executable by a processor, characterized in that: The program code enables the processor to execute the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Standard file printing preview method and device, equipment and storage medium
CN110413954A