PDF (Portable Document Format) generation method and device, electronic equipment and storage medium

Through data optimization and template configuration rendering processing on the server side, the problem of high memory usage and performance degradation when the client browser generates PDF is solved, fast and accurate PDF generation is achieved, and the generation efficiency and stability are improved.

CN118657133APending Publication Date: 2024-09-17PING AN BANK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410743710.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

When the existing technology generates a PDF containing long page content on a client browser, it is prone to problems such as high memory usage and long script execution time, resulting in lags, performance degradation and freezes, especially when processing large amounts of data and complex processes. layout and pictures.

Method used

By obtaining the preprocessed raw data, perform data optimization and compression, use template configuration and rendering processing to generate PDF files, reduce data redundancy and memory usage, and use the powerful performance of the server side for PDF generation.

Benefits of technology

It achieves fast and accurate generation of PDF files, avoids lags and slow operation, reduces memory usage, and improves the efficiency and stability of PDF generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118657133A
    Figure CN118657133A
Patent Text Reader

Abstract

The embodiment of the invention provides a PDF generation method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining preprocessed original data; template configuration is carried out according to business requirements, and a markup language template is obtained; inserting the original data into the markup language template to obtain a to-be-rendered template; performing rendering processing on the to-be-rendered template to obtain rendered page data; and converting the rendering page data to obtain a PDF (Portable Document Format) file. By implementing the embodiment of the invention, the PDF file can be quickly and accurately generated, when the data content is excessive and the layout page is complex, the PDF file can also be completely generated, the conditions of lagging, slow operation and the like cannot be caused, the data redundancy can be reduced, and the memory occupied in the operation process can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a PDF generation method, device, electronic device and storage medium. Background Art

[0002] With the advancement of digital transformation and the increasing demand for reliable document generation, PDF generation plays an important role in many industries and fields. Especially in the fields of e-commerce and finance, there is a large demand for displaying, delivering and archiving data and content in PDF (an electronic file format).

[0003] In the prior art, when a PDF containing long page content needs to be generated on a client browser, the jsPDF library is usually used for processing. When a large amount of data, complex layouts, and a large number of pictures need to be processed, jsPDF needs to be executed in the client browser, which is prone to excessive memory usage and long script execution time, resulting in problems such as freezes, performance degradation, and freezing. In addition, the processing and rendering of pictures require a large amount of computing resources. jsPDF also faces some limitations when processing complex layouts and styles, and manual adjustment and processing are required for complex layouts and adaptive designs. Therefore, when the page is very long and needs to process a large number of pictures, complex layouts, dynamic data, a large number of charts and other complex operations, the methods of the prior art can easily cause freezes, excessive memory usage, slow running speed, performance degradation, and other conditions, which ultimately lead to PDF generation failure. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a PDF generation method, device, electronic device and storage medium, which can quickly and accurately generate PDF files. When the data content is too much and the layout page is complex, the PDF file can also be completely generated without causing jamming, slow operation, etc., and can reduce data redundancy and reduce the memory occupied during operation.

[0005] In a first aspect, an embodiment of the present application provides a method for generating a PDF, the method comprising:

[0006] Obtain the preprocessed raw data;

[0007] Configure the template according to business requirements to obtain a markup language template;

[0008] Inserting the original data into the markup language template to obtain a template to be rendered;

[0009] Rendering the template to be rendered to obtain rendering page data;

[0010] The rendering page data is converted to obtain a PDF file.

[0011] In the above implementation process, the original data is inserted into the markup language template after template configuration, and then further rendered and converted, so that the PDF file can be generated quickly and accurately. When the data content is too much and the layout page is complex, the PDF file can also be completely generated without causing jamming or slow operation. It can reduce data redundancy and reduce the memory occupied during operation.

[0012] Furthermore, before the step of obtaining the pre-processed raw data, the method further includes:

[0013] Get the data to be displayed;

