OFD fast generation method, system, electronic device and storage medium
By directly processing the XML files in the OFD file as ordinary text files, omitting the decompression and parsing process, the problem of low processing efficiency of OFD file in the prior art is solved, and more efficient OFD file generation is achieved.
Patent Information
- Application Number
- CN202110193589.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-20
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2041-02-20
AI Technical Summary
The existing OFD file processing methods are inefficient in adding image objects and text objects, and the process of decompressing, parsing and generating objects takes a long time.
By obtaining the template file for preprocessing, the XML file inside OFD is directly regarded as a normal text file, the process of decompression and parsing XML is omitted, and object generation and data writing is directly carried out.
It significantly improves the efficiency of OFD file generation, omitting the process of understanding the compression and parsing of documents and XML files, and improving the stability and efficiency of the system.
Smart Images

Figure CN112989780B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer software, and in particular to an OFD fast generation method, system, electronic device and storage medium. Background Art
[0002] OFD format document is a document format that is independent of software, hardware, operating system, and output device. It presents various digital content objects such as text, graphics, and images in a fixed layout according to certain rules. OFD uses XML technology to describe file data, and has the characteristics of truly maintaining the layout information such as text, charts, formulas, colors, etc. in the original file, and this characteristic should not change with changes in the software and hardware environment. Usually, the OFD file processing method is inefficient for adding image objects and text objects, and the decompression, parsing, and object generation are all relatively time-consuming. Summary of the invention
[0003] The technical problem to be solved by the present invention is to provide an OFD fast generation method, system, electronic device and storage medium in view of the deficiencies in the prior art.
[0004] The technical solution of the present invention to solve the above technical problem is as follows: A method for quickly generating OFD, comprising:
[0005] Step 1, obtaining a template file, preprocessing the template file, obtaining a plurality of files which are decompressed and saved to corresponding preset locations;
[0006] Step 2, obtaining the user's input information, generating a two-dimensional code image from the input information, and saving the two-dimensional code image in a data form into a first file corresponding to the multiple files;
[0007] Step 3, storing the text content of the input information in a character string form in a second file corresponding to the plurality of files;
[0008] Step 4: compress the multiple files including the first file and the second file to generate a complete OFD file.
[0009] The beneficial effects of the present invention are as follows: the OFD rapid template generation method mainly carries out targeted processing, abandons the steps of decompression, parsing, and object generation, and directly regards the XML file inside OFD as an ordinary text file. Object generation and data writing are all operations on text files, eliminating the process of parsing XML. This can greatly improve efficiency, and the process of decompression, document parsing, and XML file parsing are all omitted. In addition, the work that can be processed during initialization is processed during the initialization process of program startup. The process that needs to be dynamically processed in the middle only has the part that must be calculated. The organization of XML files also uses string concatenation instead of parsing. Therefore, stability and efficiency can be greatly improved.
[0010] Further, step 1 is specifically as follows:
[0011] Obtain a template file, decompress the template file to obtain n xml files, save the fixed files in the xml file in the form of a string in a first preset position, save the files with changes in the xml file in the form of a string in a second preset position, and save the files with undetermined changes in the xml file in the form of a preset result file in a third preset position.
[0012] The beneficial effect of adopting the above further solution is that the XML file in OFD is directly regarded as an ordinary text file, and object generation and data writing are all operations on text files, eliminating the process of parsing XML. This can significantly improve efficiency.
[0013] Further, step 4 is specifically as follows:
[0014] The file at the first preset position, the file at the second preset position, the file at the third preset position, the first file and the second file are integrated into a final file, and the final file is compressed to generate a complete OFD file.
[0015] The beneficial effect of adopting the above further solution is that storing files at fixed locations can not only effectively distinguish the categories of files but also quickly retrieve and generate them, thereby improving efficiency.
[0016] Furthermore, after step 3, the following steps are also included:
[0017] The electronic signature is stored in a fourth preset location in the form of signature data.
[0018] Another technical solution of the present invention to solve the above technical problem is as follows: an OFD rapid generation system, comprising:
[0019] An acquisition module is used to acquire a template file, pre-process the template file, and obtain a plurality of files which are decompressed and saved to a preset location accordingly;
[0020] A generating module, used for obtaining user input information, generating a two-dimensional code image from the input information, and saving the two-dimensional code image in a data form into a first file corresponding to the plurality of files;
[0021] A storage module, used for storing the text content of the input information in a character string form in a second file corresponding to the plurality of files;
[0022] The compression module is used to compress a plurality of files including the first file and the second file to generate a complete OFD file.
[0023] The beneficial effects of the present invention are as follows: the OFD rapid template generation method mainly carries out targeted processing, abandons the steps of decompression, parsing, and object generation, and directly regards the XML file inside OFD as an ordinary text file. Object generation and data writing are all operations on text files, eliminating the process of parsing XML. This can greatly improve efficiency, and the process of decompression, document parsing, and XML file parsing are all omitted. In addition, the work that can be processed during initialization is processed during the initialization process of program startup. The process that needs to be dynamically processed in the middle only has the part that must be calculated. The organization of XML files also uses string concatenation instead of parsing. Therefore, stability and efficiency can be greatly improved.
[0024] Furthermore, the acquisition module is specifically used for:
[0025] Obtain a template file, decompress the template file to obtain n xml files, save the fixed files in the xml file in the form of a string in a first preset position, save the files with changes in the xml file in the form of a string in a second preset position, and save the files with undetermined changes in the xml file in the form of a preset result file in a third preset position.
[0026] The beneficial effect of adopting the above further solution is that the XML file in OFD is directly regarded as an ordinary text file, and object generation and data writing are all operations on text files, eliminating the process of parsing XML. This can significantly improve efficiency.
[0027] Furthermore, the compression module is specifically used for:
[0028] The file at the first preset position, the file at the second preset position, the file at the third preset position, the first file and the second file are integrated into a final file, and the final file is compressed to generate a complete OFD file.
[0029] The beneficial effect of adopting the above further solution is that storing files at fixed locations can not only effectively distinguish the categories of files but also quickly retrieve and generate them, thereby improving efficiency.
[0030] Furthermore, the storage module is also used for:
[0031] The electronic signature is stored in a fourth preset location in the form of signature data.
[0032] Another technical solution of the present invention to solve the above technical problem is as follows: an electronic device, comprising a memory, a processor, and a vector stored in the memory and running on the processor, wherein when the processor executes the vector, an OFD fast generation method described in any one of the above items is implemented.
[0033] The beneficial effects of the present invention are as follows: the OFD rapid template generation method mainly carries out targeted processing, abandons the steps of decompression, parsing, and object generation, and directly regards the XML file inside OFD as an ordinary text file. Object generation and data writing are all operations on text files, eliminating the process of parsing XML. This can greatly improve efficiency, and the process of decompression, document parsing, and XML file parsing are all omitted. In addition, the work that can be processed during initialization is processed during the initialization process of program startup. The process that needs to be dynamically processed in the middle only has the part that must be calculated. The organization of XML files also uses string concatenation instead of parsing. Therefore, stability and efficiency can be greatly improved.
[0034] Another technical solution of the present invention to solve the above technical problem is as follows: a storage medium, in which instructions are stored, and when a computer reads the instructions, the computer executes any one of the above-mentioned OFD rapid generation methods.
[0035] The beneficial effects of the present invention are as follows: the OFD rapid template generation method mainly carries out targeted processing, abandons the steps of decompression, parsing, and object generation, and directly regards the XML file inside OFD as an ordinary text file. Object generation and data writing are all operations on text files, eliminating the process of parsing XML. This can greatly improve efficiency, and the process of decompression, document parsing, and XML file parsing are all omitted. In addition, the work that can be processed during initialization is processed during the initialization process of program startup. The process that needs to be dynamically processed in the middle only has the part that must be calculated. The organization of XML files also uses string concatenation instead of parsing. Therefore, stability and efficiency can be greatly improved.
[0036] Advantages of additional aspects of the present invention will be given in part in the following description, and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A schematic diagram of a process flow provided for an embodiment of an OFD rapid generation method of the present invention;
[0038] Figure 2 A structural framework diagram provided for an embodiment of an OFD rapid generation system of the present invention;
[0039] Figure 3 A schematic diagram of the internal structure of a template file after decompression provided in an embodiment of an OFD rapid generation method of the present invention;
[0040] Figure 4 A schematic diagram of the final form of a template file provided in an embodiment of an OFD rapid generation method of the present invention;
[0041] Figure 5 A schematic diagram of a bank electronic certificate provided in an embodiment of an OFD rapid generation method of the present invention;
[0042] In the accompanying drawings, the components represented by the reference numerals are listed as follows:
[0043] 100, acquisition module, 200, generation module, 300, storage module, 400, compression module. DETAILED DESCRIPTION
[0044] The principles and features of the present invention are described below in conjunction with the accompanying drawings. The examples given are only used to explain the present invention but not to limit the scope of the present invention.
[0045] like Figure 1 As shown, a method for quickly generating OFD includes:
[0046] Step 1, obtaining a template file, preprocessing the template file, obtaining multiple files that are decompressed and saved to a preset location;
[0047] Step 2, obtaining the user's input information, generating a QR code image from the input information, and saving the QR code image in a data form into a first file corresponding to the multiple files;
[0048] Step 3, storing the text content of the input information in a character string form in a second file corresponding to the plurality of files;
[0049] Step 4: compress the multiple files including the first file and the second file to generate a complete OFD file.
[0050] In some possible implementations, the OFD rapid template generation method mainly performs targeted processing, abandons the steps of decompression, parsing, and object generation, and directly regards the XML file inside OFD as an ordinary text file. Object generation and data writing are all operations on text files, eliminating the process of parsing XML. This can greatly improve efficiency, and the process of decompression, document parsing, and XML file parsing are all omitted. In addition, the work that can be processed during initialization is processed during the initialization process of program startup. The process that needs to be dynamically processed in the middle only has the part that must be calculated. The organization of XML files also uses string concatenation instead of parsing. Therefore, it can greatly improve stability and efficiency.
[0051] It should be noted that in the actual processing, there may be businesses that do not require QR codes. For businesses that do not require QR codes, the processes of generating QR codes and compressing QR codes can be omitted. That is, users can adjust whether to generate QR codes based on actual needs. Similarly, the electronic signatures mentioned below are also the same. For businesses that do not require electronic signatures, the processes of generating electronic signatures and compressing electronic signatures can be omitted. The OFD fast template generation method is mainly used on the server side and can provide multiple language interfaces. It can be called by c++, c#, java multi-threads and multi-processes under windows and linux. It decompresses OFD template files, such as electronic invoices, receipts and other files, and puts them in a fixed directory, such as the name Template. Its internal structure is as follows: Figure 3 As shown;
[0052] The preprocessing of template files includes:
[0053] 1) Read the relatively fixed XML file content in the template file into the memory and save it in the form of a string, such as OFD.xml and PublicRes.xml;
[0054] 2) Read the XML file contents that may change in the template file and whose results can be known in advance into the memory. Figure 5 For example, if the voucher does not need an electronic signature, OFD.xml will not change. That is, when it is saved, OFD.xml in the template file can be used directly. However, if the voucher needs an electronic signature, OFD.xml needs to be changed, and an additional description of the electronic signature reference is added. During initialization, the changed OFD.xml can also be read into the memory, for example, named OFD_Sign.xml, and saved. When saving, if there is a signature action, the content of OFD_Sign.xml is saved.
[0055] In addition to OFD.xml, other files that can know the result of changes in advance include Document.xml. The method is the same as OFD.xml. The changed XML file content is read into the memory in advance during initialization. When saving, it can be used directly.
[0056] 3) For XML files that will definitely change due to the addition of new data, and the final result of the change cannot be known in advance, the unchanged parts are read into the memory separately. For example, Template\Doc_0\Pages\Page_0\Content.xml, in the original Content.xml, describes the fixed information of the bank electronic certificate, such as the form, certificate number, issuing agency, etc. Image objects and text objects are added to this Content.xml. Content.xml can be divided into two parts and read into the memory and saved in the form of strings, recorded as m_wsXmlHead and m_wsXmlTail respectively. When adding image objects and text objects, the objects are provided in string form. The final Template\Doc_0\Pages\Page_0\Content.xml should be generated in the following form, where the objects are marked in the order of generation: m_wsXmlHead+m_wsImageObj1+...+m_wsImageObjN+m_wsTextObj1+...+m_wsTextObjN+m_wsXmlTail
[0057] For step 2, there is no XML file in the original OFD template file, but a new XML file is generated due to electronic signature, etc. For example, Template\Doc_0\Signs\Signatures.xml.
[0058] If these files are to be signed, they must be generated. The format of Signatures.xml is relatively fixed and has certain rules, and can be generated in the template folder in advance.
[0059] There is also a similar DocumentRes.xml. When adding a QR code image object, you need to generate DocumentRes.xml. You can mention this template folder to generate it.
[0060] For step 3, text object initialization. In the business, the most processing involved is the addition of text objects. Image objects are relatively few and their object descriptions are relatively simple, so they do not need to be processed during initialization. In each fixed template OFD file, the number of text objects that need to be added is certain. The position, font information, color, etc. of each object in the page are fixed and can be known in advance. Therefore, all the unchanged parts of the text objects can be read into the memory during initialization and saved as a string. When the text object is finally generated, you only need to connect the red fixed part string with the dynamically generated variable part string.
[0061] After the above processing, the final form of the template file is as follows Figure 4 shown.
[0062] For step 2, add the QR code object. The generation of the QR code object must be dynamic. Generate the QR code image according to the information entered by the customer, save the image content in the memory as memory data, and describe the resource in Template / Doc_0 / DocumentRes.xml, and add the description of the image object in Template\Doc_0\Pages\Page_0\Content.xml.
[0063] For step 3, add a description of the text object directly in Template\Doc_0\Pages\Page_0\Content.xml. The only part that needs to be calculated is DeltaX="1.587600 1.587600 1.587600 1.587600 3.1752001.587600 3.175200 1.587600 1.587600". This part of data needs to be calculated based on the font, and then stored in the form of a string, and connected with the fixed part string of the text object during the initialization process to generate a complete text object.
[0064] When all data operations have been completed, the electronic signature calculation is finally performed. The signature algorithm is used to calculate the XML file to be protected and generate Template\Doc_0\Signs\Sign_0\Signature.xml and the signature data file Template\Doc_0\Signs\Sign_0\SignedValue.dat.
[0065] Compress the final generated XML file, RES resource file, and signature-related files to generate the required OFD file.
[0066] Preferably, in any of the above embodiments, step 1 is specifically:
[0067] Obtain a template file, decompress the template file to obtain n xml files, save the fixed files in the xml file in the form of a string in a first preset location, save the files with changes in the xml file in the form of a string in a second preset location, and save the files with uncertain changes in the xml file in the form of a preset result file in a third preset location.
[0068] In some possible implementations, the XML file in OFD is directly regarded as an ordinary text file, and object generation and data writing are all operations on the text file, eliminating the process of parsing XML. This can significantly improve efficiency.
[0069] Preferably, in any of the above embodiments, step 4 is specifically:
[0070] The file at the first preset position, the file at the second preset position, the file at the third preset position, the first file and the second file are integrated into a final file, and the final file is compressed to generate a complete OFD file.
[0071] In some possible implementations, storing files at fixed locations can not only effectively distinguish file categories but also quickly retrieve and generate files, thereby improving efficiency.
[0072] Preferably, in any of the above embodiments, after step 3, the following steps are further included:
[0073] The electronic signature is stored in a fourth preset location in the form of signature data.
[0074] like Figure 2 As shown, an OFD rapid generation system includes:
[0075] The acquisition module 100 is used to acquire the template file, pre-process the template file, obtain multiple files after decompression and save them to the preset location;
[0076] A generating module 200 is used to obtain user input information, generate a two-dimensional code image from the input information, and save the two-dimensional code image in a data form into a first file corresponding to the plurality of files;
[0077] The storage module 300 is used to store the text content of the input information in a character string form in a corresponding second file in the plurality of files;
[0078] The compression module 400 is used to compress a plurality of files including the first file and the second file to generate a complete OFD file.
[0079] In some possible implementations, the OFD rapid template generation method mainly performs targeted processing, abandons the steps of decompression, parsing, and object generation, and directly regards the XML file inside OFD as an ordinary text file. Object generation and data writing are all operations on text files, eliminating the process of parsing XML. This can greatly improve efficiency, and the process of decompression, document parsing, and XML file parsing are all omitted. In addition, the work that can be processed during initialization is processed during the initialization process of program startup. The process that needs to be dynamically processed in the middle only has the part that must be calculated. The organization of XML files also uses string concatenation instead of parsing. Therefore, it can greatly improve stability and efficiency.
[0080] Preferably, in any of the above embodiments, the acquisition module 100 is specifically used for:
[0081] Obtain a template file, decompress the template file to obtain n xml files, save the fixed files in the xml file in the form of a string in a first preset location, save the files with changes in the xml file in the form of a string in a second preset location, and save the files with uncertain changes in the xml file in the form of a preset result file in a third preset location.
[0082] In some possible implementations, the XML file in OFD is directly regarded as an ordinary text file, and object generation and data writing are all operations on the text file, eliminating the process of parsing XML. This can significantly improve efficiency.
[0083] Preferably, in any of the above embodiments, the compression module 400 is specifically used for:
[0084] The file at the first preset position, the file at the second preset position, the file at the third preset position, the first file and the second file are integrated into a final file, and the final file is compressed to generate a complete OFD file.
[0085] In some possible implementations, storing files at fixed locations can not only effectively distinguish file categories but also quickly retrieve and generate files, thereby improving efficiency.
[0086] Preferably, in any of the above embodiments, the storage module 300 is further used for:
[0087] The electronic signature is stored in a fourth preset location in the form of signature data.
[0088] An electronic device comprises a memory, a processor and a vector stored in the memory and running on the processor, wherein when the processor executes the vector, any one of the above-mentioned OFD fast generation methods is implemented.
[0089] In some possible implementations, the OFD rapid template generation method mainly performs targeted processing, abandons the steps of decompression, parsing, and object generation, and directly regards the XML file inside OFD as an ordinary text file. Object generation and data writing are all operations on text files, eliminating the process of parsing XML. This can greatly improve efficiency, and the process of decompression, document parsing, and XML file parsing are all omitted. In addition, the work that can be processed during initialization is processed during the initialization process of program startup. The process that needs to be dynamically processed in the middle only has the part that must be calculated. The organization of XML files also uses string concatenation instead of parsing. Therefore, it can greatly improve stability and efficiency.
[0090] A storage medium stores instructions, and when a computer reads the instructions, the computer executes any one of the above-mentioned OFD rapid generation methods.
[0091] In some possible implementations, the OFD rapid template generation method mainly performs targeted processing, abandons the steps of decompression, parsing, and object generation, and directly regards the XML file inside OFD as an ordinary text file. Object generation and data writing are all operations on text files, eliminating the process of parsing XML. This can greatly improve efficiency, and the process of decompression, document parsing, and XML file parsing are all omitted. In addition, the work that can be processed during initialization is processed during the initialization process of program startup. The process that needs to be dynamically processed in the middle only has the part that must be calculated. The organization of XML files also uses string concatenation instead of parsing. Therefore, it can greatly improve stability and efficiency.
[0092] It can be understood that in some embodiments, some or all of the optional implementation modes in the above embodiments may be included.
[0093] It should be noted that the above embodiments are product embodiments corresponding to the previous method embodiments. For the description of the optional implementation methods in the product embodiments, reference can be made to the corresponding description in the above method embodiments, which will not be repeated here.
[0094] The reader should understand that in the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification and the features of different embodiments or examples without contradiction.
[0095] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the method embodiments described above are only illustrative, for example, the division of steps is only a logical function division, and there may be other division methods in actual implementation, such as multiple steps can be combined or integrated into another step, or some features can be ignored or not executed.
[0096] If the above method is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of 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 and other media that can store program codes.
[0097] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements 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 quickly generating OFD, characterized in that: include: Step 1, obtaining a template file, preprocessing the template file, obtaining a plurality of files which are decompressed and saved to corresponding preset locations; Step 2, obtaining the user's input information, generating a two-dimensional code image from the input information, and saving the two-dimensional code image in a data form into a first file corresponding to the multiple files; Step 3, storing the text content of the input information in a character string form in a second file corresponding to the plurality of files; Step 4, compressing the multiple files including the first file and the second file to generate a complete OFD file; Step 1 is as follows: Obtain a template file, decompress the template file to obtain n xml files, save the fixed files in the xml file in the form of a character string in a first preset location, save the files with changes in the xml file in the form of a character string in a second preset location, and save the files with undetermined changes in the xml file in the form of a preset result file in a third preset location; Step 4 is as follows: The file at the first preset position, the file at the second preset position, the file at the third preset position, the first file and the second file are integrated into a final file, and the final file is compressed to generate a complete OFD file.
2. The OFD rapid generation method according to claim 1, characterized in that: After step 3, also include: The electronic signature is stored in a fourth preset location in the form of signature data.
3. An OFD rapid generation system, characterized in that: include: An acquisition module is used to acquire a template file, pre-process the template file, and obtain a plurality of files which are decompressed and saved to a preset location accordingly; A generating module, used for obtaining user input information, generating a two-dimensional code image from the input information, and saving the two-dimensional code image in a data form into a first file corresponding to the plurality of files; A storage module, used for storing the text content of the input information in a character string form in a second file corresponding to the plurality of files; A compression module, used for compressing a plurality of files including the first file and the second file to generate a complete OFD file; The acquisition module is specifically used for: Obtain a template file, decompress the template file to obtain n xml files, save the fixed files in the xml file in the form of a character string in a first preset location, save the files with changes in the xml file in the form of a character string in a second preset location, and save the files with undetermined changes in the xml file in the form of a preset result file in a third preset location; The compression module is specifically used for: The file at the first preset position, the file at the second preset position, the file at the third preset position, the first file and the second file are integrated into a final file, and the final file is compressed to generate a complete OFD file.
4. The OFD rapid generation system according to claim 3, characterized in that: The storage module is also used to: The electronic signature is stored in a fourth preset location in the form of signature data.
5. An electronic device comprising a memory, a processor, and a vector stored in the memory and running on the processor, characterized in that: When the processor executes the vector, an OFD fast generation method as claimed in claim 1 or 2 is implemented.
6. A storage medium, characterized in that: The storage medium stores instructions, and when a computer reads the instructions, the computer executes the OFD fast generation method as claimed in claim 1 or 2.
Citation Information
Patent Citations
Method for converting file of preset format into OFD format
CN109977088A
Method and device for generating OFD format page based on XML template
CN111797595A