An artificial intelligence-based ticket template automatic generation method and system
By using an AI-based approach to automatically parse and repair PDF invoices to generate JasperReports templates, the problem of low conversion accuracy and poor reliability in existing technologies is solved, achieving efficient and reliable template generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- FOUNDER INT(WUHAN)TECH DEV CO LTD
- Filing Date
- 2026-02-28
- Publication Date
- 2026-06-02
AI Technical Summary
Existing technologies struggle to automatically and faithfully convert unstructured PDF invoices into JasperReports report templates that can be directly compiled. Furthermore, the generated JRXML often violates XSD structure constraints, leading to compilation failures and requiring extensive manual debugging and repair.
Using an AI-based approach, text elements and vector graphics paths are extracted from PDF files, standardized, and semantically understood using a large language model. Tags and fields are identified, and a semantic layout intermediate representation is generated. Based on preset component mapping rules, it is converted into JasperReports components, and the compiler is used for compilation and self-repair to ensure the high fidelity of the template.
It achieves an end-to-end automated process from PDF to JasperReports templates, significantly reducing manual costs, ensuring high layout fidelity and template compilability, and solving the problems of low conversion accuracy and poor reliability in existing technologies.
Smart Images

Figure CN122133628A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent report processing technology, and in particular to an automated method and system for generating invoice templates based on artificial intelligence. Background Technology
[0002] In enterprise information systems, JasperReports is a widely used open-source reporting engine, and its template files (JRXML) are a structured XML description language. However, manually designing and writing JRXML templates from existing paper or electronic PDF invoices is a tedious, time-consuming, and error-prone task, especially for commercial invoices that include complex table lines, multilingual fonts, and precise alignment requirements.
[0003] Currently, some PDF conversion tools exist, but most can only extract text or perform simple format conversions. They cannot understand the business semantics of reports (such as distinguishing labels and fields), let alone accurately map vector graphics (such as table lines) in PDFs to JasperReports compilable components. In addition, the generated JRXML often violates JasperReports' strict XSD (XML Schema Definition) structural constraints, leading to compilation failures and requiring extensive manual debugging and repair.
[0004] Therefore, the industry urgently needs a technical solution that can automatically and faithfully convert existing PDF invoices into high-quality, ready-to-use JasperReports templates. Summary of the Invention
[0005] This invention proposes an automated method for generating invoice templates based on artificial intelligence, aiming to solve the technical problem in the prior art of how to automatically and faithfully convert unstructured, uneditable PDF invoices into JasperReports report templates that can be directly compiled and data-bound.
[0006] In a first aspect, the present invention provides an automated method for generating invoice templates based on artificial intelligence, comprising: S1 parses the source PDF invoice file, extracts the text elements and vector graphics paths, and standardizes the coordinates of all elements to generate an intermediate layout representation. S2, based on the large language model, perform semantic understanding on the intermediate layout representation, identify tag elements, field elements and their pairing relationships, identify table areas, and generate a semantic intermediate layout representation containing semantic roles; S3, convert the elements in the semantic layout intermediate representation into corresponding JasperReports report components according to the preset component mapping rules, and convert the standardized coordinates into JasperReports physical coordinates according to the coordinate transformation formula to generate the initial JRXML template. S4. Use the JasperReports compiler to compile the initial JRXML template. If the compilation fails, input the compilation error information and the current JRXML template into the large language model for error analysis and repair, generate the repaired JRXML template, and repeat this step until the compilation is successful to obtain the target report template.
[0007] The technical effect of the AI-based automated generation method for invoice templates disclosed in this invention is that it realizes an end-to-end automated process from PDF to runnable JasperReports templates, significantly reducing labor costs and technical requirements while ensuring high layout fidelity and template compilability.
[0008] Furthermore, S1 specifically includes: S11, perform multi-feature fusion type detection on the source PDF invoice file, and dynamically select a parsing strategy based on text density, number of images and layout complexity; S12 uses the PyMuPDF engine to parse PDF pages, extract text blocks and their font attributes, and extract vector graphics paths represented by PDF drawing operation code sequences. S13, classify the vector graphic paths and convert them into standard geometric primitives, and repair the degenerate paths; S14 converts the coordinates of all geometric primitives and text blocks from the original PDF coordinate system to a standardized coordinate system with the top left corner of the page as the origin and expressed as a percentage.
[0009] Furthermore, in S13, repairing the degraded path includes: if the height of the bounding box of the path is approximately zero, then repairing it to a horizontal line; if the width of the bounding box of the path is approximately zero, then repairing it to a vertical line.
[0010] Furthermore, in S2, the prompt information input to the large language model is a compressed layout description, the format of which is: [element ID], (x1,y1)-(x2,y2), font size, text content, where the coordinates are all percentage coordinates; the large language model performs joint reasoning based on spatial proximity, visual style features and text semantic features to identify tags and fields.
[0011] Furthermore, in S3, the coordinate transformation formula is: ; ; in, For percentage coordinates in the semantic layout middle representation. The values are the converted JasperReports physical coordinates, and PageWidthpt and PageHeightpt are the physical page dimensions.
[0012] Furthermore, S3 also includes: decomposing the identified table frame lines from a continuous sequence of path points into multiple independent line segments, with each line segment mapped to a JasperReports Line component.
[0013] Furthermore, in S3, the generation of the initial JRXML template follows the root element child node order defined by JasperReportsXSD, and all static and dynamic content elements obtained from the PDF are placed within the theme band for absolute positioning layout.
[0014] Furthermore, in S4, the error analysis and repair performed by the large language model includes at least one of the following: adjusting the JRXML node order according to the XSD order; checking and adjusting the band height to meet the page physical constraints; correcting the font configuration to use the font extension mode; and fine-tuning the element coordinates for out-of-bounds or overlapping.
[0015] Secondly, the present invention provides an artificial intelligence-based automated generation system for invoice templates to implement the method, comprising: The layout parsing and standardization module is used to parse the source PDF invoice file, extract the text elements and vector graphic paths, standardize the coordinates of all elements, and generate an intermediate layout representation. The semantic understanding and recognition module integrates a large language model, which is used to perform semantic understanding on the intermediate layout representation based on the large language model, identify tag elements, field elements and their pairing relationships, identify table areas, and generate a semantic intermediate layout representation containing semantic roles. The template mapping and generation module is used to convert the elements in the semantic layout intermediate representation into corresponding JasperReports report components according to the preset component mapping rules, and convert the standardized coordinates into JasperReports physical coordinates according to the coordinate transformation formula to generate the initial JRXML template. The compilation and self-repair closed-loop module is used to compile the initial JRXML template using the JasperReports compiler. If the compilation fails, the compilation error information and the current JRXML template are input into the large language model for error analysis and repair, generating a repaired JRXML template. This step is repeated until the compilation is successful, and the target report template is obtained.
[0016] The technical effect of the system disclosed in this invention is that it provides a modular and deployable system that solidifies and engineers the above-mentioned automation method, and realizes a stable and efficient intelligent generation capability for invoice templates.
[0017] Thirdly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described thereon. Attached Figure Description
[0018] Figure 1 This is an overall flowchart of the method for automatically generating invoice templates provided in this embodiment of the invention; Figure 2 This is a detailed flowchart of the PDF parsing and coordinate standardization process in an embodiment of the present invention; Figure 3 This is a flowchart illustrating the compilation of a self-healing closed loop in this embodiment of the invention. Detailed Implementation
[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0020] As mentioned in the background technology, while some PDF conversion tools exist, most can only extract text or perform simple format conversions. They cannot understand the business semantics of reports (such as distinguishing labels and fields), nor can they accurately map vector graphics (such as table lines) in PDFs to compileable components of JasperReports. Furthermore, the generated JRXML often violates JasperReports' strict XSD (XML Schema Definition) structural constraints, leading to compilation failures and requiring extensive manual debugging and repair. This invention provides an AI-based method for automatically generating invoice templates, referencing... Figures 1 to 3 As shown, the specific steps include: Step S101: PDF parsing and intermediate layout representation generation. For example... Figure 2 As shown, the specific execution process is as follows: (1) PDF Type Detection: The system receives the source PDF file and does not simply determine whether it is a scanned document, but performs multi-dimensional feature analysis. It calculates the text length (has_text), the number of images (image_count), and the layout complexity based on the text block distribution. Based on preset thresholds, the PDF is routed to different parsing strategies (e.g., PyMuPDF for plain text, OCR for scanned documents, and a visual engine for complex mixed types): Plain text type: Use PyMuPDF to directly extract text and vector graphics.
[0021] Scanning type (pure image or image-intensive): Prioritize enabling OCR (Optical Character Recognition) and image recognition modules.
[0022] Complex hybrid type: Enhanced parsing by combining PyMuPDF and a visual engine.
[0023] For pages routed to OCR or a visual engine (i.e., scanned images or plain pictures), the system not only performs OCR to extract text but also simultaneously launches an image recognition module. This module employs computer vision techniques, such as Canny edge detection, Hough transform, and Line Segment Detection (LSD), to detect lines, rectangles, and table borders from the image. For detected lines, its start and end coordinates are calculated; for rectangles, its four corner points are recorded; for table structures, cell regions are further identified by analyzing line intersections to construct the table's grid layout. All detected graphic elements are converted into vector path representations and merged with the text blocks extracted by OCR. Subsequently, these elements also undergo degenerate path repair and coordinate normalization (converted to a percentage coordinate system with the top-left origin) to generate an intermediate layout representation consistent with PDF parsing. Thus, whether it's a native PDF or a scanned image, the system can obtain accurate physical layout information, laying the foundation for subsequent semantic understanding.
[0024] (2) Vector Path and Text Extraction: For native PDFs or non-scanned pages, the PyMuPDF library is used as the core parsing engine. It not only extracts text blocks (page.get_text(“dict”)) and their font (fontName) and font size (fontSize) information, but more importantly, it extracts drawing commands (paths) in the PDF. These command sequences (such as re for rectangle, m and l for drawing lines) describe all the vector graphics such as table lines and borders.
[0025] (3) Path Standardization and Repair: The extracted path commands are converted into standard geometric primitive objects, such as rectangles (rect) and lines (line). For "degraded paths" caused by precision issues in actual PDFs (e.g., paths that should be straight lines but whose coordinate points almost overlap), the system performs intelligent repair: it calculates the bounding box (bbox) of the path. If its height (bbox.height) is close to 0 (e.g., less than 0.5pt), it is considered a horizontal line; if its width (bbox.width) is close to 0, it is considered a vertical line. This ensures the correct reconstruction of the subsequent table structure.
[0026] (4) Coordinate Standardization: The original PDF coordinate system uses the bottom left corner of the page as the origin, and the unit is points (pt). To eliminate the influence of page size differences, the system uniformly converts the coordinates of all elements (text blocks, graphic elements) to percentage coordinates based on the page size, and switches the origin to the top left corner. The conversion formula is: ; (This refers to a Y-axis flip from bottom left to top left; in actual system implementations, the flip may be handled directly in a later stage.) The final output is a structured JSON, namely the LayoutIR, which includes the type, percentage coordinates, text content, and graphic attributes of each element.
[0027] This step precisely deconstructs unstructured PDFs into structured data with accurate geometric information, providing a reliable "factual basis" for subsequent semantic understanding and template conversion, and in particular, solving the industry problem of not being able to obtain vector information such as table lines.
[0028] Step S102: Semantic recognition and field pairing based on LLM.
[0029] (1) Input Construction: The LayoutIR generated by S101 is processed instead of directly inputting the large JSON. Instead, each element is compressed into a single line description, in the format: [T12](12.3,10.5)-(25.8,12.2)12pt request book number. This format allows the LLM to intuitively perceive the spatial relationship between elements.
[0030] (2) LLM Inference: The compressed layout description and carefully designed prompts are input into a large language model (such as GPT-4). The prompts require the LLM to act as a "report structure analyst" and infer based on three types of evidence: Evidence of spatial relationships: For example, two text blocks are on the same horizontal line and are very close to each other.
[0031] Visual style evidence: For example, the text in a field may be bold or in a different font than the label.
[0032] Linguistic and semantic evidence: For example, the text content contains keywords such as "number", "Date", and "Total".
[0033] (3) Output structured results: The LLM is constrained to output formatted JSON, clearly identify the role of each element (ROLE: "LABEL" or "FIELD"), assign semantic names to fields (semanticName: "invoice_no"), and establish a pairing relationship between Label and Field (boundTo). At the same time, the LLM needs to identify the table area and output the table header and row and column structure.
[0034] (4) Generate semantic layout intermediate representation: The system integrates the output of LLM and upgrades the original LayoutIR to SemanticLayoutIR. In this structure, text elements are given business semantics (such as invoice_no_label, invoice_no_field) and include information such as data type inference and table grouping.
[0035] This step leverages LLM's powerful multimodal (text + coordinates) understanding capabilities to achieve a crucial leap from "physical layout" to "business semantics," accurately identifying data binding points, which is a prerequisite for generating usable Jasper templates.
[0036] Step S103: Mapping and generating semantic layout to Jasper templates.
[0037] (1) Coordinate system conversion: Input the percentage coordinates in SemanticLayoutIR. The system uses a defined formula to convert them back to the physical coordinates (pt) required by JasperReports, ensuring that the coordinate system is consistent (origin at the top left corner). The conversion formula is as described in claim 5. This formula ensures that the template layout is strictly proportional to the original PDF layout and is not affected by the absolute page size.
[0038] (2) Component mapping: The system has a built-in mapping table. For example: role: "LABEL" → <statictext>;role:"FIELD”→ <textfield>;pathType:"line”→ <line>.
[0039] (3) Special handling of table lines: For the rectangular path representing the table frame in the PDF (a closed polygon composed of multiple points), the system performs patented processing: it decomposes it into multiple independent line segments. The algorithm is to traverse the point sequence [p0,p1,p2,p3,p0] and generate four lines connecting p0-p1, p1-p2, p2-p3, and p3-p0 in sequence. <line>This component perfectly solves the problem that JasperReports does not directly support "path" objects.
[0040] (4) JRXML generation and structure sorting: The system first generates a Jasper element abstract syntax tree (AST), and then strictly follows the JasperReports 6.20.0 XSD order (property ,style ,parameter ,field ,title (detail...) is serialized into a JRXML file. A key engineering decision was to place all elements parsed from the PDF (whether tags, fields, or lines) into a JRXML file. <title> Within the band.< / title> <detail>Only one blank band with a minimum height (e.g., 1 pixel) is reserved. This is because... <title> Bands support absolute positioning, which can perfectly reproduce the fixed page layout of PDFs and avoid the Jasper engine from automatically rearranging elements.< / title>
[0041] This step achieves a deterministic transformation from the semantic model to compilable code. Coordinate transformation ensures layout alignment, component mapping and table line processing ensure visual element restoration, and strict XSD order control is key to ensuring the generated template can be compiled, avoiding the problem of generating invalid XML in traditional methods.
[0042] Step S104: Compile the self-healing closed loop. For example... Figure 3 As shown, this is an iterative process: (1) Initial compilation: Submit the initial JRXML generated by S103 to JasperCompileManager.compileReport() of JasperReports for compilation.
[0043] (2) Error Analysis and LLM Repair: If compilation fails, the system captures detailed exception stack information. This error log, the current JRXML content, and constraints such as page and font are used to construct a new prompt word, which is then input into the LLM. The prompt word requires the LLM to act as a "JasperReports debugging expert" and analyze the cause of the error (e.g., "Field 'xxx' not found" means that the field declaration is missing or the name does not match; "Content theight too large" means that the band height exceeds the printable area of the page).
[0044] (3) Targeted Repair: Based on the analysis, LLM outputs the repaired JRXML. The repair actions follow the "minimal modification" principle and may include: adjusting the element order to conform to XSD; <field>Add missing field declarations to the list; adjust <title> Adjust the height of the bands to fit the page; change hard-coded font names to font extension references (e.g., fontName="NotoSansCJKjp"); fine-tune coordinates that slightly exceed the boundaries.< / title>
[0045] (4) Iterative convergence: Recompile with the repaired JRXML. This process is repeated cyclically, and each iteration resolves one or a batch of compilation errors. Since the set of errors is finite and each repair moves towards a compileable state, this closed loop guarantees convergence within a finite number of iterations, ultimately outputting a JRXML template that can be compiled 100% of the time.
[0046] This step builds an intelligent "compile-test-fix" automated pipeline, solving the "last mile" reliability problem of AI-generated code. It replaces expensive and error-prone manual debugging, ensuring the final deliverable (Jasper template) is production-ready.
[0047] Here is a real-world example: the automatic generation of "XYZ Company Commercial Invoice.pdf" into "Invoice_Template.jrxml".
[0048] Step 1, Input: Source PDF file. File: XYZ Company Commercial Invoice.pdf. Content characteristics: Contains company logo (image), complex table lines, mixed Chinese / Japanese text (such as "Request Number", "Product Name"), fixed labels (such as "Issuance Date") and variable data (such as "KMJT000001998069").
[0049] The second step is PDF parsing and standardization.
[0050] The PDF type detection module determines that the PDF is a complex "text + vector graphics" format and routes the request to the PyMuPDF engine. It extracts all text blocks, their coordinates, and font. For example, it identifies text block T1: "Request Book Number" (coordinates: [10,20,40,25], font: HeiseiMin-W3). It also extracts all drawing paths. For example, it identifies the rectangular path Path_R1 that forms the outer frame of the invoice form (composed of 4 line segment commands).
[0051] The third step is LLM semantic recognition.
[0052] System input: Compress the above LayoutIR into an LLM-readable prompt.
[0053] Semantic pairing: Based on spatial proximity and textual semantics ("number" represents the number), LLM determines that T1 is LABEL and T2 is FIELD, and assigns the semantic name invoice_no.
[0054] Table Recognition: LLM identifies a set of aligned text blocks that form a product details table, outputting a header ["Product Name", "Quantity", "Value", "Amount"] and row data references. Output - Semantic LayoutIR.
[0055] Step 4: Template mapping and generation.
[0056] Coordinate transformation: For field T2, its percentage coordinates bbox: [25.0, 4.8, 45.0, 6.0] are converted to Jasper physical coordinates.
[0057] x_pt=595 25.0 / 100≈149, y_pt=842 4.8 / 100≈40.
[0058] Component mapping and generation: T2(FIELD) → Generate a <textfield>The element, with the expression bound to $F{invoice_no}.
[0059] P1(rect) → is broken down into 4 independent <line>element.
[0060] All elements are placed <title> Within the band.< / title>
[0061] Output - Initial JRXML template.
[0062] Step 5: Compile the self-healing closed loop.
[0063] First compilation: JasperCompileManager.compileReport() may fail due to... <style>顺序在<field>之后而失败。
[0064] LLM修复:系统将错误日志和JRXML发送给LLM。LLM识别出"XSD顺序错误”,并将<style>节点移动到<field>节点之前。
[0065] 迭代与成功:修复后的JRXML再次编译。此次可能发现<title>波段高度超过了页面可打印区域。LLM再次微调高度值。经过若干次此类迭代,最终生成一个可100%编译通过的JRXML模板。
[0066] 第六步,最终成果与验证。
[0067] 生成文件:Invoice_Template.jrxml(目标报表模板)。
[0068] 配套测试数据:系统自动生成匹配的JSON数据文件test_data.json。
[0069] 效果验证:将该模板与测试数据在JasperReports中填充,生成的PDF与原始PDF在表格结构、字段位置、版式布局上保持高度一致(相似度>80%),且模板可直接集成到业务系统中,绑定真实数据库生成正式报表。
[0070] 本案例完整演示了本发明如何将一张包含复杂表格和多语言文本的商业发票PDF,通过"精准解析->智能理解->准确映射->自我验证”的自动化流程,转化为一个可直接使用、高保真还原的JasperReports报表模板,有效解决了该领域长期存在的人工转换成本高、精度差、可靠性低的痛点。
[0071] 基于同一发明构思,本发明实施例还提供了一种基于人工智能的账票模板自动化生成系统,用于实现上述方法,该系统包括:版式解析与标准化模块:封装了PDF类型检测、PyMuPDF解析、路径处理、坐标标准化等逻辑,负责执行步骤S101。
[0072] 语义理解与识别模块:集成大语言模型(LLM)接口,负责构造提示词、调用LLM、解析其输出,生成SemanticLayoutIR,负责执行步骤S102。
[0073] 模板映射与生成模块:包含坐标转换器、组件映射器和遵循XSD的JRXML生成器,负责执行步骤S103。
[0074] 编译与自修复闭环模块:包含JasperReports编译环境、错误日志捕获器、以及驱动LLM进行迭代修复的控制器,负责执行步骤S104。
[0075] 上述模块可以部署在同一服务器或分布式环境中,通过内部API或消息队列进行数据传递,共同协作完成账票模板的自动化生成任务。
[0076] 基于同一发明构思,本发明实施例还提供了一种计算机可读存储介质,该存储介质可以是磁盘、光盘、固态硬盘等,其上存储有计算机程序。当该程序被一个或多个处理器(如服务器CPU)加载并执行时,能够控制计算机系统实现如实施例1所述的基于人工智能的账票模板自动化生成方法的全部或部分步骤。
[0077] 本文已经公开了示例实施例,并且虽然采用了具体术语,但它们仅用于并仅应当被解释为一般说明性含义,并且不用于限制的目的。在一些实例中,对本领域技术人员显而易见的是,除非另外明确指出,否则可单独使用与特定实施例相结合描述的特征、特性和 / 或元素,或可与其他实施例相结合描述的特征、特性和 / 或元件组合使用。因此,本领域技术人员将理解,在不脱离由所附的权利要求阐明的本发明的范围的情况下,可进行各种形式和细节上的改变。< / style> < / line> < / textfield> < / field> < / detail> < / line> < / line> < / textfield> < / statictext>
Claims
1. A method for automatically generating invoice templates based on artificial intelligence, characterized in that, include: S1 parses the source PDF invoice file, extracts the text elements and vector graphics paths, and standardizes the coordinates of all elements to generate an intermediate layout representation. S2, based on the large language model, perform semantic understanding on the intermediate layout representation, identify tag elements, field elements and their pairing relationships, identify table areas, and generate a semantic intermediate layout representation containing semantic roles; S3, convert the elements in the semantic layout intermediate representation into corresponding JasperReports report components according to the preset component mapping rules, and convert the standardized coordinates into JasperReports physical coordinates according to the coordinate transformation formula to generate the initial JRXML template. S4. Use the JasperReports compiler to compile the initial JRXML template. If the compilation fails, input the compilation error information and the current JRXML template into the large language model for error analysis and repair, generate the repaired JRXML template, and repeat this step until the compilation is successful to obtain the target report template.
2. The method according to claim 1, characterized in that, S1 specifically includes: S11, perform multi-feature fusion type detection on the source PDF invoice file, and dynamically select a parsing strategy based on text density, number of images and layout complexity; S12 uses the PyMuPDF engine to parse PDF pages, extract text blocks and their font attributes, and extract vector graphics paths represented by PDF drawing operation code sequences. S13, classify the vector graphic paths and convert them into standard geometric primitives, and repair the degenerate paths; S14 converts the coordinates of all geometric primitives and text blocks from the original PDF coordinate system to a standardized coordinate system with the top left corner of the page as the origin and expressed as a percentage.
3. The method according to claim 2, characterized in that, In step S13, repairing the degraded path includes: if the height of the bounding box of the path is approximately zero, then repairing it to a horizontal line; if the width of the bounding box of the path is approximately zero, then repairing it to a vertical line.
4. The method according to claim 1, characterized in that, In step S2, the prompt information input to the large language model is a compressed layout description, the format of which is: [element ID], (x1,y1)-(x2,y2), font size, and text content, where the coordinates are all percentage coordinates; the large language model performs joint reasoning based on spatial proximity, visual style features and text semantic features to identify tags and fields.
5. The method according to claim 1, characterized in that, In S3, the coordinate transformation formula is: ; ; in, For percentage coordinates in the semantic layout middle representation. The values are the converted JasperReports physical coordinates, and PageWidthpt and PageHeightpt are the physical page dimensions.
6. The method according to claim 1, characterized in that, The S3 further includes: decomposing the identified table frame lines from a continuous sequence of path points into multiple independent line segments, with each line segment mapped to a JasperReports Line component.
7. The method according to claim 1, characterized in that, In step S3, the generation of the initial JRXML template follows the root element child node order defined by JasperReportsXSD, and all static and dynamic content elements obtained from the PDF are placed within the theme band for absolute positioning layout.
8. The method according to claim 1, characterized in that, In step S4, the error analysis and repair performed by the large language model includes at least one of the following: adjusting the JRXML node order according to the XSD order; checking and adjusting the band height to meet the page physical constraints; correcting the font configuration to use the font extension mode; and fine-tuning the element coordinates for out-of-bounds or overlapping.
9. An AI-based automated invoice template generation system for implementing the method of any one of claims 1-8, characterized in that, include: The layout parsing and standardization module is used to parse the source PDF invoice file, extract the text elements and vector graphic paths, standardize the coordinates of all elements, and generate an intermediate layout representation. The semantic understanding and recognition module integrates a large language model, which is used to perform semantic understanding on the intermediate layout representation based on the large language model, identify tag elements, field elements and their pairing relationships, identify table areas, and generate a semantic intermediate layout representation containing semantic roles. The template mapping and generation module is used to convert the elements in the semantic layout intermediate representation into corresponding JasperReports report components according to the preset component mapping rules, and convert the standardized coordinates into JasperReports physical coordinates according to the coordinate transformation formula to generate the initial JRXML template. The compilation and self-repair closed-loop module is used to compile the initial JRXML template using the JasperReports compiler. If the compilation fails, the compilation error information and the current JRXML template are input into the large language model for error analysis and repair, generating a repaired JRXML template. This step is repeated until the compilation is successful, and the target report template is obtained.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-8.