PDF file generation method and system, electronic equipment and storage medium
By designing general FTL template files and using the target template engine and iText library to generate PDF template data, the shortcomings of existing PDF generation technology in complex styles and page layout processing are solved, and highly customized and diversified PDF file generation is achieved, reducing costs and risks, and improving flexibility and scalability.
Patent Information
- Application Number
- CN202411778350.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-04-22
AI Technical Summary
Existing PDF generation technologies such as Apache PDFBox and iText have shortcomings in dealing with complex styles and page layouts. In particular, Apache PDFBox has limited capabilities in complex styles. iText has limited functionality or requires a commercial license to purchase a business license due to different versions, which increases the cost and risk of use.
By designing a general FTL template file, using the target template engine and iText library to generate PDF template data, supporting complex table header design and paging table header reproduction, and filling the data to be displayed into the template data through the Java library to generate the target PDF file.
It realizes highly customized and diversified PDF file generation, enhances the expressiveness of PDF content, reduces the cost and risks of commercial applications, and improves the flexibility and scalability of projects.
Smart Images

Figure CN119862870A_ABST
Abstract
Description
Background Art
[0002] Current PDF generation technologies such as Apache PDFBox and iText have shortcomings when dealing with complex styles and page layouts. In addition, Apache PDFBox has limited capabilities for complex styles, and iText also has the disadvantages of limited functionality or the need to purchase commercial licenses or open source code due to different versions, which increases the cost and risk of use.
[0003] Therefore, it is urgent to provide a technical solution to solve the above problems. Summary of the invention
[0004] In order to solve the above technical problems, the present invention provides a PDF file generation method, system, electronic device and storage medium.
[0005] In a first aspect, the present invention provides a method for generating a PDF file, and the technical solution of the method is as follows:
[0006] Generate PDF template data based on the data to be displayed and PDF design requirements, and use FTL templates;
[0007] Fill the data to be displayed into the PDF template data to obtain a target PDF file.
[0008] The beneficial effects of a PDF file generation method of the present invention are as follows:
[0009] The method of the present invention realizes highly customized and diversified PDF file generation by designing a universal FTL template file, supports complex header design and page header reproduction, and reduces the cost and risk of commercial applications while enhancing the expressiveness of PDF content, and also improves the flexibility and scalability of the project.
[0010] Based on the above solution, the PDF file generation method of the present invention can also be improved as follows.
[0011] In an optional manner, the step of generating PDF template data according to the data to be displayed and the PDF design requirements and using the FTL template includes:
[0012] Generate the FTL template using the target template engine, and write the template language code and the CSS code in the FTL template according to the PDF design requirements to generate the first template data;
[0013] According to the PDF design requirements, the Document class and the PdfWriter class in iText are called to generate the second template data;
[0014] The first template data and the second template data together constitute the PDF template data.
[0015] In the above optional method, by using the target template engine to generate FTL templates and combining CSS custom styles, the layout and style design of the PDF file are more flexible and diverse. At the same time, the second template data is generated through the Document and PdfWriter classes in the iText library to ensure precise control of page settings and enhance the customization capability of PDF file generation.
[0016] In an optional manner, the second template data includes: at least one of: page size, page margin, header and footer, picture background, watermark and cover;
[0017] The steps of calling the Document class and the PdfWriter class in iText to generate the second template data include:
[0018] Using the Document class, setting at least one of the page size, the page margin, the header and footer, and the cover;
[0019] Using the PdfWriter class, at least one of the picture background and the watermark is set.
[0020] In the above optional methods, by setting the page size, page margins, headers and footers, image backgrounds, watermarks, covers and other elements in detail, you can ensure that the generated PDF file is more professional and consistent in vision and structure, meet various complex needs, and enhance the aesthetics of the document.
[0021] In an optional manner, the step of filling the to-be-displayed data into the PDF template data to obtain a target PDF file includes:
[0022] According to the PDF template data, the data to be displayed is imported into the process method provided by the Template class in the target template engine to fill the data, thereby obtaining the data to be processed;
[0023] The target Java library is used to convert the data to be processed into the target PDF file.
[0024] In the above optional method, the data to be displayed is imported into the process method provided by the Template class in the target template engine for data filling, and then the processed data is converted into a PDF file using the Java library, which simplifies the process of data filling and file generation and improves development efficiency and accuracy of file generation.
[0025] In an optional manner, the first template data includes: at least one of content layout and content style.
[0026] In the above optional method, by defining the content layout and content style in the FTL template, the consistency and flexibility of the content structure and style design of the PDF file are ensured, complex content layout and diverse style requirements are supported, and the expressiveness of the PDF file is enhanced.
[0027] In a second aspect, the present invention provides a PDF file generation system, the technical solution of the system is as follows:
[0028] The PDF file generation system comprises: a setting module and an execution module;
[0029] The setting module is used to: generate PDF template data according to the data to be displayed and the PDF design requirements, and using the FTL template;
[0030] The execution module is used to fill the data to be displayed into the PDF template data to obtain a target PDF file.
[0031] The beneficial effects of a PDF file generation system of the present invention are as follows:
[0032] The system of the present invention realizes highly customized and diversified PDF file generation by designing a universal FTL template file, supports complex header design and page header reproduction, and reduces the cost and risk of commercial applications while enhancing the expressiveness of PDF content, and also improves the flexibility and scalability of the project.
[0033] Based on the above solution, the PDF file generation system of the present invention can also be improved as follows.
[0034] In an optional manner, the setting module is specifically used to:
[0035] Generate the FTL template using the target template engine, and write the template language code and the CSS code in the FTL template according to the PDF design requirements to generate the first template data;
[0036] According to the PDF design requirements, the Document class and the PdfWriter class in iText are called to generate the second template data;
[0037] The first template data and the second template data together constitute the PDF template data.
[0038] In the above optional method, by using the target template engine to generate FTL templates and combining CSS custom styles, the layout and style design of the PDF file are more flexible and diverse. At the same time, the second template data is generated through the Document and PdfWriter classes in the iText library to ensure precise control of page settings and enhance the customization capability of PDF file generation.
[0039] In an optional manner, the second template data includes: at least one of page size, page margin, header and footer, picture background, watermark and cover;
[0040] The setting module is specifically used for:
[0041] Using the Document class, setting at least one of the page size, the page margin, the header and footer, and the cover;
[0042] Using the PdfWriter class, at least one of the picture background and the watermark is set.
[0043] In the above optional methods, by setting the page size, page margins, headers and footers, image backgrounds, watermarks, covers and other elements in detail, you can ensure that the generated PDF file is more professional and consistent in vision and structure, meet various complex needs, and enhance the aesthetics of the document.
[0044] In a third aspect, a technical solution of an electronic device of the present invention is as follows:
[0045] The invention comprises a memory, a processor and a program stored in the memory and running on the processor. When the processor executes the program, the steps of the PDF file generating method of the present invention are realized.
[0046] In a fourth aspect, the present invention provides a computer-readable storage medium having the following technical solution:
[0047] The computer-readable storage medium stores instructions. When the computer-readable storage medium reads the instructions, the computer-readable storage medium executes the steps of the PDF file generation method of the present invention.
[0048] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] The accompanying drawings are only used to illustrate the embodiments and are not to be considered as limiting the present invention. In addition, the same reference symbols are used to represent the same components throughout the accompanying drawings. In the accompanying drawings:
[0050] Figure 1 A schematic diagram of a flow chart of an embodiment of a method for generating a PDF file according to the present invention;
[0051] Figure 2 Schematic diagram of the overall process of generating PDF files;
[0052] Figure 3 A schematic diagram of the structure of an embodiment of a PDF file generation system of the present invention;
[0053] Figure 4 The figure is a schematic structural diagram of an embodiment of an electronic device of the present invention. DETAILED DESCRIPTION
[0054] Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein.
[0055] Figure 1 FIG. 1 is a flow chart showing an embodiment of a method for generating a PDF file provided by the present invention, wherein the method is executed by a controller. Figure 1 As shown, the following steps are included:
[0056] S1. Generate PDF template data based on the data to be displayed and PDF design requirements, and use the FTL template. In S1:
[0057] 1) Data to be displayed refers to the specific content that needs to be presented in the generated PDF file. The data to be displayed in the PDF can be obtained by user input or querying the database, including but not limited to user information, product information, statistical data, and table data. The data to be displayed is the core content of the PDF file. Through the processing of the target template engine, the data to be displayed can be dynamically inserted into the pre-designed PDF template data to generate a PDF file with a specific format. The flexibility of the data to be displayed can support the generation of a variety of PDF files to meet different business needs.
[0058] 2) PDF design requirements are the visual and structural requirements for the generated PDF files, including page layout, style, header, footer, page size, page margins, background image, watermark, etc. Multiple requirements determine the final appearance and format of the PDF file. PDF design requirements are used to guide the generation and setting of templates to ensure that the final generated PDF file meets specific design specifications and business requirements. Design requirements can generate highly customized PDF files, such as complex header design, page header reappearance, background image or watermark, etc., thereby enhancing the expressiveness and professionalism of PDF files.
[0059] 3) PDF template data is template data generated based on the data to be displayed and PDF design requirements, and contains the structure information and style information of the PDF file. PDF template data consists of two parts: first template data and second template data. The first template data includes content layout information and style information, and the second template data includes information such as page size, left and right margins, top and bottom margins, headers, footers, image backgrounds, watermarks and covers. PDF template data is the basic framework for generating the target PDF file, which defines the overall structure and style of the PDF file. The data to be displayed will be filled in the corresponding position according to the definition of the PDF template data. Through template data, highly customized and diversified PDF file generation can be achieved, supporting complex layout and style design, and improving the flexibility and scalability of PDF files.
[0060] Specifically, the controller generates PDF template data based on the data to be displayed and the PDF design requirements, and uses the FTL template.
[0061] S2. Fill the data to be displayed into the PDF template data to obtain the target PDF file. In S2:
[0062] 1) The target PDF file refers to the PDF file that is finally generated based on the data to be displayed and the PDF template data. The target PDF file is the final output of the entire PDF file generation process, which contains all the data content and design elements. The target PDF file is the final product of the entire method. By combining the data to be displayed and the PDF design requirements, a professional PDF file that meets business needs can be generated. The target PDF file can be used for a variety of purposes, such as report generation, contract signing, invoice issuance, etc., and has a wide range of commercial application value.
[0063] Specifically, the controller further fills the data to be displayed into the PDF template data to obtain the target PDF file.
[0064] The technical solution of this embodiment realizes highly customized and diversified PDF file generation by designing a universal FTL template file, supports complex header design and page header reproduction, and reduces the cost and risk of commercial applications while enhancing the expressiveness of PDF content, and also improves the flexibility and scalability of the project.
[0065] In an optional manner, the step of generating PDF template data according to the data to be displayed and the PDF design requirements and using the FTL template includes:
[0066] Generate an FTL template using a target template engine, and write a template language code and a CSS code in the FTL template according to PDF design requirements to generate first template data;
[0067] According to the PDF design requirements, the Document class and PdfWriter class in iText are called to generate the second template data;
[0068] The first template data and the second template data together constitute PDF template data.
[0069] The second template data includes: at least one of page size, page margin, header and footer, picture background, watermark and cover;
[0070] The steps of calling the Document class and the PdfWriter class in iText to generate the second template data include:
[0071] Use the Document class to set at least one of the page size, page margins, headers and footers, and cover pages.
[0072] Among them, the setPageSize method in the Document class is used to set the page size; the setMargins method in the Document class is used to set the left and right margins and the top and bottom margins of the page; the onEndPage method of the PdfPageEvent interface in iText is used to set the header using the onHeader method of the Document class, and the onFooter method of the Document class is used to set the footer; the addImage method in the Document class is used to set the cover.
[0073] Use the PdfWriter class to set at least one of the image background and watermark.
[0074] Among them, the PdfWriter class in iText is used to set the image background or watermark.
[0075] It should be noted that, according to the data to be displayed and the PDF style requirements, the target template engine is used to write the FTL template. By writing the FTL template, the template's universality, simplicity, and dynamic generation capabilities can be achieved, making the generation of PDF files more flexible and efficient.
[0076] In this embodiment, FreeMarker is used as the target template engine, wherein FreeMarker is an open source template engine, which can generate output text based on the template and the data to be changed, and the output text can be HTML code, email, configuration file, etc. The FTL template is developed using the template language provided by FreeMarker, and the template language code and CSS code are written in the FTL template to generate the first template data in the FTL template (wherein, the first template data includes: the layout and style of the data to be displayed), thereby ensuring a clear layout and rich styles, comparable to the real Web page effect. FreeMarker has rich grammatical instructions, including logical judgment, loop processing, and string output and operation, all of which are well supported.
[0077] Create the Document class and PdfWriter class in iText. By initializing the Document class and PdfWriter class, you can lay the foundation for subsequent data filling and PDF template data settings. Among them, iText is an open source PDF processing library; Document is the core class in iText. Through the Document class, you can define the cover, background, page size, page margins, content to be displayed, and other information of the PDF file; PdfWriter is also a core class in iText, responsible for writing the content in the Document class into the PDF file.
[0078] The PdfPageEvent interface in iText is used to implement the page paging monitoring function. Through the paging monitoring function, when generating PDF files, the display of headers, footers, background images, and watermarks on each page can be dynamically controlled. Furthermore, when paging a PDF file, headers, footers, and other content can be automatically inserted, and image backgrounds or watermarks can be added to the PDF file at the same time, improving the aesthetics and security of the document.
[0079] By passing the cover image to the addImage method in the Document class, you can set the cover image of the PDF file. By setting a unique cover image for the PDF file, you can enhance the professionalism and attractiveness of the document.
[0080] Specifically, the controller further generates an FTL template using the target template engine, and writes template language code and CSS code in the FTL template according to PDF design requirements to generate first template data; according to PDF design requirements, the Document class and PdfWriter class in iText are called to generate second template data.
[0081] In an optional manner, the step of filling the data to be displayed into the PDF template data to obtain the target PDF file includes:
[0082] According to the PDF template data, the data to be displayed is imported into the process method provided by the Template class in the target template engine to fill the data and obtain the data to be processed;
[0083] Utilize the target Java library to convert the processed data into the target PDF file.
[0084] It should be noted that, first, the data to be displayed is obtained, and the FTL template after generating the PDF template data is filled with data through the target template engine to generate HTML code. According to the data to be displayed, multiple FTL templates can be written to generate multiple HTML codes. Then, using the target Java library, the generated HTML code is added to the Document class in a loop to form the main part of the PDF file. Finally, the PDF template data and the main content containing the data to be displayed are integrated into the data to be processed, and the Document class of the data to be processed is exported to generate the target PDF file.
[0085] In this embodiment, Flying-Saucer-PDF is used as the target Java library, wherein Flying-Saucer-PDF is an open source Java library. Based on Flying-Saucer-PDF, the content of HTML code, CSS code and part of JavaScript code can be converted into a file in PDF format.
[0086] By obtaining user input information or querying the database, the data to be displayed in the PDF file is obtained, and the data is filled using the process method provided by the Template class in FreeMarker. Furthermore, the data to be displayed and the FTL template containing the PDF template data are imported into the process method for data filling and HTML code is generated.
[0087] Use the setDocumentFromString method provided by Flying-Saucer-PDF to pass in the HTML file source code, and rewrite the createPDF method in Flying-Saucer-PDF to add the Document class and PdfWriter class as parameters, and then pass the created Document class and PdfWriter class to the createPDF method. By adding the HTML code to the Document class, the main part of the PDF file is formed. If there are multiple HTML codes generated by multiple FTL templates, call the setDocumentFromString method and createPDF method multiple times to add the main part to the same Document class.
[0088] When all the main parts are added, the PDF file is exported through the FileOutputStream class to generate the target PDF file, and ensure that the final generated target PDF file meets the expected format and quality requirements.
[0089] Specifically, the controller further imports the data to be displayed into the process method provided by the Template class in the target template engine according to the PDF template data to fill the data and obtain the data to be processed; and converts the data to be processed into the target PDF file using the target Java library.
[0090] Figure 2 The overall process diagram for PDF file generation is as follows. The overall process first uses FreeMarker to write the FTL template, then initializes the Document class and PdfWriter class in iText, laying the foundation for subsequent data filling and setting the first template data containing various document parameters. After setting the second template data containing the cover, header, footer, background image, etc., the data to be displayed is obtained and filled with data, the main part and the PDF template data are integrated into the data to be processed, and converted into the target PDF file in PDF format.
[0091] It should be noted that the HTML code generated by the FTL template has great flexibility in style adjustment, can simulate the effect of a Web page, and easily handle complex header display and automatic continuation of headers during paging. In view of the shortcomings of Flying-Saucer-PDF in repeatedly writing to the same Document class, the createPDF method in Flying-Saucer-PDF has been redeveloped to add the functions of taking in parameters of the Document class and the PdfWriter class and repeatedly writing data to the Document. By calling the setDocumentFromString method and the createPDF method multiple times, it is possible to support repeated writing of HTML code to the same Document class, further improving the flexibility and efficiency of generating PDF files.
[0092] The version of iText used in the embodiment is iText 2. iText has some limitations in use. For versions 5.0 and above, if applied to the commercial field, it is necessary to purchase a corresponding commercial license, or follow the regulations of open source software to disclose the source code. Therefore, the cost and risk of commercial use are increased to a certain extent. However, iText below 5.0 has the problem of insufficient ability to dynamically adjust templates, and its functions are relatively limited, which is difficult to meet the needs of complex format file generation, and the present invention greatly improves the above-mentioned multiple problems.
[0093] Figure 3 FIG. 2 is a schematic diagram showing a structure of an embodiment of a PDF file generation system 200 provided by the present invention. Figure 3 As shown, the system 200 includes: a setting module 210 and an execution module 220.
[0094] The setting module 210 is used to: generate PDF template data according to the data to be displayed and the PDF design requirements, and using the FTL template;
[0095] The execution module 220 is used to fill the data to be displayed into the PDF template data to obtain the target PDF file.
[0096] In an optional manner, the setting module is specifically used to:
[0097] Generate an FTL template using a target template engine, and write a template language code and a CSS code in the FTL template according to PDF design requirements to generate first template data;
[0098] According to the PDF design requirements, the Document class and PdfWriter class in iText are called to generate the second template data;
[0099] The first template data and the second template data together constitute PDF template data.
[0100] In an optional manner, the second template data includes: at least one of page size, page margin, header and footer, picture background, watermark and cover;
[0101] The settings module is specifically used to:
[0102] Use the Document class to set at least one of the page size, page margins, headers, footers, and cover pages.
[0103] Use the PdfWriter class to set at least one of the image background and watermark.
[0104] The technical solution of this embodiment realizes highly customized and diversified PDF file generation by designing a universal FTL template file, supports complex header design and page header reproduction, and reduces the cost and risk of commercial applications while enhancing the expressiveness of PDF content, and also improves the flexibility and scalability of the project.
[0105] The parameters and steps of each module implementing the corresponding functions in the PDF file generation system 200 of the present embodiment may refer to the parameters and steps in the embodiment of the PDF file generation method described above, and will not be described in detail here.
[0106] like Figure 4 As shown, an electronic device 300 according to an embodiment of the present invention includes a processor 320, the processor 320 is coupled to a memory 310, and the memory 310 stores at least one computer program 330, and the at least one computer program 330 is loaded and executed by the processor 320, so that the electronic device 300 implements any one of the above-mentioned PDF file generation methods, specifically:
[0107] The electronic device 300 may have relatively large differences due to different configurations or performances, and may include one or more processors 320 (Central Processing Units, CPU) and one or more memories 310, wherein at least one computer program 330 is stored in the one or more memories 310, and the at least one computer program 330 is loaded and executed by the one or more processors 320, so that the electronic device 300 implements any of the PDF file generation methods provided in the above embodiments. Of course, the electronic device 300 may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output, and the electronic device 300 may also include other components for implementing device functions, which will not be described in detail here.
[0108] A computer-readable storage medium according to an embodiment of the present invention stores at least one computer program, and the at least one computer program is loaded and executed by a processor to enable a computer to implement any of the above-mentioned PDF file generation methods.
[0109] Optionally, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, and the like.
[0110] In an exemplary embodiment, a computer program product or a computer program is also provided, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes any of the above-mentioned PDF file generation methods.
[0111] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects and represent the definition of a specific order or sequence. The order of use of similar objects can be interchanged where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than the order shown or described.
[0112] Those skilled in the art know that the present invention can be implemented as a system, method or computer program product. Therefore, the present disclosure can be specifically implemented in the following forms, namely: it can be complete hardware, it can be complete software (including firmware, resident software, microcode, etc.), or it can be a combination of hardware and software, which is generally referred to as "circuit", "module" or "system" herein. In addition, in some embodiments, the present invention can also be implemented in the form of a computer program product in one or more computer-readable media, and the computer-readable medium contains computer-readable program code.
[0113] Any combination of one or more computer-readable media may be used. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. A computer-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 thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer 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 thereof. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, device, or device.
[0114] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A PDF file generation method, characterized in that: include: Generate PDF template data based on the data to be displayed and PDF design requirements, and use FTL templates; Fill the data to be displayed into the PDF template data to obtain a target PDF file.
2. The PDF file generation method according to claim 1, characterized in that: The steps to generate PDF template data based on the data to be displayed and the PDF design requirements, and using the FTL template, include: Generate the FTL template by using the target template engine, and write the template language code and the CSS code in the FTL template according to the PDF design requirements to generate the first template data; According to the PDF design requirements, the Document class and the PdfWriter class in iText are called to generate the second template data; The first template data and the second template data together constitute the PDF template data.
3. The PDF file generation method according to claim 2, characterized in that: The second template data includes: at least one of page size, page margin, header and footer, picture background, watermark and cover; The steps of calling the Document class and the PdfWriter class in iText to generate the second template data include: Using the Document class, setting at least one of the page size, the page margin, the header and footer, and the cover; Using the PdfWriter class, at least one of the picture background and the watermark is set.
4. The PDF file generation method according to claim 2, characterized in that: The step of filling the data to be displayed into the PDF template data to obtain a target PDF file includes: According to the PDF template data, the data to be displayed is imported into the process method provided by the Template class in the target template engine to fill the data, thereby obtaining the data to be processed; The target Java library is used to convert the data to be processed into the target PDF file.
5. The PDF file generation method according to any one of claims 2 to 4, characterized in that: The first template data includes at least one of content layout and content style.
6. A PDF file generation system, characterized in that: include: Set up modules and execute modules; The setting module is used to: generate PDF template data according to the data to be displayed and the PDF design requirements, and using the FTL template; The execution module is used to fill the data to be displayed into the PDF template data to obtain a target PDF file.
7. The PDF file generation system according to claim 6, characterized in that: The setting module is specifically used for: Generate the FTL template by using the target template engine, and write the template language code and the CSS code in the FTL template according to the PDF design requirements to generate the first template data; According to the PDF design requirements, the Document class and the PdfWriter class in iText are called to generate the second template data; The first template data and the second template data together constitute the PDF template data.
8. The PDF file generation system according to claim 7, characterized in that: The second template data includes: at least one of page size, page margin, header and footer, picture background, watermark and cover; The setting module is specifically used for: Using the Document class, setting at least one of the page size, the page margin, the header and footer, and the cover; Using the PdfWriter class, at least one of the picture background and the watermark is set.
9. An electronic device, characterized in that: The electronic device includes a processor, the processor is coupled to a memory, the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor, so that the electronic device implements the PDF file generation method according to any one of claims 1 to 5.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one computer program, and the at least one computer program is loaded and executed by the processor, so that the computer-readable storage medium implements the PDF file generation method according to any one of claims 1 to 5.