Image generation method and device, electronic equipment and storage medium
By obtaining the size of the invoice target area and the text content, the text format adjustment is performed to solve the problem of the Chinese characters that exceed the border of the electronic invoice image, and achieve better typesetting results.
Patent Information
- Application Number
- CN202411865314.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-01-21
- Estimated Expiration
- Not applicable · inactive patent
Smart Images

Figure CN119338950A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to an image generating method, device, electronic device and storage medium. Background Art
[0002] With the rapid development of information technology and the rise of new formats such as e-commerce and online payment, the transaction mode between enterprises has undergone profound changes. Traditional paper invoices can no longer meet the needs of modern financial management due to their easy loss, inconvenience in query, high storage cost and other problems.
[0003] As a new form of invoice, electronic invoice has been widely promoted and applied due to its convenient storage, query, transmission and anti-counterfeiting features. In the process of generating electronic invoice images, the existing technology usually uses a fixed font size to fill the text content. Although this method is effective in simple applications, when it is necessary to display multiple lines of text or long paragraphs, the fixed font size often causes the text content to exceed the invoice image boundary, resulting in a chaotic layout of the electronic invoice image. Summary of the invention
[0004] The present invention provides an image generation method, device, electronic device and storage medium to solve the problem that text content exceeds the boundary of an invoice image.
[0005] According to one aspect of the present invention, there is provided an image generation method, comprising:
[0006] Obtaining the invoice target area to be filled with text, and determining the width and height of the invoice target area;
[0007] Obtain the text content to be filled into the target area of the invoice, and determine the width and height of the text content;
[0008] Adjusting the text format based on the width and height of the invoice target area and the width and height of the text content;
[0009] When the width of the text content after the text format is adjusted is not greater than the width of the invoice target area, and the height of the text content after the text format is adjusted is not greater than the height of the invoice target area, the text content after the text format is adjusted is filled into the invoice target area to obtain a target invoice image.
[0010] According to another aspect of the present invention, there is provided an image generating device, comprising:
[0011] An invoice target area size determination module is used to obtain an invoice target area to be filled with text and determine the width and height of the invoice target area;
[0012] A text content size determination module, used to obtain the text content to be filled into the target area of the invoice, and determine the width and height of the text content;
[0013] A text format adjustment module, used for adjusting the text format based on the width and height of the invoice target area and the width and height of the text content;
[0014] The target invoice image generating module is used to fill the text content after the text format is adjusted into the invoice target area to obtain the target invoice image when the width of the text content after the text format is adjusted is not greater than the width of the invoice target area and the height of the text content after the text format is adjusted is not greater than the height of the invoice target area.
[0015] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0016] at least one processor;
[0017] and a memory communicatively coupled to the at least one processor;
[0018] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the image generating method described in any embodiment of the present invention.
[0019] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the image generation method described in any embodiment of the present invention when executed.
[0020] The technical solution of the embodiment of the present invention obtains the invoice target area to be filled with text, determines the width and height of the invoice target area, and then obtains the text content to be filled in the invoice target area, determines the width and height of the text content, and then adjusts the text format based on the width and height of the invoice target area and the width and height of the text content. When the width of the text content after the text format adjustment is not greater than the width of the invoice target area, and the height of the text content after the text format adjustment is not greater than the height of the invoice target area, the text content after the text format adjustment is filled into the invoice target area to obtain the target invoice image. The above technical solution adjusts the text format through size comparison, realizes dynamic adjustment of the text content, ensures that the text content does not exceed the invoice target area, and improves the display effect of the invoice image.
[0021] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0023] Figure 1 is a flowchart of an image generating method provided according to Embodiment 1 of the present invention;
[0024] Figure 2 is a flowchart of an image generating method provided according to Embodiment 2 of the present invention;
[0025] Figure 3 is a flowchart of an image generating method provided according to Embodiment 3 of the present invention;
[0026] Figure 4 is a structural schematic diagram of an image generating device provided according to a fourth embodiment of the present invention;
[0027] Figure 5 It is a schematic diagram of the structure of an electronic device for implementing the image generating method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0028] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only 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 should fall within the scope of protection of the present invention.
[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices. The acquisition, storage, use, processing, etc. of data in the technical solution of this application comply with the relevant provisions of national laws and regulations.
[0030] Embodiment 1
[0031] Figure 1 This is a flowchart of an image generation method provided in the first embodiment of the present invention. This embodiment is applicable to the case of dynamically adjusting the text format of an electronic invoice. The method can be executed by an image generation device, which can be implemented in the form of hardware and / or software. The image generation device can be configured in an electronic device such as a terminal or a server. Figure 1 As shown, the method includes:
[0032] S110, obtaining an invoice target area to be filled with text, and determining the width and height of the invoice target area.
[0033] In the embodiment of the present invention, the invoice target area may be a purchaser information display area, a seller information display area, a password information display area, or a note information display area, etc., which is not specifically limited here.
[0034] Exemplarily, the border of the purchaser information display area of the electronic invoice is identified to obtain the width and height of the purchaser information display area. The same is true for other areas, which will not be elaborated here.
[0035] S120, obtaining text content to be filled into the target area of the invoice, and determining the width and height of the text content.
[0036] In the embodiment of the present invention, the text content may be a password, user name, taxpayer identification number, address, telephone number, bank account opening bank and account number, etc., which is not specifically limited here.
[0037] Exemplarily, the text content to be filled in the target area of the invoice can be read from a preset file path, and then the size of the text content at the initial font size can be identified through the imagettfbbox function or other size measurement functions to obtain the width and height of the text content, wherein the initial font size can be 40px or other font sizes, which are not specifically limited here. It should be noted that 40px is a large font compared to other fonts, and font adjustment starting from a large font helps to improve the adaptability of text in the image.
[0038] S130: Adjust the text format based on the width and height of the invoice target area and the width and height of the text content.
[0039] S140. When the width of the text content after the text format is adjusted is not greater than the width of the invoice target area, and the height of the text content after the text format is adjusted is not greater than the height of the invoice target area, fill the text content after the text format is adjusted into the invoice target area to obtain a target invoice image.
[0040] In the embodiment of the present invention, by comparing the size of the invoice target area with the text content, the text content after the text format adjustment is filled into the invoice target area while ensuring that the text content does not exceed the invoice target area, so as to maintain the readability and aesthetics of the electronic invoice image. The target invoice image refers to the electronic invoice image with the text content drawn.
[0041] The technical solution of the embodiment of the present invention obtains the invoice target area to be filled with text, determines the width and height of the invoice target area, and then obtains the text content to be filled in the invoice target area, determines the width and height of the text content, and then adjusts the text format based on the width and height of the invoice target area and the width and height of the text content. When the width of the text content after the text format adjustment is not greater than the width of the invoice target area, and the height of the text content after the text format adjustment is not greater than the height of the invoice target area, the text content after the text format adjustment is filled into the invoice target area to obtain the target invoice image. The above technical solution adjusts the text format through size comparison, realizes dynamic adjustment of the text content, ensures that the text content does not exceed the invoice target area, reduces the complexity of manual adjustment, and improves the display effect of the invoice image.
[0042] Embodiment 2
[0043] Figure 2A flowchart of an image generation method provided for Embodiment 2 of the present invention, the method of this embodiment can be combined with the various optional schemes in the image generation method provided in the above embodiments. The image generation method provided in this embodiment is further optimized. Optionally, the text format adjustment based on the width and height of the invoice target area and the width and height of the text content includes: adjusting the font size based on the width and height of the invoice target area and the width and height of the text content; and / or adjusting the text line break based on the width and height of the invoice target area and the width and height of the text content.
[0044] like Figure 2 As shown, the method includes:
[0045] S210: Acquire an invoice target area to be filled with text, and determine the width and height of the invoice target area.
[0046] S220: Obtain text content to be filled into the target area of the invoice, and determine the width and height of the text content.
[0047] S230, adjusting the font size based on the width and height of the invoice target area and the width and height of the text content; and / or adjusting the text line break based on the width and height of the invoice target area and the width and height of the text content.
[0048] S240: When the width of the text content after the text format is adjusted is not greater than the width of the invoice target area, and the height of the text content after the text format is adjusted is not greater than the height of the invoice target area, fill the text content after the text format is adjusted into the invoice target area to obtain a target invoice image.
[0049] In the embodiment of the present invention, the font size and / or line wrapping of the text content may be adjusted so that the text content does not exceed the invoice target area, thereby improving the display effect of the invoice image.
[0050] Optionally, the font size is adjusted based on the width and height of the invoice target area and the width and height of the text content, including: if the width of the text content is larger than the width of the invoice target area, the font size of the text content is reduced until the width of the text content is no larger than the width of the invoice target area, and the font size of the text content is stopped; and / or, if the height of the text content is larger than the height of the invoice target area, the font size of the text content is reduced until the height of the text content is no larger than the height of the invoice target area, and the font size of the text content is stopped.
[0051] It is understandable that if the width of the text content is greater than the width of the invoice target area, or the height of the text content is greater than the height of the invoice target area, it means that the text content has exceeded the invoice target area, and the font size of the text content needs to be reduced, thereby reducing the overall width of the text content or the overall height of the text content, so as to arrange the text content within the invoice target area.
[0052] Exemplarily, if the width of the text content is greater than the width of the invoice target area, the font size of the text content is cyclically reduced until the width of the text content is no greater than the width of the invoice target area, and the font size reduction of the text content is stopped.
[0053] In some optional embodiments, the height of the text content may be the height of all lines. Specifically, the height of a single line of text may be calculated by imagettfbbox, and then the height of the single line of text may be multiplied by the number of lines to obtain the height of the text content.
[0054] Optionally, text line wrapping is adjusted based on the width and height of the invoice target area and the width and height of the text content, including: segmenting the text content to obtain multiple words in the text content; adding the multiple words in the text content to the current line character string in sequence, and when the width of the current line character string is greater than the width of the invoice target area, adding the excess text in the current line character string to the next line character string, and continuing to add the remaining words to the next line character string.
[0055] In the embodiment of the present invention, the word may be Arabic numerals, English letters, Chinese characters, symbols or a combination of the above, which is not specifically limited here. The current line character string refers to a character string used to store the text content of the current line.
[0056] Exemplarily, the text content can be segmented based on spaces or punctuation marks to obtain multiple words in the text content, and the multiple words in the text content are stored in a word list so that the words can be added to the current line string one by one for line break judgment. Further, an empty string, that is, the current line string, is initialized to store the text content of the current line. Further, the word list is traversed to add multiple words to the current line string in sequence. Further, the width of the current line string is calculated. When the width of the current line string is greater than the width of the invoice target area, it indicates that the current line string exceeds the width of the invoice target area, and the current line string can be saved in a line list, wherein the line list is used to save the text content of all lines, and then the excess text in the current line string is added to the next line string, and the remaining words are continued to be added to the next line string.
[0057] Optionally, adding the excess text in the current line of string to the next line of string includes: determining the excess spaces and / or punctuation marks in the current line of string; and adding the text after the excess spaces and / or punctuation marks in the current line of string to the next line of string.
[0058] The punctuation marks may be commas, semicolons, and periods, etc., which are not specifically limited here. It should be noted that by giving priority to line breaks with spaces and / or punctuation marks, it is possible to ensure that the end of a line ends with a complete word or punctuation mark, thereby increasing the readability of the text layout content.
[0059] Optionally, the excess text in the current line of string is added to the next line of string, including: if the excess text in the current line of string is the remaining content of the target word, the target word is truncated, and the remaining content of the truncated target word is added to the next line of string.
[0060] The target word may be a long word that cannot be fully displayed in the current line. It should be noted that by truncating and wrapping the long word, the neatness of the text layout can be ensured.
[0061] The technical solution of the embodiment of the present invention can adjust the font size and / or the text line break of the text content so that the text content does not exceed the invoice target area, thereby improving the display effect of the invoice image.
[0062] Embodiment 3
[0063] Figure 3 A flowchart of an image generation method provided for Embodiment 3 of the present invention, the method of this embodiment can be combined with the various optional schemes in the image generation method provided in the above embodiments. The image generation method provided in this embodiment is further optimized. Optionally, the text content after the text format is adjusted is filled into the invoice target area to obtain the target invoice image, including: determining the initial coordinates for drawing the text content; taking the initial coordinates for drawing the text content as the starting point, drawing the text content after the text format is adjusted line by line into the invoice target area to obtain the target invoice image.
[0064] like Figure 3 As shown, the method includes:
[0065] S310: Acquire an invoice target area to be filled with text, and determine the width and height of the invoice target area.
[0066] S320, obtaining text content to be filled into the target area of the invoice, and determining the width and height of the text content.
[0067] S330: Adjust the text format based on the width and height of the invoice target area and the width and height of the text content.
[0068] S340. When the width of the text content after the text format is adjusted is not greater than the width of the invoice target area, and the height of the text content after the text format is adjusted is not greater than the height of the invoice target area, determine the initial coordinates for drawing the text content, and use the initial coordinates for drawing the text content as a starting point to draw the text content after the text format is adjusted line by line to the invoice target area to obtain a target invoice image.
[0069] In the embodiment of the present invention, the initial coordinates for drawing the text content may be the upper left corner position or other vertex positions of the invoice target area, which is not specifically limited here.
[0070] Exemplarily, the initial coordinates for drawing the text content can be (startX, startY); the initial x coordinate can be set: x=startX, and the initial y coordinate can be set: y=startY. After each line is drawn, the y coordinate is incremented: y=y+lineHeight to ensure that the next line of text is displayed below the current line of text, where lineHeight represents the height of a single line of text. Further, the imagettftext or drawText function is used to draw the text content line by line, and each line of text content in the line list is drawn sequentially into the invoice target area. During the line-by-line drawing process, the starting drawing position of each line can be determined by x and y. After all lines of text are drawn, the target invoice image can be saved to a specified path or displayed on the screen.
[0071] The technical solution of the embodiment of the present invention determines the initial coordinates for drawing the text content; takes the initial coordinates for drawing the text content as the starting point, and draws the text content with the text format adjusted line by line to the invoice target area, thereby achieving accurate typesetting of the text content and improving the display effect of the invoice image.
[0072] Embodiment 4
[0073] Figure 4 This is a schematic diagram of the structure of an image generating device provided by Embodiment 4 of the present invention. Figure 4 As shown, the device comprises:
[0074] The invoice target area size determination module 410 is used to obtain the invoice target area to be filled with text and determine the width and height of the invoice target area;
[0075] The text content size determination module 420 is used to obtain the text content to be filled into the target area of the invoice and determine the width and height of the text content;
[0076] A text format adjustment module 430, used to adjust the text format based on the width and height of the invoice target area and the width and height of the text content;
[0077] The target invoice image generation module 440 is used to fill the text content after the text format is adjusted into the invoice target area to obtain the target invoice image when the width of the text content after the text format is adjusted is not greater than the width of the invoice target area and the height of the text content after the text format is adjusted is not greater than the height of the invoice target area.
[0078] The technical solution of the embodiment of the present invention obtains the invoice target area to be filled with text, determines the width and height of the invoice target area, and then obtains the text content to be filled in the invoice target area, determines the width and height of the text content, and then adjusts the text format based on the width and height of the invoice target area and the width and height of the text content. When the width of the text content after the text format adjustment is not greater than the width of the invoice target area, and the height of the text content after the text format adjustment is not greater than the height of the invoice target area, the text content after the text format adjustment is filled into the invoice target area to obtain the target invoice image. The above technical solution adjusts the text format through size comparison, realizes dynamic adjustment of the text content, ensures that the text content does not exceed the invoice target area, and improves the display effect of the invoice image.
[0079] In some optional implementations, the text format adjustment module 430 includes:
[0080] A font size adjustment unit, used for adjusting the font size based on the width and height of the invoice target area and the width and height of the text content;
[0081] And / or, a text line break adjustment unit, used to adjust the text line break based on the width and height of the invoice target area and the width and height of the text content.
[0082] In some optional implementations, the font size adjustment unit is specifically configured to:
[0083] If the width of the text content is greater than the width of the invoice target area, the font size of the text content is reduced until the width of the text content is no greater than the width of the invoice target area, and the font size of the text content is stopped from being adjusted;
[0084] And / or, if the height of the text content is greater than the height of the invoice target area, the font size of the text content is reduced until the height of the text content is no greater than the height of the invoice target area, and the font size of the text content is stopped from being adjusted.
[0085] In some optional implementations, the text line break adjustment unit includes:
[0086] A text content segmentation subunit, used to segment the text content to obtain a plurality of words in the text content;
[0087] The current line word adding subunit is used to add multiple words in the text content to the current line string in sequence.
[0088] The line break judgment subunit is used to add the excess text in the current line string to the next line string when the width of the current line string is greater than the width of the invoice target area, and continue to add the remaining words to the next line string.
[0089] In some optional implementations, the line break determination subunit is specifically used to:
[0090] Determine the spaces and / or punctuation marks exceeding the current line character string;
[0091] The characters following the spaces and / or punctuation marks in the current line of character string are added to the next line of character string.
[0092] In some optional implementations, the line break determination subunit is further specifically used for:
[0093] If the excess text in the current line of character string is the remaining content of the target word, the target word is truncated, and the remaining content of the target word obtained by truncation is added to the next line of character string.
[0094] In some optional implementations, the target invoice image generation module 440 may also be used to:
[0095] Determine the initial coordinates for drawing the text content;
[0096] Taking the initial coordinates for drawing the text content as a starting point, the text content after the text format is adjusted is drawn line by line to the invoice target area to obtain a target invoice image.
[0097] The image generating device provided in the embodiment of the present invention can execute the image generating method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0098] Embodiment 5
[0099] Figure 5A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0100] like Figure 5 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The I / O interface 15 is also connected to the bus 14.
[0101] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0102] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as an image generation method, which includes:
[0103] Obtaining the invoice target area to be filled with text, and determining the width and height of the invoice target area;
[0104] Obtain the text content to be filled into the target area of the invoice, and determine the width and height of the text content;
[0105] Adjusting the text format based on the width and height of the invoice target area and the width and height of the text content;
[0106] When the width of the text content after the text format is adjusted is not greater than the width of the invoice target area, and the height of the text content after the text format is adjusted is not greater than the height of the invoice target area, the text content after the text format is adjusted is filled into the invoice target area to obtain a target invoice image.
[0107] In some embodiments, the image generation method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the image generation method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the image generation method in any other appropriate manner (e.g., by means of firmware).
[0108] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0109] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0110] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0111] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0112] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0113] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0114] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0115] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. An image generation method, characterized in that: include: Obtaining the invoice target area to be filled with text, and determining the width and height of the invoice target area; Obtain the text content to be filled into the target area of the invoice, and determine the width and height of the text content; Adjusting the text format based on the width and height of the invoice target area and the width and height of the text content; When the width of the text content after the text format is adjusted is not greater than the width of the invoice target area, and the height of the text content after the text format is adjusted is not greater than the height of the invoice target area, the text content after the text format is adjusted is filled into the invoice target area to obtain a target invoice image.
2. The method according to claim 1, characterized in that The text format adjustment based on the width and height of the invoice target area and the width and height of the text content includes: Adjusting the font size based on the width and height of the invoice target area and the width and height of the text content; And / or, adjusting the text line break based on the width and height of the invoice target area and the width and height of the text content.
3. The method according to claim 2, characterized in that The adjusting the font size based on the width and height of the invoice target area and the width and height of the text content includes: If the width of the text content is greater than the width of the invoice target area, the font size of the text content is reduced until the width of the text content is no greater than the width of the invoice target area, and the font size of the text content is stopped from being adjusted; And / or, if the height of the text content is greater than the height of the invoice target area, the font size of the text content is reduced until the height of the text content is no greater than the height of the invoice target area, and the font size of the text content is stopped from being adjusted.
4. The method according to claim 2, characterized in that: The text line break adjustment based on the width and height of the invoice target area and the width and height of the text content includes: Segmenting the text content to obtain multiple words in the text content; Add multiple words in the text content to the current line string in sequence; When the width of the current line of character string is greater than the width of the invoice target area, the excess words in the current line of character string are added to the next line of character string, and the remaining words are added to the next line of character string.
5. The method according to claim 4, characterized in that The step of adding the excess text in the current line of character string to the next line of character string includes: Determine the spaces and / or punctuation marks exceeding the current line character string; The characters following the spaces and / or punctuation marks in the current line of character string are added to the next line of character string.
6. The method according to claim 4, characterized in that The step of adding the excess text in the current line of character string to the next line of character string includes: If the excess text in the current line of character string is the remaining content of the target word, the target word is truncated, and the remaining content of the target word obtained by truncation is added to the next line of character string.
7. The method according to claim 1, characterized in that The step of filling the text content after the text format adjustment into the invoice target area to obtain the target invoice image includes: Determine the initial coordinates for drawing the text content; Taking the initial coordinates for drawing the text content as a starting point, the text content after the text format is adjusted is drawn line by line to the invoice target area to obtain a target invoice image.
8. An image generating device, characterized in that: include: An invoice target area size determination module is used to obtain an invoice target area to be filled with text and determine the width and height of the invoice target area; A text content size determination module, used to obtain the text content to be filled into the target area of the invoice, and determine the width and height of the text content; A text format adjustment module, used for adjusting the text format based on the width and height of the invoice target area and the width and height of the text content; The target invoice image generating module is used to fill the text content after the text format is adjusted into the invoice target area to obtain the target invoice image when the width of the text content after the text format is adjusted is not greater than the width of the invoice target area and the height of the text content after the text format is adjusted is not greater than the height of the invoice target area.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively coupled to the at least one processor; The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the image generation method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the image generation method according to any one of claims 1 to 7 when executed.
Citation Information
Patent Citations
Form processing system, ocr device, form creation device, and form procrssing method
CN102331914A
Image privacy processing method, computing equipment and storage medium
CN112381702A
Document generation method and device, equipment and storage medium
CN114462371A
Table generation method and device, electronic equipment and storage medium
CN116311300A
Text display method and device, electronic equipment and storage medium
CN117311875A