[0014] The data to be displayed are optimized and compressed in sequence to obtain preprocessed original data.

[0015] In the above implementation process, the data to be displayed is optimized and compressed, which can reduce the storage space occupied by the data to be displayed, increase the running speed of the conversion process, improve the conversion efficiency, and shorten the time.

[0016] Furthermore, the step of configuring the template according to the business requirements to obtain the markup language template includes:

[0017] Get configuration data;

[0018] Build a basic template based on the business requirements;

[0019] The configuration data is used to configure the basic template to obtain the markup language template. In the above implementation process, the basic template is constructed according to business requirements, and then the basic template is configured according to the configuration data, which can improve the accuracy of the markup language template and ensure the adaptability of the markup language template to business requirements.

[0020] Furthermore, the step of configuring the basic template with the configuration data to obtain the markup language template includes:

[0021] Obtaining a layout style required for configuring the markup language template according to the structure of the basic template;

[0022] Obtaining configuration data corresponding to the layout style from the configuration data;

[0023] The configuration data corresponding to the layout style is added to the basic template to obtain the markup language template.

[0024] In the above implementation process, according to the configuration data corresponding to the layout style in the configuration data, adding it to the basic template can make the template structure of the obtained markup language template more compatible with the data content, simplifying the subsequent conversion process.

[0025] Furthermore, the step of inserting the original data into the markup language template to obtain a template to be rendered includes:

[0026] Get the template engine;

[0027] Dynamically processing the original data according to the template engine to obtain dynamic data;

[0028] The dynamic data is inserted into the markup language template to obtain the template to be rendered.

[0029] In the above implementation process, the original data is dynamically processed according to the template engine so that the original data can be adjusted according to the markup language template, which can simplify the markup language template and facilitate conversion of the markup language template.

[0030] Furthermore, the step of rendering the template to be rendered to obtain rendering page data includes:

[0031] Get the rendering request;

[0032] Extracting rendering request data according to the rendering request;

[0033] The rendering request data is rendered into the template to be rendered according to the template engine to obtain the rendering page data.

[0034] In the above implementation process, by rendering the rendering request data into the template to be rendered, the rendering request data can be obtained in real time according to the rendering request, so that the rendering request data can be more closely matched to the template to be rendered, thereby improving rendering efficiency.

[0035] Furthermore, the step of converting the rendered page data to obtain a PDF file includes:

[0036] Obtain a conversion tool library containing data types of the rendered page data;

[0037] Calling a conversion command according to the conversion tool library;

[0038] The rendering page data is converted into the PDF file according to the conversion command.

[0039] In the above implementation process, calling the conversion command through the conversion tool library and then performing data conversion can reduce jamming and ensure that the conversion process will not be affected by the complex structure of the rendering page data.

[0040] In a second aspect, an embodiment of the present application further provides a PDF generation device, the device comprising:

[0041] An acquisition module is used to obtain the preprocessed raw data;

[0042] A configuration module is used to configure the template according to business requirements to obtain a markup language template;

[0043] An inserting module, used for inserting the original data into the markup language template to obtain a template to be rendered;

[0044] A rendering module, used to render the template to be rendered to obtain rendering page data;

[0045] The conversion module is used to convert the rendering page data to obtain a PDF file.

[0046] In the above implementation process, the original data is inserted into the markup language template after template configuration, and then further rendered and converted, so that the PDF file can be generated quickly and accurately. When the data content is too much and the layout page is complex, the PDF file can also be completely generated without causing jamming or slow operation. It can reduce data redundancy and reduce the memory occupied during operation.

[0047] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in any one of the first aspects when executing the computer program.

[0048] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which instructions are stored. When the instructions are executed on a computer, the computer executes the method as described in any one of the first aspects.

[0049] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when running on a computer, enables the computer to execute the method as described in any one of the first aspects.

[0050] Other features and advantages of the present disclosure will be set forth in the following description, or some features and advantages may be inferred or unambiguously determined from the description, or may be learned by implementing the above-mentioned technology of the present disclosure.

