Document operating system based on document object model
Through the document operating system based on the document object model, the problem that the existing Chinese document generation does not meet the court format requirements is solved, and dynamically generates documents that meet the format requirements is realized, template editing is simplified and operation convenience and system performance are improved.
Patent Information
- Application Number
- CN202411332998.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2025-01-03
AI Technical Summary
The existing solution to convert Word files based on HTML templates has caused the document generation to not meet the court format requirements, and developers need to manually configure containers, which is difficult and labor-intensive.
Using a document operating system based on the document object model, including acquisition module, parsing module, data storage module and document management module, the Word document data is replaced by the Aspose.Word interface to replace the placeholder in the template, providing drag-and-drop canvas area and attributes Panel, supports paragraphs, loops, judgments, table nodes, and adds exception capture mechanisms at key operations.
It realizes dynamic generation of documents that meet format requirements, simplifies template editing, and improves the operational convenience and system performance of business personnel.
Smart Images

Figure CN119248163A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of document generation, and in particular to a document operating system based on a document object model. Background Art
[0002] With the construction and improvement of my country's rule of law society, my country's requirements for judicial trials are becoming higher and higher, and at the same time, high requirements are placed on the efficiency of generating judgment documents. To this end, the judge can summarize the judgment documents of basic cases and typical cases under each type of case in advance, and provide a general template for the judgment documents of each type of case.
[0003] Most of the current implementations of generating court documents are based on converting HTML templates to Word. This solution has two main problems: first, HTML template maintenance is based on a rich text edit box, which may not be visible to the naked eye, but in fact there is a problem with the structure of the template content, resulting in abnormal document generation; second, after the HTML template is converted into a Word file, the style of the HTML file is fundamentally different from the style of the Word file, resulting in a large difference between the style of the HTML file and the expected style, which does not meet the court's document format requirements. When developers or professional business personnel maintain the template, they need to manually configure each container to build a complete document template, which is difficult and labor-intensive.
[0004] Therefore, it is necessary to provide a new document operating system based on the document object model to solve the above technical problems. Summary of the invention
[0005] In order to solve the technical problem that the current implementation of generating court documents does not meet the court's document format requirements, when developers or professional business personnel maintain templates, they need to manually configure each container to build a complete document template, which is difficult and labor-intensive. The present invention provides a document operating system based on a document object model.
[0006] The document operating system based on the document object model provided by the present invention includes:
[0007] Acquisition module, used to obtain word documents;
[0008] Parsing module, used to parse the data content of word documents;
[0009] A data storage module, used to store the document template and the parsed data into a database;
[0010] The document management module is used to edit document content online, generate a draggable canvas area, set container nodes and property panels in the canvas area, call the document template stored in the database, replace the placeholders in the document template with the data content of the word document through the interface of the Aspose.word document object model, save the required document configuration, and finally output the document. The container nodes include paragraphs, loops, judgments, and tables, where other nodes can be added, and the style of the container or the style of other contents in the container can be set. The property panel displays the properties of the selected container, such as text content, style settings, logical conditions, etc.
[0011] Furthermore, the canvas area includes global styles, feature settings, container node addition, word text import, document preview and source code editing.
[0012] Furthermore, the container nodes include paragraph container nodes, loop container nodes, decision container nodes and table container nodes.
[0013] Furthermore, the document generation process also includes adding an exception capture mechanism at key operations. By adding exception capture logic at key operations, it can ensure that the system can handle problems in a timely manner and give appropriate prompts, thereby improving the user experience.
[0014] Furthermore, the way to obtain the word document is to obtain the document from the user using a file upload API.
[0015] Furthermore, parsing the data content of the word document includes traversing the document using Aspose.Words to extract text, tables, image information, styles and formats.
[0016] Furthermore, when calling the document template, the File.ReadAllTextAsync method is used to asynchronously read the file content.
[0017] Furthermore, the XDocument.SaveAsync method is used to asynchronously save the document when saving the required document configuration.
[0018] Furthermore, when parsing the data content of the word document and replacing the placeholders in the document, the Task.Run method is used to put the entire process into a background thread for execution.
[0019] Furthermore, when the document management module needs to process the generation of multiple document templates, multi-threaded access is used to limit concurrency, thereby improving the responsiveness and performance of the system.
[0020] Compared with the related art, the document operating system based on the document object model provided by the present invention has the following beneficial effects:
[0021] 1. The present invention generates a draggable canvas area, sets a container node and a property panel in the canvas area, calls a document template stored in a database, and replaces the placeholder in the document template with the data content of the word document through the interface of the Aspose.word document object model. It can operate the word file well, dynamically add paragraphs, tables, texts and other contents, and automatically generate the correct style.
[0022] 2. The present invention can import the document template provided by the court into the system by importing the word document. The system will first parse the word content and convert it into the current data structure. The business personnel can then edit the converted template, which will save a lot of work for the business personnel.
[0023] 3. The document preview and source code editing are set in the canvas area of the present invention, and the template can be directly edited by coding, thereby improving the operational convenience of professionals. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 A structural block diagram of a document operating system based on a document object model provided by the present invention;
[0025] Figure 2 The effect diagram of the canvas area provided by the present invention;
[0026] Figure 3 The effect diagram of the paragraph container node provided by the present invention;
[0027] Figure 4 The effect diagram of the loop container node provided by the present invention;
[0028] Figure 5 The effect diagram of determining container nodes provided by the present invention;
[0029] Figure 6 This is an effect diagram of the table container node provided by the present invention. DETAILED DESCRIPTION
[0030] The present invention will be further described below in conjunction with the accompanying drawings and implementation modes.
[0031] Please refer to Figure 1 , Figure 2 , Figure 3 , Figure 4 , Figure 5 as well as Figure 6 ,in, Figure 1 A structural block diagram of a document operating system based on a document object model provided by the present invention; Figure 2 The effect diagram of the canvas area provided by the present invention; Figure 3 The effect diagram of the paragraph container node provided by the present invention; Figure 4 The effect diagram of the loop container node provided by the present invention; Figure 5 The effect diagram of determining container nodes provided by the present invention; Figure 6 This is an effect diagram of the table container node provided by the present invention.
[0032] In the specific implementation process, Figure 1-Figure 2 As shown, the document operating system based on the document object model includes:
[0033] The acquisition module is used to acquire the word document by using the file upload API to obtain the document from the user;
[0034] Parsing module, used to parse the data content of word documents. Parsing the data content of word documents includes using Aspose.Words to traverse the document and extract text, tables, picture information, styles and formats;
[0035] Among them, text information: extract the text content of paragraphs, titles, headers, footers, etc.;
[0036] Table information: extract the number of rows, columns, cell contents, etc. of the table;
[0037] Image information: extract image attributes such as size, format, resolution, and the image's location in the document;
[0038] Style and format: extract the text's font, size, color, bold, italic and other style information, as well as paragraph indentation, line spacing and other format information;
[0039] A data storage module, used to store the document template and the parsed data into a database;
[0040] The document management module is used to edit the document content online, generate a draggable canvas area, set container nodes and property panels in the canvas area, call the document template stored in the database, replace the placeholder in the document template with the data content of the word document through the interface of the Aspose.word document object model, save the required document configuration, and finally output the document. The container nodes include paragraphs, loops, judgments, and tables, in which other nodes can be added, and the style of the container or other content in the container can be set;
[0041] refer to Figure 3As shown, the paragraph container node is a basic container, in which you can add various content nodes, such as file nodes, variable nodes, function nodes, image nodes, and some special content nodes (such as page breaks, electronic signatures, etc.). In addition, it can also support setting the overall style of the paragraph, or setting the style of the content nodes in it in a targeted manner;
[0042] refer to Figure 4 As shown, the loop container node is a container with traversable characteristics, which is used to generate repetitive content. For example, if you want to add all the defendant information of the case to the document, you need to use the loop container node. The object it traverses is the defendant list. As a "container", it can also add other nodes.
[0043] refer to Figure 5 As shown, the judgment container node is a container with Boolean judgment characteristics, which is used to generate branched document content. For example, when the defendant of the case is a natural person, the content related to the natural person is output, otherwise the content related to the enterprise is output. In addition, the judgment logic can be added dynamically and can support the combination of multiple conditions to achieve conditional judgments similar to: if x=A then...elseif x=B then...else if x=C then...else...end;
[0044] refer to Figure 6 As shown, the table container node is a container for dynamically generating tables in documents. The table container is slightly special compared to other containers. Only some specific containers can be added inside it, such as loop containers and "row containers". Adding a loop container in a table container is mainly to deal with some scenarios where rows need to be added dynamically, such as outputting all the defendant's loan information in the document, and each loan contract is displayed in one line. In this case, a loop container is needed, and the loop object is the defendant's loan contract.
[0045] As a table, there is also a need to merge cells, so the configuration logic for merging cells is also designed.
[0046] In addition, for the sake of user experience, in order to allow business personnel to view the configuration effects in a timely manner when configuring the table container, a preview function is added so that they can check whether the configured part meets their expectations during configuration.
[0047] The user completes the configuration of the required document template by adding or editing various container nodes required for the document template on the canvas, and adding specific content or logic (loop traversal, Boolean judgment, and custom function writing) in these container nodes. After completing the configuration, the user submits and saves the document template to make it persistent.
[0048] Furthermore, the canvas area includes global styles, feature settings, container node addition, word text import, document preview and source code editing. Among them, source code editing is aimed at developers or more professional business personnel. Professionals can click the [Source Code] button above the edit box to enter the coding interface and directly edit the template through coding, thereby improving the operational convenience of professionals.
[0049] It should be further explained that the document generation process also includes adding exception catching mechanisms at key operations, such as: exception catching when reading template files (file does not exist, file is damaged), exception catching when saving generated documents (insufficient disk space, insufficient file permissions), exception catching when parsing data (format error, missing data), and exception catching when replacing placeholders (data type mismatch). By adding exception catching logic at key operations, it can be ensured that the system can handle problems in a timely manner and give appropriate prompts, thereby improving the user experience.
[0050] It should be noted that when calling the document template, the File.ReadAllTextAsync method is used to asynchronously read the file content;
[0051] Use the XDocument.SaveAsync method to save the document asynchronously when saving the required document configuration;
[0052] When parsing the data content of the word document and replacing the placeholders in the document, use the Task.Run method to put the entire process into the background thread for execution, forming a complete asynchronous document generation;
[0053] Using an asynchronous programming model for time-consuming operations can avoid blocking the main thread and improve the responsiveness and performance of the system.
[0054] The document generation process is as follows:
[0055] The user completes the configuration of the required document template by adding or editing various container nodes required for the document template on the canvas, and adding specific content or logic (loop traversal, Boolean judgment, and custom function writing) in these container nodes. After completing the configuration, the user submits and saves the document to persist the document template. At this time, the saved document template data structure is close to Aspose.word. When generating a document, the system component backend will read the template data structure, parse each node (container node, content node), and then render the word file through the Aspose.word interface to finally output the document.
[0056] Furthermore, when the document management module needs to process the generation of multiple document templates, multi-threaded access is used to limit concurrency and avoid excessive consumption of system resources.
[0057] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0058] The above shows and describes the basic principles and main features of the present invention and the advantages of the present invention. For those skilled in the art, it is obvious that the present invention is not limited to the details of the above exemplary embodiments, and the present invention can be implemented in other specific forms without departing from the spirit or basic features of the present invention. Therefore, no matter from which point of view, the embodiments should be regarded as exemplary and non-restrictive. The scope of the present invention is defined by the attached claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention, and any figure mark in the claims should not be regarded as limiting the claims involved.
[0059] In addition, it should be understood that although the present specification is described according to implementation modes, not every implementation mode contains only one independent technical solution. This description of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment may also be appropriately combined to form other implementation modes that can be understood by those skilled in the art.
Claims
1. A document operating system based on a document object model, characterized in that: include: Acquisition module, used to obtain word documents; Parsing module, used to parse the data content of word documents; A data storage module, used to store the document template and the parsed data into a database; The document management module is used to edit document content online, generate a draggable canvas area, set container nodes and property panels in the canvas area, call the document template stored in the database, replace the placeholders in the document template with the data content of the word document through the interface of the Aspose.word document object model, save the required document configuration, and finally output the document.
2. The document operating system based on the document object model according to claim 1, characterized in that: The canvas area includes global styles, feature settings, container node addition, word text import, document preview and source code editing.
3. The document operating system based on the document object model according to claim 1, characterized in that: The container nodes include paragraph container nodes, loop container nodes, decision container nodes and table container nodes.
4. The document operating system based on the document object model according to claim 1, characterized in that: The document generation process also includes adding exception capture mechanisms at key operations.
5. The document operating system based on the document object model according to claim 1, characterized in that: The method of obtaining the word document is to obtain the document from the user using a file upload API.
6. The document operating system based on the document object model according to claim 1, characterized in that: Parsing the data content of the word document includes using Aspose.Words to traverse the document and extract text, tables, image information, styles and formats.
7. The document operating system based on the document object model according to claim 1, characterized in that: When calling the document template, use the File.ReadAllTextAsync method to asynchronously read the file content.
8. The document operating system based on the document object model according to claim 1, characterized in that: Use the XDocument.SaveAsync method to save the document asynchronously when saving the required document configuration.
9. The document operating system based on the document object model according to claim 1, characterized in that: When parsing the data content of the word document and replacing the placeholders in the document, the Task.Run method is used to put the entire process into a background thread for execution.
10. The document operation system based on the document object model according to claim 1, characterized in that: When the document management module needs to process the generation of multiple document templates, multi-threaded access is used to limit concurrency.
