Document generation method and device, storage medium and electronic equipment
By obtaining template configuration information and document data model to generate target pictures in preset encoding formats and performing format conversion, the problem of poor PDF files in the prior art is solved, and the integrity and high-quality display of text and charts are achieved.
Patent Information
- Application Number
- CN202310720925.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-16
- Publication Date
- 2024-12-17
AI Technical Summary
The quality of the PDF files generated in the prior art is poor. The screenshot method causes the image resolution to affect the display quality. Text and charts cannot be selected separately, and truncation problems are prone to occur during paging and cutting.
By obtaining the template configuration information and document data model of the PDF document, generate target pictures with preset encoding format, and replace the target number parameters with the target picture, convert the format to generate target PDF documents, avoid the impact of screenshot resolution, and ensure the text and The integrity of the chart.
Improve the display quality of PDF documents, ensure that text content can be selected separately, avoid truncation problems, and improve content clarity and accuracy.
Smart Images

Figure CN119150818A_ABST
Abstract
Description
Background Art
[0002] PDF stands for Portable Document Format, which is an electronic file format that supports security encryption, signatures and other features. Therefore, in business, the system often needs to generate PDF documents with fixed formats (such as reports evaluated according to rules, official documents, etc.) to provide to users. For example, in the process of online medical treatment based on the Internet, in order to facilitate information sharing between patients and doctors, it is often necessary to generate PDF reports of patients' health data in the form of charts.
[0003] At present, one way to generate PDF reports is to first use web technologies such as HyperText Mark-up Language (HTML), Cascading Style Sheets (CSS), and JavaScript (JS scripting language) to render HTML format reports, and then use tools to convert HTML reports into PDF reports. However, this method is similar to taking a screenshot of a page and then generating a PDF based on the screenshot. The resolution configuration during the image generation process may affect the display quality of the image, resulting in distortion of the generated PDF report. At the same time, the screenshot method makes it impossible to select and copy elements such as text and links in the PDF report separately, and the screenshot needs to be split when paging, resulting in truncation of text or charts, which ultimately leads to poor quality of the generated PDF file.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0005] The purpose of the present disclosure is to provide a document generation method, device, storage medium and electronic device, thereby overcoming the problem of poor quality of generated PDF files at least to a certain extent.
[0006] According to one aspect of the present disclosure, there is provided a document generation method, comprising:
[0007] In response to the document generation instruction, obtaining template configuration information for generating a target PDF document;
[0008] Draw a chart according to the template configuration information and the document data model to generate a target image in a preset encoding format; the document data model is a document model generated by the data required by the target PDF document;
[0009] Replacing the parameter recorded by the target number in the document data model with the target image corresponding to the target number to obtain the target document;
[0010] The target document is formatted and generated into the target PDF document.
[0011] Optionally, before drawing a chart according to the template configuration information and the document data model to generate a target image in a preset encoding format, the method further includes:
[0012] Acquire target data required to generate the target PDF document;
[0013] The target data is added to a preset document presentation model to generate the document data model.
[0014] Optionally, the drawing of a chart according to the template configuration information and the document data model to generate a target image in a preset encoding format includes:
[0015] Constructing a drawing parameter template that conforms to the chart configuration information according to the chart configuration information included in the template configuration information;
[0016] Integrate and match the drawing parameter template with the document data model to generate drawing parameter configuration values for drawing each chart;
[0017] Draw charts respectively according to the drawing parameter configuration values to generate target pictures in the preset encoding format.
[0018] Optionally, drawing charts respectively according to the drawing parameter configuration values to generate the target picture in the preset encoding format includes:
[0019] Based on the drawing parameter configuration values, drawing charts respectively using a preset drawing method to obtain multiple target charts;
[0020] The multiple target graphs are converted into images according to the preset coding format to generate target images in the preset coding format.
[0021] Optionally, the step of replacing the parameter recorded by the target number in the document data model with the target image corresponding to the target number to obtain the target document includes:
[0022] Querying the chart parameters of the target number record in the document data model;
[0023] Replacing the chart parameters of the record with the target image corresponding to the target number to obtain a replaced document data model;
[0024] The target document is generated according to the template network address indicated in the template configuration information and the replaced document data model.
[0025] Optionally, generating the target document according to the template network address indicated in the template configuration information and the replaced document data model includes:
[0026] Acquire web page template information according to the template network address indicated in the template configuration information;
[0027] The replaced document data model is applied to the web page template information to obtain the target document in a preset format.
[0028] Optionally, converting the format of the target document to generate the target PDF document includes:
[0029] The target document in the preset format is converted using a preset document conversion method to obtain the corresponding target PDF document.
[0030] According to one aspect of the present disclosure, there is provided a document generating device, the device comprising:
[0031] A first acquisition module, configured to acquire, in response to a document generation instruction, template configuration information for generating a target PDF document;
[0032] A first generating module, configured to draw a chart according to the template configuration information and a document data model to generate a target image in a preset encoding format; the document data model is a document model generated by the data required by the target PDF document;
[0033] A replacement module, used to replace the parameters recorded by the target number in the document data model with the target image corresponding to the target number, so as to obtain a target document;
[0034] The second generating module is used to convert the format of the target document to generate the target PDF document.
[0035] Optionally, the device further comprises:
[0036] A second acquisition module, used to acquire target data required to generate the target PDF document;
[0037] The third generating module is used to add the target data to the preset document presentation model to generate the document data model.
[0038] Optionally, the first generating module is further used to:
[0039] Constructing a drawing parameter template that conforms to the chart configuration information according to the chart configuration information included in the template configuration information;
[0040] Integrate and match the drawing parameter template with the document data model to generate drawing parameter configuration values for drawing each chart;
[0041] Draw charts respectively according to the drawing parameter configuration values to generate target pictures in the preset encoding format.
[0042] Optionally, the first generating module is further used to:
[0043] Based on the drawing parameter configuration values, drawing charts respectively using a preset drawing method to obtain multiple target charts;
[0044] The multiple target graphs are converted into images according to the preset coding format to generate target images in the preset coding format.
[0045] Optionally, the replacement module is further used for:
[0046] Querying the chart parameters of the target number record in the document data model;
[0047] Replacing the chart parameters of the record with the target image corresponding to the target number to obtain a replaced document data model;
[0048] The target document is generated according to the template network address indicated in the template configuration information and the replaced document data model.
[0049] Optionally, the replacement module is further used for:
[0050] Acquire web page template information according to the template network address indicated in the template configuration information;
[0051] The replaced document data model is applied to the web page template information to obtain the target document in a preset format.
[0052] Optionally, the second generating module is further used to:
[0053] The target document in the preset format is converted using a preset document conversion method to obtain the corresponding target PDF document.
[0054] According to one aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the document generation method described in any one of the above is implemented.
[0055] According to one aspect of the present disclosure, there is provided an electronic device, including:
[0056] Processor; and
[0057] A memory, configured to store executable instructions of the processor;
[0058] The processor is configured to execute any one of the document generation methods described above by executing the executable instructions.
[0059] In summary, the document generation method provided by the embodiment of the present disclosure can respond to the document generation instruction, obtain the template configuration information for generating the target PDF document, draw the chart according to the template configuration information and the document data model, generate the target image of the preset encoding format, the document data model is a document model generated by the data required by the target PDF document, replace the parameter recorded in the document data model with the target image corresponding to the target number, obtain the target document, perform format conversion on the target document, and generate the target PDF document. In this way, by directly obtaining the template configuration information for generating the PDF document to generate the document model and the image corresponding to the chart, the problem of reducing the image display quality due to the influence of the screenshot resolution can be avoided, and the text content in the generated PDF document can be ensured to be captured and selected separately, which improves the clarity and accuracy of the content in the generated PDF document, and also avoids the problem of truncation of text or charts due to paging and cutting of the screenshot, which ensures the integrity of the text content and charts in the document and improves the display quality of the PDF document.
[0060] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0062] Figure 1 is a flowchart of the steps of a document generation method provided by an embodiment of the present disclosure;
[0063] Figure 2 is a flow chart of generating a document data model provided by an embodiment of the present disclosure;
[0064] Figure 3 is a flow chart of generating a target image provided by an embodiment of the present disclosure;
[0065] Figure 4is a flow chart of obtaining a target document provided by an embodiment of the present disclosure;
[0066] Figure 5 is a block diagram of a document generation device provided by an embodiment of the present disclosure;
[0067] Figure 6 An electronic device provided by an embodiment of the present disclosure is used to implement the above-mentioned document generation method. DETAILED DESCRIPTION
[0068] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0069] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0070] It should be noted that in the technical solution of the present invention, the collection / collection, updating, analysis, use, transmission, storage and other aspects of the user personal information involved (such as basic patient information, such as name, gender, age, height, weight, waist circumference, etc.) are in compliance with the provisions of relevant laws and regulations, and are used for legal and reasonable purposes. They are not shared, leaked or sold outside of these legal uses, and are subject to supervision and management by national regulatory authorities. Necessary measures should be taken for user personal information to selectively block the use or access to personal information data to prevent illegal access to such personal information data, ensure that persons who have access to personal information data comply with the provisions of relevant laws and regulations, and ensure the security of user personal information. In addition, once these user personal information data are no longer needed, the risks should be minimized by restricting or even prohibiting data collection and / or deleting data.
[0071] When applicable, including in certain relevant applications, user privacy is protected by de-identifying data, such as by removing specific identifiers when applicable (e.g., date of birth, etc., as written in actual technical solutions), controlling the amount or specificity of stored data (e.g., collecting location data at the city level rather than at the specific address level, as written in actual technical solutions), controlling how data is stored, and / or other de-identification methods.
[0072] Figure 1 is a flowchart of a method for generating a document provided by an embodiment of the present disclosure. Figure 1 As shown, the method may include:
[0073] Step S101: In response to a document generation instruction, template configuration information for generating a target PDF document is acquired.
[0074] In the embodiment of the present disclosure, the document generation instruction may be an instruction to generate a PDF from the current data content, and the user may input a determination operation to the plug-in representing the document generation instruction, and accordingly, the terminal executes the document generation instruction in response to the determination operation. Since the content format, typesetting style, etc. of the document need to be determined when the network data generates a PDF document, and the content format, typesetting style, etc. of the corresponding document may be different when the data on different websites generate a PDF document, and the content format, typesetting style, etc. of the corresponding document may also be different when different data are generated from the same website. Therefore, obtaining the template configuration information for generating the target PDF document may be to search for the configuration information such as the content format, typesetting style, etc. of the document corresponding to the current data when generating a PDF according to the parameters indicated by the document generation instruction, and determine the parameters indicated by the document generation instruction and the configuration information such as the content format, typesetting style, etc. of the document as the template configuration information for generating the target PDF document.
[0075] It should be noted that the template configuration information may be global configuration information related to PDF document generation, and the content of the template configuration information may mainly include: the URL (Uniform Resource Locator) address corresponding to the html document template, the template variable array of the chart, wherein each icon template variable in the template configuration information represents an independently displayed chart, and each variable will eventually be replaced by a picture in a preset encoding format. The template configuration information may be in JSON (JavaScript Object Notation) format or other data formats.
[0076] Step S102: Draw a chart according to the template configuration information and the document data model to generate a target image in a preset encoding format; the document data model is a document model generated by the data required by the target PDF document.
[0077] In the disclosed embodiment, the document data model may be a document model generated according to the data required for generating the target PDF document, and the document data model may identify the text content of the document, the content format of the document, the typesetting style, etc. Drawing a chart according to the template configuration information and the document data model to generate a target image in a preset encoding format may be performed by first determining the drawing parameter configuration value corresponding to the chart according to the template configuration information and the document data model, then drawing the chart according to the corresponding drawing parameter configuration value, and finally generating a target image in a preset encoding format. The preset encoding format may be an encoding format pre-set according to an actual application, for example, it may be a base64 encoding format, and base64 may be a method of representing binary data based on 64 printable characters.
[0078] Step S103: Replace the parameter recorded by the target number in the document data model with the target image corresponding to the target number to obtain the target document.
[0079] In an embodiment of the present disclosure, when the data used to generate a target PDF document includes at least one image or table, the target number corresponding to each target image may be determined first, and then the parameter of the record corresponding to the target number in the document data model may be searched according to the target number, and the parameter may be replaced with the target image. Finally, the document data model obtained after replacing all target images may be converted to obtain the corresponding target document.
[0080] It should be noted that when the data used to generate the target PDF document does not contain pictures or tables, there is no need to replace the parameters recorded in the document data model of the target number with the target pictures corresponding to the target number to obtain the target document. The document data model can be directly converted to obtain the target document.
[0081] Step S104: convert the target document into a format to generate the target PDF document.
[0082] In the embodiment of the present disclosure, the target document may be format converted using a preset PDF conversion method to generate a target PDF document corresponding to the target document.
[0083] In summary, the document generation method provided by the embodiment of the present disclosure can respond to the document generation instruction, obtain the template configuration information for generating the target PDF document, draw the chart according to the template configuration information and the document data model, generate the target image of the preset encoding format, the document data model is a document model generated by the data required by the target PDF document, replace the parameter recorded in the document data model with the target image corresponding to the target number, obtain the target document, perform format conversion on the target document, and generate the target PDF document. In this way, by directly obtaining the template configuration information for generating the PDF document to generate the document model and the image corresponding to the chart, the problem of reducing the image display quality due to the influence of the screenshot resolution can be avoided, and the text content in the generated PDF document can be ensured to be captured and selected separately, which improves the clarity and accuracy of the content in the generated PDF document, and also avoids the problem of truncation of text or charts due to paging and cutting of the screenshot, which ensures the integrity of the text content and charts in the document and improves the display quality of the PDF document.
[0084] Optionally, in the embodiment of the present disclosure, before the operation of drawing a chart according to the template configuration information and the document data model to generate a target image in a preset encoding format, as follows Figure 2 As shown, it may also include:
[0085] Step S201: Acquire target data required to generate the target PDF document.
[0086] In the disclosed embodiment, all data required for document display may be queried according to user information, device number and document generation instruction, and the queried data may be used as target data required for generating a target PDF document.
[0087] Step S202: Add the target data to the preset document presentation model to generate the document data model.
[0088] In the embodiment of the present disclosure, the preset document display model may be a document display model that is pre-set according to actual conditions, and the preset document display model may be set with information such as the content format and typesetting style of the document. Adding target data to the preset document display model to generate a document data model may be based on the style type indicated in the preset document display model, adding target data of corresponding style types to the preset document display model to obtain the document data model, wherein the style type indicated in the preset document display model may be a first-level title, a second-level title, a body, a header, a footer, and the like.
[0089] For example, in one implementation, a dynamic configuration service may be called to obtain the template configuration information for generating the target PDF document. The dynamic configuration service may realize the externalization of configuration attributes, and the configuration attributes may be updated through the management background. The service using the configuration attributes may obtain the update of the configuration attributes. The input parameter of the dynamic configuration service may be the configuration attribute key, and the output parameter may be the configuration attribute value. According to the chart configuration information contained in the template configuration information, the configuration attribute key is constructed in sequence, and the dynamic configuration service is called to read the drawing parameter template corresponding to each chart template variable. The ReportData service is called to obtain the target data required to generate the target PDF document, add the target data to the preset document display model, and generate the document data model. The ReportData service may be a report data query service, which is responsible for querying all the data required for the report display according to the input parameter and generating the report data model. The input parameter of the ReportData service may be the user ID, the report type, such as blood pressure monitoring report, blood sugar monitoring report, etc. The report involves a time period, including the start time and the end time. The output parameter of the ReportData service may be the user's basic data, the monitoring data within the report time period, and its derived indicator data.
[0090] Optionally, in the embodiment of the present disclosure, the above-mentioned operation of drawing a chart according to the template configuration information and the document data model to generate a target image in a preset encoding format is as follows: Figure 3 As shown, it may specifically include:
[0091] Step S1021: construct a drawing parameter template that conforms to the chart configuration information according to the chart configuration information included in the template configuration information.
[0092] In the disclosed embodiment, it may be chart configuration information set for a picture or table in the statistical template configuration information, and a drawing parameter template is constructed based on the chart configuration information corresponding to each picture or table, wherein the drawing parameter template may include the size, resolution, display parameters, etc. of the picture and the size, table style, text style, etc. of the table.
[0093] Step S1022: Integrate and match the drawing parameter template with the document data model to generate drawing parameter configuration values for drawing each chart.
[0094] In the disclosed embodiment, the drawing parameter configuration value for each chart may be generated by integrating and matching the data for each chart in the document data model with the corresponding drawing parameter template.
[0095] Step S1023: Draw charts respectively according to the drawing parameter configuration values to generate a target picture in the preset coding format.
[0096] In the embodiment of the present disclosure, the chart may be drawn according to the drawing content and drawing style indicated by the drawing parameter configuration value, and the drawn picture may be converted into a target picture in a preset encoding format.
[0097] For example, in one implementation, the Template service is called in sequence to integrate and match the drawing parameter template with the document data model to generate drawing parameter configuration values for drawing each chart. The Template service can be a call to a template engine to merge the template containing variables and the data model into a document that can be used directly. The input parameters of the Template service can be the template text content and the data model, and the output parameters of the Template service can be the result text content generated using the data model.
[0098] Optionally, in the embodiment of the present disclosure, the operation of drawing charts respectively according to the drawing parameter configuration values to generate the target picture in the preset coding format may specifically include:
[0099] Based on the drawing parameter configuration value, a preset drawing method is used to draw charts respectively to obtain multiple target charts; the multiple target charts are converted into images according to the preset coding format to generate target images in the preset coding format.
[0100] In the disclosed embodiment, a preset drawing method may be used to generate a target chart for each chart according to the corresponding drawing parameter configuration value, and then the generated multiple target charts are converted into images according to the preset coding format to generate corresponding multiple target images in the preset coding format. The preset drawing method may be a drawing method pre-set according to actual conditions, for example, the preset drawing method may be a call to the echarts drawing service based on the node-canvas engine.
[0101] For example, in one implementation method, a node service can be built, and the express web framework is introduced to provide a REST API interface. The API interface receives drawing parameters in json format, calls the chart rendering capability provided by the node-canvas module, draws the chart on the server, and then converts it into base64-encoded image data as the interface call result. Since drawing parameters often involve a large amount of dynamic data, the Freemarker template engine can be used to dynamically generate drawing parameters according to actual scenarios. In this way, an independent drawing service is built using node-canvas and echarts tools, and the drawing parameter configuration is generated using template generation, which simplifies the drawing service call.
[0102] For example, you can first use web technology to develop an HTML report template. For the charts in the report template, call the above drawing service to generate image base64 encoded data, use the image base64 encoded data to replace the chart template variables in the report template, and then use the open html to pdf tool to convert the HTML report after the merged data to HTML native format and generate PDF format. In this way, the HTML native conversion method and the canvas conversion method are combined to convert the chart display into image base64 encoded data using canvas first, and then use HTML native conversion for the entire HTML report, and finally convert it into PDF format with charts.
[0103] Optionally, in the embodiment of the present disclosure, the operation of replacing the parameter recorded in the document data model by the target number with the target image corresponding to the target number to obtain the target document is as follows: Figure 4 As shown, it may specifically include:
[0104] Step S1031, querying the chart parameters of the target number record in the document data model.
[0105] In the embodiment of the present disclosure, the target number may be queried in the document data model, and the chart parameters of the record corresponding to the target number may be determined.
[0106] Step S1032: Replace the chart parameters of the record with the target image corresponding to the target number to obtain a replaced document data model.
[0107] In the disclosed embodiment, according to the target numbers corresponding to the target images, the chart parameters recorded with the same target number can be replaced with the corresponding target images until all the target images are replaced to obtain a replaced document data model.
[0108] Step S1033: Generate the target document according to the template network address indicated in the template configuration information and the replaced document data model.
[0109] In the disclosed embodiment, the template network address indicated in the template configuration information may be determined first, and then the web page style indicated by the template network address is synthesized with the replaced document data model to generate the corresponding target document.
[0110] Optionally, in the embodiment of the present disclosure, the operation of generating the target document according to the template network address indicated in the template configuration information and the replaced document data model may specifically include:
[0111] According to the template network address indicated in the template configuration information, web page template information is obtained; and the replaced document data model is applied to the web page template information to obtain the target document in a preset format.
[0112] In the disclosed embodiment, web page template information can be obtained based on the template network address indicated in the template configuration information. The web page template information can include information such as the web page title and the web page style. Then, the replaced document data model can be directly applied in the web page template information, either by pasting the replaced document data model into the web page template information or by directly displaying the replaced document data model in the web page template information. Finally, a target document in a preset format is obtained.
[0113] Optionally, in the embodiment of the present disclosure, the operation of converting the format of the target document to generate the target PDF document may specifically include:
[0114] The target document in the preset format is converted using a preset document conversion method to obtain the corresponding target PDF document.
[0115] In the embodiment of the present disclosure, the preset document conversion method may be a method of converting a preset format into a PDF format, the preset format may be an HTML format, and the preset document conversion method may be an open HTML to PDF tool.
[0116] For example, in one implementation, the html2pdf service may be called to convert the target document in a preset format to obtain a corresponding target PDF document. The html2pdf service may convert an html report file consisting of an html document and css code into a pdf format file. The input parameter of the html2pdf service may be the html report content, and the output parameter of the html2pdf service may be the PDF report file.
[0117] For example, taking the generation of blood glucose digital therapy monitoring report as an example, in response to the generation instruction of continuous blood glucose monitoring PDF report, the DUCC dynamic configuration service is called to query the template configuration information of the report. The template configuration information may include: html report template URL address, chart template variable array, where the chart template variable array may include TIR pie chart template variable, AGP map template variable, blood glucose trend chart template variable. Call the blood glucose data query service to query all the data required for report display according to the patient ID, device unique number and monitoring time period, and generate a document data model according to the display model of the report template. The report data model may include: basic patient information. For example: name, gender, age, height, weight, waist circumference and other information, basic report information, such as: device name, device number, monitoring time, report time, effective time and other information, basic blood sugar indicators, such as: estimated glycosylated hemoglobin, average glucose value, maximum blood sugar fluctuation range, average blood sugar fluctuation range, glucose standard deviation, glucose coefficient of variation and other information, TIR pie chart data, such as: proportion of time meeting standard blood sugar, proportion of high blood sugar time, proportion of low blood sugar time, AGP map data, such as: 10% percentile, 90% percentile, 25% percentile, 75% percentile, median, target range and other information, blood sugar trend chart data, such as: The 10% quantile, 90% quantile, 25% quantile, 75% quantile, average value of each day within the time period, the highest value, the lowest value and other information within the time period, daily statistical data, such as: the average glucose value, standard deviation, coefficient of variation, highest glucose value, lowest glucose value, percentage of glucose ≥13.9mmol / L, percentage of glucose ≥10.0mmol / L, percentage of glucose ≥7.8mmol / L, percentage of glucose ≤3.9mmol / L, percentage of glucose ≤2.8mmol / L, percentage of 3.9mmol / L<glucose<10mmol / L and other information within the time period. According to the chart configuration information contained in the template configuration information, the drawing parameter templates are constructed in sequence. For each drawing parameter template read, the Template service is called in sequence, and the obtained document data model is applied to generate the drawing parameter configuration values corresponding to each chart. Specifically, it can be expressed as the following pseudo code: TIR pie chart parameter configuration = apply (TIR pie chart parameter configuration template, report data model. TIR pie chart data model); AGP graph parameter configuration = apply (AGP graph parameter configuration template, report data model. AGP graph data model); blood glucose trend graph parameter configuration = apply (blood glucose trend graph parameter configuration template, report data model. Blood glucose trend graph data model).Call the node echarts drawing service in sequence, draw a chart, and convert the chart into an image and output it in base64 encoding format. Replace the recorded chart parameters with the target image to obtain the replaced document data model. Generate the target document according to the template network address indicated in the template configuration information and the replaced document data model. Specifically, it can be represented by the following pseudo code: report data model.var_TIR pie chart = draw (TIR pie chart parameter configuration).base64; report data model.var_AGP map = draw (AGP map parameter configuration).base64; report data model.var_blood sugar trend chart = draw (blood sugar trend chart parameter configuration).base64. Obtain the template network URL address indicated in the template configuration information, read the web page template information in html format, apply the replaced document data model in the web page template information, and obtain the target document in a preset format. Specifically, it can be represented by the following pseudo code: html report = apply (html report template, report data model). Convert the generated html format document to generate a target PDF document, and upload it to the object storage service (OSS) for download and viewing.
[0118] Figure 5 is a block diagram of a document generation device provided by an embodiment of the present disclosure, such as Figure 5 As shown, the device 30 may include:
[0119] A first acquisition module 301 is used to acquire template configuration information for generating a target PDF document in response to a document generation instruction;
[0120] A first generating module 302 is used to draw a chart according to the template configuration information and the document data model to generate a target image in a preset encoding format; the document data model is a document model generated by the data required by the target PDF document;
[0121] A replacement module 303, used to replace the parameter recorded by the target number in the document data model with the target image corresponding to the target number, to obtain a target document;
[0122] The second generating module 304 is used to convert the format of the target document to generate the target PDF document.
[0123] In summary, the document generation device provided by the embodiment of the present disclosure can respond to the document generation instruction, obtain the template configuration information for generating the target PDF document, draw the chart according to the template configuration information and the document data model, generate the target image of the preset encoding format, the document data model is a document model generated by the data required by the target PDF document, replace the parameter recorded in the document data model with the target image corresponding to the target number, obtain the target document, perform format conversion on the target document, and generate the target PDF document. In this way, by directly obtaining the template configuration information for generating the PDF document to generate the document model and the image corresponding to the chart, the problem of reducing the image display quality due to the influence of the screenshot resolution can be avoided, and the text content in the generated PDF document can be ensured to be captured and selected separately, which improves the clarity and accuracy of the content in the generated PDF document, and also avoids the problem of truncation of text or charts due to paging and cutting of the screenshot, which ensures the integrity of the text content and charts in the document and improves the display quality of the PDF document.
[0124] Optionally, the device 30 further includes:
[0125] A second acquisition module, used to acquire target data required to generate the target PDF document;
[0126] The third generating module is used to add the target data to the preset document presentation model to generate the document data model.
[0127] Optionally, the first generating module 302 is further configured to:
[0128] Constructing a drawing parameter template that conforms to the chart configuration information according to the chart configuration information included in the template configuration information;
[0129] Integrate and match the drawing parameter template with the document data model to generate drawing parameter configuration values for drawing each chart;
[0130] Draw charts respectively according to the drawing parameter configuration values to generate target pictures in the preset encoding format.
[0131] Optionally, the first generating module 302 is further configured to:
[0132] Based on the drawing parameter configuration values, drawing charts respectively using a preset drawing method to obtain multiple target charts;
[0133] The multiple target graphs are converted into images according to the preset coding format to generate target images in the preset coding format.
[0134] Optionally, the replacement module 303 is further used to:
[0135] Querying the chart parameters of the target number record in the document data model;
[0136] Replacing the chart parameters of the record with the target image corresponding to the target number to obtain a replaced document data model;
[0137] The target document is generated according to the template network address indicated in the template configuration information and the replaced document data model.
[0138] Optionally, the replacement module 303 is further used to:
[0139] Acquire web page template information according to the template network address indicated in the template configuration information;
[0140] The replaced document data model is applied to the web page template information to obtain the target document in a preset format.
[0141] Optionally, the second generating module 304 is further used to:
[0142] The target document in the preset format is converted using a preset document conversion method to obtain the corresponding target PDF document.
[0143] The specific details of each module in the above-mentioned document generation device have been described in detail in the corresponding document generation method, so they will not be repeated here.
[0144] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0145] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0146] In an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
[0147] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".
[0148] Refer to the following Figure 6 The electronic device 400 according to this embodiment of the present disclosure is described. Figure 6 The electronic device 400 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0149] like Figure 6 As shown, the electronic device 400 is in the form of a general computing device. The components of the electronic device 400 may include, but are not limited to: the at least one processing unit 410, the at least one storage unit 420, a bus 430 connecting different system components (including the storage unit 420 and the processing unit 410), and a display unit 440.
[0150] The storage unit stores program codes, which can be executed by the processing unit 410, so that the processing unit 410 performs the steps according to various exemplary embodiments of the present disclosure described in the above “Exemplary Method” section of this specification. For example, the processing unit 410 can perform the following steps: Figure 1 In the step S101 shown in the figure, in response to a document generation instruction, template configuration information for generating a target PDF document is obtained; in the step S102, a chart is drawn according to the template configuration information and a document data model to generate a target image in a preset encoding format; the document data model is a document model generated by data required for the target PDF document; in the step S103, a parameter recorded in the document data model with a target number is replaced with a target image corresponding to the target number to obtain a target document; in the step S104, the target document is format converted to generate the target PDF document.
[0151] The storage unit 420 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 4201 and / or a cache storage unit 4202 , and may further include a read-only storage unit (ROM) 4203 .
[0152] The storage unit 420 may also include a program / utility 4204 having a set (at least one) of program modules 4205, such program modules 4205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0153] Bus 430 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0154] The electronic device 400 may also communicate with one or more external devices 500 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 400, and / or communicate with any device that enables the electronic device 400 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 450. Furthermore, the electronic device 400 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 460. As shown, the network adapter 460 communicates with other modules of the electronic device 400 via a bus 430. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 400, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0155] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0156] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible implementations, various aspects of the present disclosure may also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary implementations of the present disclosure described in the above "Exemplary Method" section of the present specification.
[0157] According to the program product for implementing the above method in the embodiment of the present disclosure, it can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present disclosure is not limited thereto. In this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.
[0158] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0159] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0160] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0161] Program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0162] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present disclosure, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.
[0163] Other embodiments of the present disclosure will be readily apparent to those skilled in the art after considering the specification and practicing the inventions invented herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not invented by the present disclosure. The specification and examples are to be considered merely exemplary, and the true scope and spirit of the present disclosure are indicated by the claims.
Claims
1. A document generation method, It is characterized in that The method comprises: In response to the document generation instruction, obtaining template configuration information for generating a target PDF document; Draw a chart according to the template configuration information and the document data model to generate a target image in a preset encoding format; the document data model is a document model generated by the data required by the target PDF document; Replacing the parameter recorded by the target number in the document data model with the target image corresponding to the target number to obtain the target document; The target document is formatted and generated into the target PDF document.
2. The method according to claim 1, It is characterized in that Before drawing a chart according to the template configuration information and the document data model to generate a target image in a preset encoding format, the method further includes: Acquire target data required to generate the target PDF document; The target data is added to a preset document presentation model to generate the document data model.
3. The method according to claim 2, It is characterized in that The step of drawing a chart according to the template configuration information and the document data model to generate a target image in a preset encoding format includes: Constructing a drawing parameter template that conforms to the chart configuration information according to the chart configuration information included in the template configuration information; Integrate and match the drawing parameter template with the document data model to generate drawing parameter configuration values for drawing each chart; Draw charts respectively according to the drawing parameter configuration values to generate target pictures in the preset encoding format.
4. The method according to claim 1, It is characterized in that The step of drawing charts respectively according to the drawing parameter configuration values to generate a target picture in the preset coding format includes: Based on the drawing parameter configuration values, drawing charts respectively using a preset drawing method to obtain multiple target charts; The multiple target graphs are converted into images according to the preset coding format to generate target images in the preset coding format.
5. The method according to claim 4, It is characterized in that The step of replacing the parameter recorded by the target number in the document data model with the target image corresponding to the target number to obtain the target document includes: Querying the chart parameters of the target number record in the document data model; Replacing the chart parameters of the record with the target image corresponding to the target number to obtain a replaced document data model; The target document is generated according to the template network address indicated in the template configuration information and the replaced document data model.
6. The method according to claim 5, It is characterized in that The step of generating the target document according to the template network address indicated in the template configuration information and the replaced document data model comprises: Acquire web page template information according to the template network address indicated in the template configuration information; The replaced document data model is applied to the web page template information to obtain the target document in a preset format.
7. The method according to claim 6, It is characterized in that The step of converting the target document into a format to generate the target PDF document includes: The target document in the preset format is converted using a preset document conversion method to obtain the corresponding target PDF document.
8. A document generation device, It is characterized in that The device comprises: A first acquisition module, configured to acquire, in response to a document generation instruction, template configuration information for generating a target PDF document; A first generating module, configured to draw a chart according to the template configuration information and a document data model to generate a target image in a preset encoding format; the document data model is a document model generated by the data required by the target PDF document; A replacement module, used to replace the parameters recorded by the target number in the document data model with the target image corresponding to the target number, so as to obtain a target document; The second generating module is used to convert the format of the target document to generate the target PDF document.
9. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the document generation method according to any one of claims 1 to 7 is implemented.
10. An electronic device, It is characterized in that include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the document generation method according to any one of claims 1 to 7 by executing the executable instructions.
Citation Information
Cited By
Artificial intelligence-based generator for synthetic medical charts
WO2026173801A1