[0051] And it can be implemented according to the contents of the specification. The following is a detailed description of the preferred embodiments of the present application with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the range values. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying any creative work.

[0053] Figure 1 A schematic diagram of a PDF generation method provided in an embodiment of the present application;

[0054] Figure 2 A schematic diagram of the structure of a PDF generation device provided in an embodiment of the present application;

[0055] Figure 3 A schematic diagram of the structure of a PDF generation device provided in an embodiment of the present application;

[0056] Figure 4 A schematic diagram of the structural composition of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0057] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0058] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0059] The specific implementation methods of the present application are further described in detail below in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present application, but are not used to limit the scope of the present application.

[0060] Embodiment 1

[0061] Figure 1 It is a flowchart of the method for generating PDF provided in the embodiment of the present application, such as Figure 1 As shown, the method includes:

[0062] S1, obtain the preprocessed raw data;

[0063] S2, configure the template according to business requirements to obtain a markup language template;

[0064] S3, inserting the original data into the markup language template to obtain a template to be rendered;

[0065] S4, rendering the template to be rendered to obtain rendering page data;

[0066] S5, converting the rendered page data to obtain a PDF file.

[0067] In the above implementation process, the original data is inserted into the markup language template after template configuration, and then further rendered and converted, so that the PDF file can be generated quickly and accurately. When the data content is too much and the layout page is complex, the PDF file can also be completely generated without causing jamming or slow operation. It can reduce data redundancy and reduce the memory occupied during operation.

[0068] With the advancement of digital transformation and the increasing demand for reliable document generation, the use of server-side PDF generation will continue to develop and be applied to all walks of life. The performance, reliability and scalability of the server make the process of generating PDF more stable, efficient and flexible. Therefore, the embodiment of the present application proposes a solution to generate PDF files on the server side using powerful server performance to solve the performance problem when generating PDF files on the client browser.

[0069] Furthermore, before the step of obtaining the preprocessed raw data, the method further includes:

[0070] Get the data to be displayed;

[0071] The data to be displayed is optimized and compressed in turn to obtain the preprocessed original data.

[0072] In the above implementation process, the data to be displayed is optimized and compressed, which can reduce the storage space occupied by the data to be displayed, increase the running speed of the conversion process, improve the conversion efficiency, and shorten the time.

[0073] The data to be displayed in the embodiment of the present application can be obtained from a database or a call interface, and the image processing library and tools are used to perform operations such as optimization, compression and scaling on the image.

[0074] Furthermore, S2 includes:

[0075] Get configuration data;

[0076] Build basic templates based on business needs;

[0077] The configuration data is used to configure the basic template to obtain a markup language template.

[0078] In the above implementation process, a basic template is constructed according to business requirements, and then the basic template is configured according to configuration data, which can improve the accuracy of the markup language template and ensure the adaptability of the markup language template to business requirements.

[0079] According to business needs, multiple sets of markup language templates are created in advance. For example, the markup language template can be a HyperText Markup Language (HTML) template. The embodiment of the present application uses HTML, Cascading Style Sheets (CSS) and JavaScript to build a web page template containing a complex structure to represent the layout and style of icons, tables, texts and pictures.

[0080] Furthermore, the step of configuring the basic template with the configuration data to obtain the markup language template includes:

[0081] Obtain the layout style required by the configuration markup language template according to the structure of the basic template;

[0082] Obtaining configuration data corresponding to the layout style in the configuration data;

[0083] The configuration data corresponding to the layout style is added to the basic template to obtain a markup language template.

[0084] In the above implementation process, according to the configuration data corresponding to the layout style in the configuration data, adding it to the basic template can make the template structure of the obtained markup language template more compatible with the data content, simplifying the subsequent conversion process.

[0085] Furthermore, S3 includes:

[0086] Get the template engine;

