Document generation method and device, computer equipment and readable storage medium
By automatically obtaining data from the text library or API interface and filling it into the document, combined with the demander's layout strategy, the problem of inefficient traditional document generation methods is solved, and efficient and personalized document generation is achieved.
Patent Information
- Application Number
- CN202411728366.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-02-11
AI Technical Summary
Traditional static document generation methods are inefficient and error-prone, especially when dealing with a large number of similar but different text documents.
Provides a document generation method, which generates an initial document based on the document template parameters of the demand side, obtains the text objects and picture objects to be added, and adds these objects to the initial document according to the demand side's layout strategy to generate a synthetic document.
It improves document generation efficiency, reduces the time and error rate of manual editing, and realizes personalized customization and efficient generation of documents.
Smart Images

Figure CN119416767A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of file processing, and in particular to a document generation method, apparatus, computer equipment and readable storage medium. Background Art
[0002] With the accelerated advancement of enterprise informatization, the demand for document processing in various industries is also constantly upgrading. In particular, key business documents such as financial statements, contracts, invoices, etc., these documents often contain a large amount of text that needs to be dynamically extracted from the text library or interface API, and the text is required to be highly accurate and consistent when presented.
[0003] The traditional method of generating static documents usually fixes the content and format when the document is created. If it needs to be modified or updated later, it often needs to be done manually.
[0004] However, this method is not only inefficient but also prone to errors. Especially when dealing with a large number of similar documents with different texts, the limitations of this method are particularly obvious, so it is urgent to improve it. Summary of the invention
[0005] Based on this, it is necessary to provide a document generation method, apparatus, computer device and readable storage medium that can improve the efficiency of document generation in response to the above technical problems.
[0006] In a first aspect, the present application provides a document generation method, the method comprising:
[0007] Generate an initial document according to the document template parameters carried in the document generation requirement initiated by the demander;
[0008] Obtain the object to be added provided by the demander; the object to be added includes text objects and picture objects;
[0009] According to the layout strategy of the object to be added according to the demand policy, the object to be added is added to the initial document to generate a composite document.
[0010] In one of the embodiments, if the object to be added is a text object, the layout strategy includes at least text position parameters, paragraph attribute parameters, text rendering strategy, and the page proportion of the text object relative to the initial document;
[0011] If the object to be added is a picture object, the layout strategy at least includes picture position parameters, picture size parameters, picture attribute parameters, picture rendering strategy and picture stacking order of the picture object.
[0012] In one embodiment, if the object to be added is a text object, the text object provided by the demander is obtained in the following manner:
[0013] Access the text source provided by the demander through the text access interface;
[0014] According to the filtering operation of the demander on the text source, the target text corresponding to the text filtering operation is queried in the text source;
[0015] The target text is taken as the text object provided by the demander.
[0016] In one embodiment, after obtaining the composite document for displaying the image to be added, the method further includes:
[0017] At the set update verification time, verify whether the object to be added provided by the demander has been updated;
[0018] If it exists, based on the updated object to be added, return to execute the layout strategy for the image to be added according to the demand policy, add the object to be added to the initial document, and generate a synthetic document for displaying the image to be added.
[0019] In one embodiment, the requirement policy obtains the layout strategy for adding pictures in the following manner:
[0020] Provide layout setting page to the demander;
[0021] Obtain the layout strategy for the object to be added entered by the demander in the layout setting page.
[0022] In one embodiment, if the object to be added is a text object, the object to be added is added to the initial document according to the layout strategy of the object to be added according to the requirement policy to generate a composite document, including:
[0023] According to the format conversion instruction provided by the demander, the object to be added of the text type is converted into the object to be added of the picture type;
[0024] According to the layout strategy of the demander for the object to be added after the format conversion, the object to be added after the format conversion is added to the initial document to generate a composite document.
[0025] In one embodiment, if the object to be added is a text object, the object to be added is added to the initial document according to the layout strategy of the object to be added according to the requirement policy to generate a composite document, including:
[0026] According to the text position parameters and paragraph attribute parameters of the text object and the page ratio of the text object relative to the initial document, the object to be added is added to the initial document to generate a layout document;
[0027] The text to be rendered selected by the demander in the text object is used as the variable value of the rendering variable in the layout document;
[0028] According to the rendering position in the text rendering strategy, determine the placeholder to be rendered in the layout document; the placeholder to be rendered corresponds to a rendering method;
[0029] Add the variable value of the rendering variable to the placeholder position corresponding to the placeholder to be rendered to synthesize the document.
[0030] In a second aspect, the present application further provides a document generation device, the device comprising:
[0031] The initial document acquisition module is used to generate the initial document according to the document template parameters carried in the document generation requirement initiated by the demander;
[0032] The object acquisition module is used to acquire the object to be added provided by the demander; the object to be added includes a text object and a picture object;
[0033] The document generation module is used to add the objects to be added to the initial document according to the layout strategy of the objects to be added according to the demand policy, and generate a composite document.
[0034] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0035] Generate an initial document according to the document template parameters carried in the document generation requirement initiated by the demander;
[0036] Obtain the object to be added provided by the demander; the object to be added includes text objects and picture objects;
[0037] According to the layout strategy of the object to be added according to the demand policy, the object to be added is added to the initial document to generate a composite document.
[0038] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the following steps are implemented:
[0039] Generate an initial document according to the document template parameters carried in the document generation requirement initiated by the demander;
[0040] Obtain the object to be added provided by the demander; the object to be added includes text objects and picture objects;
[0041] According to the layout strategy of the object to be added according to the demand policy, the object to be added is added to the initial document to generate a composite document.
[0042] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0043] Generate an initial document according to the document template parameters carried in the document generation requirement initiated by the demander;
[0044] Obtain the object to be added provided by the demander; the object to be added includes text objects and picture objects;
[0045] According to the layout strategy of the object to be added according to the demand policy, the object to be added is added to the initial document to generate a composite document.
[0046] The above-mentioned document generation method, device, computer equipment and readable storage medium, the present application reduces the time and error rate of manual editing of documents by automatically obtaining data from a text library or API interface and filling it into the document. Furthermore, the template parameters and layout strategies of the document are customized according to business needs, and highly customized document generation is achieved, which improves the document generation efficiency and realizes document personalization. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0048] FIG1 is a schematic diagram of a flow chart of a document generation method in one embodiment;
[0049] FIG2 is a schematic diagram of a composite document in one embodiment;
[0050] FIG3 is a schematic diagram of a flow chart of steps for generating a synthetic document in one embodiment;
[0051] FIG4 is a schematic flow chart of the steps of obtaining a text object provided by a demander in one embodiment;
[0052] FIG5 is a schematic diagram of a flow chart of the step of updating a synthetic document in one embodiment;
[0053] FIG6 is a schematic diagram of a flow chart of steps for generating a synthetic document in another embodiment;
[0054] FIG7 is a block diagram of a document generating device in one embodiment;
[0055] FIG. 8 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0057] In an exemplary embodiment, as shown in FIG1 , a document generation method is provided, and the method is applied to a computer device as an example for explanation.
[0058] S101, generating an initial document according to the document template parameters carried in the document generation demand initiated by the demander.
[0059] The demander initiates a document generation request through the user interface or API interface, and the request carries document template parameters. Document template parameters can include page attributes of the PDF file, such as page size (A3, A4, etc.), orientation (landscape, portrait), page margins, etc.
[0060] Specifically, after receiving the demand, the document template parameters are parsed and a blank PDF drawing board is generated according to these parameters, which is the initial document. This blank PDF drawing board is the basis for adding content later, and it ensures that the initial layout and format of the document meet the requirements of the demander.
[0061] S102, obtaining the object to be added provided by the demander.
[0062] The objects to be added include text objects and picture objects.
[0063] Specifically, a text access interface or user interface is provided so that the demander can upload or input the text objects and picture objects to be added, that is, the text objects and picture objects submitted through the interface or interface.
[0064] It is understandable that for text objects, the demander may need to input text content, specify the text source (such as a database, API, etc.), and perform a screening operation to obtain the target text. For image objects, the demander may directly upload the image file or specify the image storage location.
[0065] S103, adding the object to be added to the initial document according to the layout strategy of the object to be added according to the demand policy, and generating a composite document.
[0066] The layout strategy for the objects to be added refers to a series of rules and parameters that control how these objects (including text objects and image objects) are laid out and displayed in the final PDF document. The purpose of the layout strategy is to ensure that the generated PDF document meets the visual design requirements of the demander and can effectively convey information.
[0067] For example, layout strategies include but are not limited to the following aspects:
[0068] (1) Position parameters: Text position parameters: specify the specific position of the text on the PDF page, such as the pixel distance from the top, bottom, left or right of the page, or the percentage position relative to the page size. Image position parameters: also specify the position of the image on the PDF page to ensure that the image can be arranged in the expected way.
[0069] (2) Size and ratio parameters: Text size parameters: Although the size of the text itself can be controlled by the font size, in some cases, it may be necessary to specify the overall size of the text block or limit its maximum width. Image size parameters: Specify the display size of the image, including width and height, which can be an absolute pixel value or a percentage relative to the page size.
[0070] (3) Attribute parameters: Paragraph attribute parameters (only applicable to text): control the layout of text, such as indentation, line spacing, paragraph spacing, font type, font size, font color, and alignment, etc. Image attribute parameters: can include image transparency, borders, shadow effects, etc., used to adjust the visual performance of the image.
[0071] Specifically, as shown in FIG2 , the objects to be added are added to the initial document according to the layout strategy. After all the objects to be added are added to the initial document according to the layout strategy, a final composite document is generated. This composite document is a complete PDF file, which contains all the content and format requirements specified by the demander.
[0072] The above-mentioned text generation method, this application reduces the time and error rate of manual document editing by automatically obtaining data from a text library or API interface and filling it into the document. Furthermore, it customizes the template parameters and layout strategies of the document according to business needs, and generates highly customized documents, which improves the document generation efficiency and realizes document personalization.
[0073] In an exemplary embodiment, the demand side obtains the layout strategy for the image to be added in the following manner: providing a layout setting page to the demand side; obtaining the layout strategy for the object to be added input by the demand side in the layout setting page.
[0074] Optionally, in order to obtain the layout strategy of the request policy for the image to be added, a layout setting page will be provided to the requester first. This page is a user interface that allows the requester to intuitively define and adjust the layout of the objects to be added (including text objects and image objects) in the PDF document.
[0075] For example, in the layout setting page, the demander can define the layout strategy of the object to be added through various input methods (such as dragging, selecting, inputting parameters, etc.). Specifically, these strategies may include but are not limited to:
[0076] Position: Specify the specific position of the image to be added on the page, which can be determined by pixel coordinates, percentages, or relative positions. Size: Set the width and height of the image, or choose to keep the original proportions of the image and scale it. Wrapping: Define the text wrapping method around the image, such as wrap around all around, wrap tightly, etc. Alignment: Set the alignment of the image on the page, such as left alignment, right alignment, center alignment, etc. Hierarchy: Determine the hierarchical relationship between the image and other page elements (such as text, other images) to control which elements will be displayed above or below the image.
[0077] Specifically, after the demander completes the definition of the layout strategy in the layout setting page, the settings can be saved. The system will then add the images to be added to the initial document according to these layout strategies to generate a composite document.
[0078] In this embodiment, the demander can accurately control the layout of each object to be added on the page according to its specific needs, thereby realizing highly personalized PDF document generation. The layout setting page provides an intuitive user interface, so that demanders with non-technical backgrounds can also easily define complex layout strategies.
[0079] In an exemplary embodiment, if the object to be added is a text object, the layout strategy includes at least text position parameters, paragraph attribute parameters, text rendering strategy, and the page ratio of the text object relative to the initial document.
[0080] It is understandable that, in addition to the example in S103 above, the text rendering strategy refers to the dynamic rendering method of the text. For example, if the text content comes from a database or API, the rendering strategy may include how to update the text content according to the dynamic data in the data source, whether to support loop rendering (i.e., repeatedly rendering text paragraphs in the same format according to the number of records in the data source), and whether to support conditional rendering (i.e., deciding whether to render a certain text paragraph based on specific conditions). Page proportion: This refers to the relative size of the space occupied by the text object on the page. For example, you can specify the percentage of the page width that the text paragraph occupies to ensure that the text maintains good readability on different page sizes.
[0081] Further, as shown in FIG3 , if the object to be added is a text object, the object to be added is added to the initial document according to the layout strategy of the object to be added according to the demand policy, and a composite document is generated, including:
[0082] S301, adding the object to be added to the initial document according to the text position parameters, paragraph attribute parameters of the text object, and the page ratio of the text object relative to the initial document, to generate a layout document.
[0083] Among them, according to the text position parameters provided by the demander (such as the specific position relative to the edge of the page, the percentage position, etc.), paragraph attribute parameters (such as font, font size, color, alignment, indentation, spacing, etc.) and the proportion of the text object in the page (such as the proportion of the width and height of the page), the text object is added to the initial document at the pixel level to obtain a preliminary layout document, so that the layout of the text object on the page meets the requirements of the demander.
[0084] S302: Use the text to be rendered selected by the demander in the text object as the variable value of the rendering variable in the layout document.
[0085] Specifically, after the layout document is generated, the demander can insert dynamic data in certain locations, which will be determined when the PDF is generated. Therefore, the demander will select some text to be rendered in the text object, and these texts will be replaced by actual data values in the final generated PDF. In this step, these texts to be rendered are saved as variable values of rendering variables for subsequent rendering.
[0086] S303: Determine a placeholder to be rendered in the layout document according to the rendering position in the text rendering strategy.
[0087] Among them, the placeholder to be rendered corresponds to a rendering method.
[0088] It can be understood that, in a layout document, the placeholder to be rendered refers to a location for inserting dynamic data.
[0089] In this step, these placeholders are found and marked in the layout document according to the rendering positions defined in the text rendering strategy. Each placeholder corresponds to a rendering method, such as text rendering, image rendering, etc.
[0090] S304: Add the variable value of the rendering variable to the placeholder position corresponding to the placeholder to be rendered to synthesize the document.
[0091] Specifically, after determining the placeholder to be rendered, the variable value of the previously saved rendering variable (i.e., the text to be rendered selected by the demander) can be added to the corresponding placeholder position. In this way, the placeholder in the layout document is replaced by the actual data value, generating the final synthesized document. The above process is usually carried out in the cloud, using cloud computing resources to complete the rendering and synthesis of the document, thereby reducing the load pressure on the local device.
[0092] In this embodiment, through the template engine technology, users are supported to customize the style and rendering logic of PDF components, and highly customizable PDF generation is achieved. Users are allowed to accurately control the layout and style of PDF content at the pixel level to ensure that the generated PDF is consistent with the preview designed by the user. Cloud computing resources are used to complete the generation and rendering of documents, which reduces the load pressure of local devices and improves generation efficiency. It supports automatic extraction of data according to the data source and rendering into PDF, realizing the automatic generation of dynamic content.
[0093] In an exemplary embodiment, if the object to be added is a picture object, the layout strategy includes at least picture position parameters, picture size parameters, picture attribute parameters, picture rendering strategy and picture stacking order of the picture object.
[0094] It is understandable that, in addition to the example in S103 above, the image rendering strategy refers to how to update the image content according to the dynamic data in the data source. For example, if the image is a chart (such as a line chart, a bar chart, etc.) generated based on certain data in the data source, the rendering strategy will determine how to dynamically generate and update these charts based on the latest data. The image stacking order refers to the stacking order that determines their display priority on the page if multiple images or other objects overlap in a PDF document. By adjusting the stacking order of the images, you can control which objects are displayed in the foreground and which objects are displayed in the background.
[0095] Furthermore, in the initial document (PDF drawing board) obtained in S101, user-defined components are supported, and the component forms include but are not limited to single page, single paragraph, single table, single row of table, single picture, and combination of the above components. This technology allows users to manipulate the content and attributes of each element in the customized component. In addition, it allows users to render customized components obtained by designing relevant rendering strategies. The rendering strategies supported by this technology include: loop rendering strategy, conditional rendering strategy, and combined rendering strategy; among them: loop rendering strategy: as long as the user-defined conditions are met, the customized component will be rendered continuously; conditional rendering strategy: the customized component will be rendered only when the user-defined conditions are met; combined rendering strategy: a combination of the above rendering strategies and conditional rendering strategies;
[0096] In an exemplary embodiment, as shown in FIG4 , if the object to be added is a text object, the text object provided by the demander is obtained in the following manner:
[0097] S401, accessing the text source provided by the demander through a text access interface.
[0098] Optionally, the text source provided by the demander is received through a text access interface.
[0099] The text source can be data in various formats, such as data tables in a database, data returned by an API interface, Excel files, CSV files, etc. Through the text access interface, these data sources can be easily accessed to provide a basis for subsequent processing.
[0100] S402: According to the screening operation of the demander on the text source, the target text corresponding to the text screening operation is searched in the text source.
[0101] Optionally, after accessing the text source, the demander can filter out specific text from the data as the content to be generated in the PDF.
[0102] For example, according to the function of the filtering operation, the demander is allowed to query the text source according to preset conditions or rules (such as keywords, date range, data type, etc.). The query result is the target text, which will serve as the basic data for subsequent PDF generation.
[0103] S403, taking the target text as the text object provided by the demander.
[0104] Specifically, after the screening operation is completed and the target text is obtained, the target text is saved as the text object provided by the demander. These text objects will be added to the initial document according to the subsequent processing flow (such as template definition, logic definition, image rendering, data bonding, etc.), and finally generate a PDF file that meets the requirements of the demander.
[0105] In this embodiment, by providing a text access interface and a filtering operation function, text sources in various formats can be easily accessed, and the demander is allowed to filter and customize according to actual needs, thereby improving the flexibility of PDF generation.
[0106] In an exemplary embodiment, as shown in FIG5 , after obtaining the composite document for displaying the image to be added, the method further includes:
[0107] S501, at the set update verification time, verify whether the object to be added provided by the demander has been updated.
[0108] Optionally, automatically check whether the objects to be added (including text, pictures, etc.) provided by the demander have been updated at the set update verification time. This update verification time can be a fixed time point (such as early morning every day) or can be triggered based on a specific event (such as when database data is updated). Through regular or event-triggered update verification, ensure that the content in the synthetic document is consistent with the latest data of the demander, and avoid inaccurate information caused by data lag.
[0109] S502: If it exists, based on the updated object to be added, return to execute S103.
[0110] Optionally, if it is detected that the object to be added is updated, the process returns to S103 and the process of generating the synthetic document is re-executed based on the updated data. If it is detected that the object to be added is not updated, the current processing process is terminated.
[0111] In this embodiment, the update verification is triggered by a periodic or event-triggered update to ensure that the generated PDF file always contains the latest data, thereby improving the timeliness of the document. The entire update verification and reprocessing process is automated, without manual intervention, thereby improving work efficiency.
[0112] In an exemplary embodiment, if the object to be added is a text object, as shown in FIG6 , the object to be added is added to the initial document according to the layout strategy of the object to be added according to the demand policy, and a composite document is generated, including:
[0113] S601, converting a text type object to be added into a picture type object to be added according to a format conversion instruction provided by a demander.
[0114] Optionally, the text object is converted to an image object according to the format conversion instructions provided by the demander. This usually involves rendering the text content into an image buffer and saving it in an image format (such as PNG, JPEG, etc.). By converting to an image, it is easier to achieve precise control at the pixel level while avoiding the complexity and limitations of directly processing PDF text.
[0115] S602: adding the object to be added after the format conversion to the initial document according to the layout strategy of the demander for the object to be added after the format conversion, to generate a composite document.
[0116] Optionally, the object to be added that has been converted into an image is added to the initial PDF document according to the layout strategy of the demand side. This includes specifying the image's location, size, rotation angle, and other properties in the PDF.
[0117] It is understandable that the layout strategy can include pixel-level precise positioning, relative positioning (such as relative to the edge of the page or a reference point), alignment (such as left alignment, center alignment, right alignment, etc.), scaling, etc. Through precise layout strategies, it is ensured that the converted image objects can be displayed in the expected way in the PDF document to meet the design requirements.
[0118] In this embodiment, by converting text into images and then processing them, precise control at the pixel level can be more easily achieved to meet complex design requirements.
[0119] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0120] Based on the same inventive concept, the embodiment of the present application also provides a document generation device for implementing the document generation method involved above. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in one or more document generation device embodiments provided below can refer to the limitations on the document generation method above, and will not be repeated here.
[0121] In an exemplary embodiment, as shown in FIG7 , a document generation device is provided, including:
[0122] The initial document acquisition module 11 is used to generate an initial document according to the document template parameters carried in the document generation demand initiated by the demander;
[0123] The object acquisition module 12 is used to acquire the object to be added provided by the demander; the object to be added includes a text object and a picture object;
[0124] The document generation module 13 is used to add the object to be added to the initial document according to the layout strategy of the object to be added according to the demand policy, so as to generate a composite document.
[0125] Each module in the document generation device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0126] In an exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be shown in FIG8. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, the memory, and the input / output interface are connected via a system bus, and the communication interface, the display unit, and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner may be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, a document generation method is implemented. The display unit of the computer device is used to form a visually visible picture, which may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0127] Those skilled in the art will understand that the structure shown in FIG. 8 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0128] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0129] Generate an initial document according to the document template parameters carried in the document generation requirement initiated by the demander;
[0130] Obtain the object to be added provided by the demander; the object to be added includes text objects and picture objects;
[0131] According to the layout strategy of the object to be added according to the demand policy, the object to be added is added to the initial document to generate a composite document.
[0132] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0133] Generate an initial document according to the document template parameters carried in the document generation requirement initiated by the demander;
[0134] Obtain the object to be added provided by the demander; the object to be added includes text objects and picture objects;
[0135] According to the layout strategy of the object to be added according to the demand policy, the object to be added is added to the initial document to generate a composite document.
[0136] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0137] Generate an initial document according to the document template parameters carried in the document generation requirement initiated by the demander;
[0138] Obtain the object to be added provided by the demander; the object to be added includes text objects and picture objects;
[0139] According to the layout strategy of the object to be added according to the demand policy, the object to be added is added to the initial document to generate a composite document.
[0140] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, text library or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The text library involved in each embodiment provided in this application may include at least one of a relational text library and a non-relational text library. Non-relational text libraries may include distributed text libraries based on blockchain, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a text processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0141] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0142] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A document generation method, characterized in that: The method comprises: Generate an initial document according to the document template parameters carried in the document generation requirement initiated by the demander; Acquire the object to be added provided by the demander; the object to be added includes a text object and a picture object; According to the layout strategy of the demander for the object to be added, the object to be added is added to the initial document to generate a composite document.
2. The method according to claim 1, characterized in that If the object to be added is the text object, the layout strategy includes at least text position parameters, paragraph attribute parameters, text rendering strategy, and the page ratio of the text object relative to the initial document; If the object to be added is the picture object, the layout strategy at least includes picture position parameters, picture size parameters, picture attribute parameters, picture rendering strategy and picture stacking order of the picture object.
3. The method according to claim 1, characterized in that If the object to be added is the text object, the step of obtaining the text object provided by the requester includes: Access the text source provided by the demander through a text access interface; According to the screening operation of the demander on the text source, querying the text source to obtain the target text corresponding to the text screening operation; The target text is taken as the text object provided by the demander.
4. The method according to claim 1, characterized in that: After generating the composite document, the method further includes: At the set update verification time, verify whether the object to be added provided by the demander has been updated; If so, based on the updated object to be added, the process returns to the step of adding the object to be added to the initial document according to the layout strategy of the demander for the object to be added, and generating a synthetic document.
5. The method according to claim 1, characterized in that The demander obtains the layout strategy for the object to be added in the following manner: Providing a layout setting page to the demander; The layout strategy for the object to be added input by the demander in the layout setting page is obtained.
6. The method according to claim 1, characterized in that If the object to be added is the text object, then according to the layout strategy of the demander for the object to be added, the object to be added is added to the initial document to generate a composite document, including: According to the format conversion instruction provided by the demander, the object to be added of the text type is converted into the object to be added of the picture type; According to the layout strategy of the demander for the to-be-added object after format conversion, the to-be-added object after format conversion is added to the initial document to generate a composite document.
7. The method according to claim 2, characterized in that If the object to be added is the text object, then according to the layout strategy of the demander for the object to be added, the object to be added is added to the initial document to generate a composite document, including: According to the text position parameters and paragraph attribute parameters of the text object and the page ratio of the text object relative to the initial document, the object to be added is added to the initial document to generate a layout document; Using the text to be rendered selected by the demander in the text object as the variable value of the rendering variable in the layout document; Determine, according to the rendering position in the text rendering strategy, a placeholder to be rendered in the layout document; the placeholder to be rendered corresponds to a rendering mode; The variable value of the rendering variable is added to the placeholder position corresponding to the placeholder to be rendered to synthesize the document.
8. A document generation device, characterized in that: The device comprises: The initial document acquisition module is used to generate the initial document according to the document template parameters carried in the document generation requirement initiated by the demander; An object acquisition module, used to acquire the object to be added provided by the demander; the object to be added includes a text object and a picture object; The document generation module is used to add the object to be added to the initial document according to the layout strategy of the demander for the object to be added, so as to generate a composite document.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.