[0087] The original data is dynamically processed according to the template engine to obtain dynamic data;

[0088] Insert dynamic data into the markup language template to obtain a template to be rendered.

[0089] In the above implementation process, the original data is dynamically processed according to the template engine so that the original data can be adjusted according to the markup language template, which can simplify the markup language template and facilitate conversion of the markup language template.

[0090] The embodiment of the present application uses a template engine to dynamically insert the original data prepared by the server into the HTML template.

[0091] Furthermore, S4 includes:

[0092] Get the rendering request;

[0093] Extract rendering request data according to the rendering request;

[0094] The rendering request data is rendered into the template to be rendered according to the template engine to obtain the rendering page data.

[0095] In the above implementation process, by rendering the rendering request data into the template to be rendered, the rendering request data can be obtained in real time according to the rendering request, so that the rendering request data can be more closely matched to the template to be rendered, thereby improving rendering efficiency.

[0096] The embodiment of the present application uses a server-side framework for rendering. Specifically, a server-side framework of a suitable technology stack is selected, such as Node.js (Express, Koa) and other server-side frameworks.

[0097] When the rendering request is received from the client using the routing and handling procedures of the server-side framework, the template engine in the server-side framework is used to apply the prepared data to the HTML template to generate the final rendered HTML (ie, rendered page data).

[0098] The embodiment of the present application is rendered through a template engine, and the server side usually has a professional image processing library and tools that can efficiently process and render images. Using the image processing library on the server side, images can be optimized, compressed and processed to improve rendering speed and image quality.

[0099] Furthermore, S5 includes:

[0100] Get the conversion tool library containing the data type of the rendered page data;

[0101] Call the conversion command according to the conversion tool library;

[0102] The rendered page data is converted into a PDF file according to the conversion command.

[0103] In the above implementation process, calling the conversion command through the conversion tool library and then performing data conversion can reduce jamming and ensure that the conversion process will not be affected by the complex structure of the rendering page data.

[0104] The embodiment of the present application selects a PDF generation tool with a suitable technology stack, such as the wkhtmltopdf conversion tool library.

[0105] Use wkhtmltopdf to convert HTML to PDF files. Use the PDF conversion tool's API or command line tool to convert server-generated HTML to PDF files.

[0106] After obtaining the PDF file, save the PDF to the file system, use the file operation function provided by the server-side framework to save the generated PDF file to the server's file system, and assign it a unique file name.

[0107] The embodiments of the present application can process large amounts of data and complex operations, thereby providing higher performance and reliability. Compared to the client browser, the server can process the computing tasks required to generate the PDF faster, reducing the burden on the client and avoiding problems such as freezes, performance degradation, and freezes.

[0108] The method of the embodiment of the present application can better manage and optimize memory usage, ensure the stability of PDF generation and successful export, and the conversion process has high scalability and customization capabilities, and can be configured with multiple HTML templates, thereby enhancing scalability.

[0109] Embodiment 2

[0110] In order to execute the method corresponding to the above embodiment 1 to achieve the corresponding functions and technical effects, a PDF generation device is provided below, such as Figure 2 As shown, the device comprises:

[0111] Acquisition module 1, used to acquire the pre-processed raw data;

[0112] Configuration module 2, used to configure the template according to business requirements to obtain a markup language template;

[0113] Insertion module 3, used for inserting original data into the markup language template to obtain a template to be rendered;

[0114] Rendering module 4, used to render the template to be rendered to obtain rendering page data;

[0115] The conversion module 5 is used to convert the rendering page data to obtain a PDF file.

[0116] In the above implementation process, the original data is inserted into the markup language template after template configuration, and then further rendered and converted, so that the PDF file can be generated quickly and accurately. When the data content is too much and the layout page is complex, the PDF file can also be completely generated without causing jamming or slow operation. It can reduce data redundancy and reduce the memory occupied during operation.

[0117] Furthermore, the device also includes a preprocessing module 6, which is used to:

[0118] Get the data to be displayed;

[0119] The data to be displayed is optimized and compressed in turn to obtain the preprocessed original data.

[0120] In the above implementation process, the data to be displayed is optimized and compressed, which can reduce the storage space occupied by the data to be displayed, increase the running speed of the conversion process, improve the conversion efficiency, and shorten the time.

[0121] Furthermore, the configuration module 2 is also used for:

[0122] Get configuration data;

[0123] Build basic templates based on business needs;

[0124] The configuration data is used to configure the basic template to obtain a markup language template.

[0125] In the above implementation process, a basic template is constructed according to business requirements, and then the basic template is configured according to configuration data, which can improve the accuracy of the markup language template and ensure the adaptability of the markup language template to business requirements.

[0126] Furthermore, the configuration module 2 is also used for:

[0127] Obtain the layout style required by the configuration markup language template according to the structure of the basic template;

[0128] Obtaining configuration data corresponding to the layout style in the configuration data;

[0129] The configuration data corresponding to the layout style is added to the basic template to obtain a markup language template.

[0130] In the above implementation process, according to the configuration data corresponding to the layout style in the configuration data, adding it to the basic template can make the template structure of the obtained markup language template more compatible with the data content, simplifying the subsequent conversion process.

[0131] Furthermore, the insertion module 3 is also used for:

[0132] Get the template engine;

[0133] The original data is dynamically processed according to the template engine to obtain dynamic data;

[0134] Insert dynamic data into the markup language template to obtain a template to be rendered.

[0135] In the above implementation process, the original data is dynamically processed according to the template engine so that the original data can be adjusted according to the markup language template, which can simplify the markup language template and facilitate conversion of the markup language template.

[0136] Furthermore, the rendering module 4 is also used for:

[0137] Get the rendering request;

[0138] Extract rendering request data according to the rendering request;

[0139] The rendering request data is rendered into the template to be rendered according to the template engine to obtain the rendering page data.

[0140] In the above implementation process, by rendering the rendering request data into the template to be rendered, the rendering request data can be obtained in real time according to the rendering request, so that the rendering request data can be more closely matched to the template to be rendered, thereby improving rendering efficiency.

[0141] Furthermore, the conversion module 5 is also used for:

[0142] Get the conversion tool library containing the data type of the rendered page data;

[0143] Call the conversion command according to the conversion tool library;

[0144] The rendered page data is converted into a PDF file according to the conversion command.

[0145] In the above implementation process, calling the conversion command through the conversion tool library and then performing data conversion can reduce jamming and ensure that the conversion process will not be affected by the complex structure of the rendering page data.

[0146] The PDF generation device described above can implement the method described in the first embodiment described above. The options described in the first embodiment described above are also applicable to this embodiment and will not be described in detail here.

[0147] The rest of the contents of the embodiments of the present application can refer to the contents of the above-mentioned embodiment 1, and will not be repeated in this embodiment.

[0148] Embodiment 3

[0149] An embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the PDF generation method of the first embodiment.

[0150] Optionally, the above-mentioned electronic device may be a server.

[0151] See also Figure 4 , Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device may include a processor 41, a communication interface 42, a memory 43 and at least one communication bus 44. The communication bus 44 is used to realize direct connection and communication between these components. The communication interface 42 of the device in the embodiment of the present application is used to communicate signaling or data with other node devices. The processor 41 can be an integrated circuit chip with signal processing capabilities.

[0152] The processor 41 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor 31 can also be any conventional processor, etc.

[0153] The memory 43 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electric erasable programmable read-only memory (EEPROM), etc. The memory 43 stores computer readable instructions. When the computer readable instructions are executed by the processor 41, the device can execute the above-mentioned Figure 1 The method embodiment involves various steps.

[0154] Optionally, the electronic device may further include a storage controller and an input / output unit. The memory 43, the storage controller, the processor 41, the peripheral interface, and the input / output unit are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components may be electrically connected to each other via a communication bus 44. The processor 41 is used to execute executable modules stored in the memory 43, such as software function modules or computer programs included in the device.

[0155] The input and output unit is used to provide users with the task creation and to create an optional time period or preset execution time for the task to enable interaction between the user and the server. The input and output unit can be, but is not limited to, a mouse and a keyboard.

[0156] Understandably, Figure 4 The structure shown is for illustration only. The electronic device may also include Figure 4 More or fewer components as shown, or with Figure 4 Different configurations are shown. Figure 4 Each component shown in the figure can be implemented by hardware, software or a combination thereof.

[0157] In addition, an embodiment of the present application further provides a computer-readable storage medium storing a computer program, which implements the PDF generation method of the first embodiment when the computer program is executed by a processor.

[0158] The embodiment of the present application also provides a computer program product, which, when running on a computer, enables the computer to execute the method described in the method embodiment.

[0159] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart, can be implemented with a dedicated hardware-based device that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0160] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0161] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.

[0162] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application. It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.

[0163] The above is only a specific implementation of the present application, but the protection range of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical range disclosed in the present application, which should be included in the protection range of the present application. Therefore, the protection range of the present application should be based on the protection range of the claims.

[0164] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

Claims

1. A method for generating a PDF, It is characterized in that The method comprises: Obtain the preprocessed raw data; Configure the template according to business requirements to obtain a markup language template; Inserting the original data into the markup language template to obtain a template to be rendered; Rendering the template to be rendered to obtain rendering page data; The rendering page data is converted to obtain a PDF file.

2. The method for generating a PDF according to claim 1, It is characterized in that Before the step of obtaining the pre-processed raw data, the method further includes: Get the data to be displayed; The data to be displayed are optimized and compressed in sequence to obtain preprocessed original data.

3. The method for generating a PDF according to claim 1, It is characterized in that The step of configuring the template according to the business requirements to obtain the markup language template includes: Get configuration data; Build a basic template based on the business requirements; The basic template is configured with the configuration data to obtain the markup language template.

4. The method for generating a PDF according to claim 3, It is characterized in that The step of configuring the basic template with the configuration data to obtain the markup language template includes: Obtaining a layout style required for configuring the markup language template according to the structure of the basic template; Obtaining configuration data corresponding to the layout style from the configuration data; The configuration data corresponding to the layout style is added to the basic template to obtain the markup language template.

5. The method for generating a PDF according to claim 1, It is characterized in that The step of inserting the original data into the markup language template to obtain a template to be rendered includes: Get the template engine; Dynamically processing the original data according to the template engine to obtain dynamic data; The dynamic data is inserted into the markup language template to obtain the template to be rendered.

6. The method for generating a PDF according to claim 1, It is characterized in that The step of rendering the template to be rendered to obtain rendering page data includes: Get the rendering request; Extracting rendering request data according to the rendering request; The rendering request data is rendered into the template to be rendered according to the template engine to obtain the rendering page data.

7. The method for generating a PDF according to claim 1, It is characterized in that The step of converting the rendered page data to obtain a PDF file includes: Obtain a conversion tool library containing data types of the rendered page data; Calling a conversion command according to the conversion tool library; The rendering page data is converted into the PDF file according to the conversion command.

8. A PDF generation device, It is characterized in that The device also includes: An acquisition module is used to obtain the preprocessed raw data; A configuration module is used to configure the template according to business requirements to obtain a markup language template; An inserting module, used for inserting the original data into the markup language template to obtain a template to be rendered; A rendering module, used to render the template to be rendered to obtain rendering page data; The conversion module is used to convert the rendering page data to obtain a PDF file.

9. An electronic device, It is characterized in that The electronic device comprises a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the PDF generation method according to any one of claims 1 to 7.

10. A storage medium, It is characterized in that The device stores a computer program, which, when executed by a processor, implements the PDF generation method according to any one of claims 1 to 7.