Modeling method and device for generating a printing template based on different types of components

CN122985089APending Publication Date: 2026-10-27BEIJING JOIN CHEER SOFTWARE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611127809.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-28
Publication Date
2026-10-27

AI Technical Summary

Technical Problem

现有技术中,打印元素的布局和属性配置与业务字段关联信息可能分别记录,在生成打印模板模型时需要对上述信息进行组合处理,导致打印模板模型的生成过程较为复杂

Benefits of technology

本发明实施例通过获取包含多种类型组件及其组件属性信息的预设组件库,并根据从组件库中选择的组件在打印画布中生成对应的组件实例,使文本、字段、条码、线段、图片和表格等不同类型的打印内容能够以组件实例的形式添加至打印画布;通过响应布局调整操作和属性设置操作更新组件实例属性,使各组件实例的布局和属性能够根据模板需求进行配置;通过将所选择业务字段的字段路径写入对应组件实例的组件实例属性,使对应组件实例与业务字段之间的数据绑定信息能够作为组件实例属性的一部分予以记录;进而根据打印画布的配置信息和各组件实例的组件实例属性生成打印模板模型。由此,有利于提高包含多种类型打印内容的打印模板的配置灵活性,并降低因不同类型打印元素的配置数据和业务字段关联信息分散处理而带来的打印模板构建及打印模板模型生成的复杂度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122985089A_ABST
    Figure CN122985089A_ABST
Patent Text Reader

Abstract

The application discloses a modeling method and device for generating a printing template based on different types of components, and the method comprises the following steps: obtaining a preset component library, wherein the component library comprises multiple types of components; in response to an operation of adding a selected component in the component library to a printing canvas, generating a corresponding component instance according to component attribute information of the selected component; in response to a layout adjustment or attribute setting operation on the component instance, updating component instance attributes of the component instance; in response to a data binding operation on the component instance, writing a field path of a selected business field in an external business data source into the component instance attributes of the corresponding component instance; and generating a printing template model according to configuration information of the printing canvas and the component instance attributes of each component instance. The application is beneficial to improving the configuration flexibility of the printing template, and reducing the complexity of template construction and model generation caused by the scattered processing of configuration data and business field association information of different types of printing elements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of visual print design technology, and more specifically, to a modeling method and apparatus for generating print templates based on different types of components. Background Technology

[0002] Print templates are used to define the layout and style of the content to be printed, ensuring that business data is formatted into a printed document according to a predetermined format. Depending on the business scenario, print templates typically include print elements such as text, business fields, barcodes, lines, images, and tables.

[0003] In existing technologies, print templates are typically configured through programming, designing fixed reports, or using visual design tools. When using programming or designing fixed reports, the print content and its layout are usually associated with the program code or report structure. When the print content or layout changes, the program code or report structure needs to be modified accordingly. While some visual design tools allow adding print elements and adjusting their layout and attributes within the design interface, configuring multiple types of print elements within the same print template requires the system to process the configuration data for each print element separately, making the print template construction process quite complex.

[0004] Furthermore, for print elements whose print content needs to be determined based on business data, it is also necessary to configure the correspondence between the print element and the business fields in the external business data source. In existing technologies, the layout and attribute configuration of print elements and the associated information of business fields may be recorded separately. When generating the print template model, the above information needs to be combined, making the print template model generation process relatively complex. Therefore, in existing technologies, when the print template includes multiple types of print elements and needs to be associated with external business data, there are problems such as insufficient flexibility in print template configuration and a relatively complex print template model generation process. Summary of the Invention

[0005] In order to solve at least one of the technical problems in the background art, the present invention proposes a modeling method and apparatus for generating printing templates based on different types of components.

[0006] One aspect of the present invention provides a modeling method for generating print templates based on different types of components, the method comprising: Obtain a preset component library, which contains various types of components and stores component information corresponding to each type of component. The various types of components include text components, field components, barcode components, line segment components, image components, and table components. The component information includes component attribute information. In response to the operation of adding the component selected from the component library to the printing canvas, a corresponding component instance is generated in the printing canvas according to the component attribute information corresponding to the selected component; In response to layout adjustment operations on component instances in the printed canvas or property setting operations on component instances, update the component instance properties of the corresponding component instances. In response to a data binding operation on a component instance, the field path of the business field selected from the external business data source is written to the component instance property of the corresponding component instance to record the data binding information of the corresponding component instance; Based on the configuration information of the print canvas and the component instance attributes of each component instance, a print template model including each component instance is generated.

[0007] In another aspect, the present invention provides a modeling apparatus for generating printing templates based on different types of components, the apparatus comprising: The component library acquisition unit is used to acquire a preset component library, which contains multiple types of components and stores component information corresponding to each type of component. The multiple types of components include text components, field components, barcode components, line segment components, image components, and table components. The component information includes component attribute information. The component instance generation unit is used to generate a corresponding component instance in the printing canvas in response to the operation of adding a component selected from the component library to the printing canvas, based on the component attribute information corresponding to the selected component. The instance property update unit is used to update the component instance properties of the corresponding component instance in response to a layout adjustment operation of the component instance in the printed canvas or a property setting operation of the component instance. The data binding unit is used to respond to the data binding operation on the component instance by writing the field path of the business field selected from the external business data source to the component instance property of the corresponding component instance to record the data binding information of the corresponding component instance. The template model generation unit is used to generate a print template model including each component instance based on the configuration information of the print canvas and the component instance attributes of each component instance.

[0008] To achieve the above objectives, according to another aspect of the present invention, a computer device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described modeling method for generating print templates based on different types of components.

[0009] To achieve the above objectives, according to another aspect of the present invention, a computer-readable storage medium is also provided, on which a computer program / instructions are stored, which, when executed by a processor, implement the steps of the modeling method for generating print templates based on different types of components described above.

[0010] To achieve the above objectives, according to another aspect of the present invention, a computer program product is also provided, comprising a computer program / instructions that, when executed by a processor, implement the steps of the modeling method for generating print templates based on different types of components described above.

[0011] The beneficial effects of this invention are as follows: This invention provides an embodiment of a pre-defined component library containing various types of components and their attribute information. Based on the components selected from this library, corresponding component instances are generated in the printing canvas. This allows different types of printable content, such as text, fields, barcodes, lines, images, and tables, to be added to the printing canvas as component instances. The component instance attributes are updated in response to layout adjustment and attribute setting operations, enabling the layout and attributes of each component instance to be configured according to template requirements. By writing the field path of the selected business field into the component instance attribute of the corresponding component instance, the data binding information between the corresponding component instance and the business field is recorded as part of the component instance attribute. Finally, a print template model is generated based on the printing canvas configuration information and the component instance attributes of each component instance. This improves the configuration flexibility of print templates containing various types of printable content and reduces the complexity of print template construction and model generation caused by the scattered processing of configuration data and business field association information for different types of print elements. Attached Figure Description

[0012] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. In the drawings: Figure 1 This is a flowchart of a modeling method for generating printing templates based on different types of components according to an embodiment of the present invention; Figure 2 This is a flowchart illustrating how a component instance is generated in a printed canvas according to an embodiment of the present invention; Figure 3 This is a flowchart illustrating the process of establishing a data binding relationship between a component instance and a business field according to an embodiment of the present invention; Figure 4 This is a preview rendering flowchart of different types of component instances in embodiments of the present invention; Figure 5 This is a flowchart of the partial refresh process for the print template preview in an embodiment of the present invention; Figure 6 This is a flowchart illustrating the generation and storage process of the printing template model according to an embodiment of the present invention. Figure 7 This is a flowchart illustrating the process of establishing a component tree based on a parent-child hierarchical relationship according to an embodiment of the present invention; Figure 8 This is a flowchart of the runtime rendering and output process of the printing template in an embodiment of the present invention; Figure 9 This is a flowchart of an example of the cross-document copying component according to an embodiment of the present invention; Figure 10 This is a structural block diagram of a modeling device for generating printing templates based on different types of components according to an embodiment of the present invention; Figure 11 This is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Implementation

[0013] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments. 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 should fall within the scope of protection of the present invention.

[0014] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0015] It should be noted that the terms "comprising" and "having" and any variations thereof in the specification, claims and accompanying drawings of this invention are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such processes, methods, products or devices.

[0016] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other. The present invention will now be described in detail with reference to the accompanying drawings and embodiments.

[0017] This invention provides a modeling method for generating print templates based on different types of components. The method uses a pre-defined component library to configure component information for different types of components, such as text components, field components, barcode components, line segment components, image components, and table components. When a component is added to the print canvas, a corresponding component instance is generated. The component attribute information for each type of component can include public and private attribute information. Different component instances generated from the same component have independent component instance attributes, allowing for separate layout adjustments and attribute settings. For component instances that need to be associated with external business data, the field path of the business field can be written into the component instance attribute to record the data binding information of the component instance. Users can add, adjust, and combine component instances on the print canvas and preview the effect of the current print template. After completing the template configuration, a print template model is generated based on the print canvas configuration information and the component instance attributes of each component instance. In some embodiments, component tree modeling, partial refresh of the print template preview, runtime rendering, cross-document component instance copying, and access to newly added component types can also be implemented.

[0018] Figure 1 This is a flowchart of a modeling method for generating printing templates based on different types of components according to an embodiment of the present invention, such as... Figure 1 As shown, in one embodiment of the present invention, the modeling method for generating printing templates based on different types of components includes steps S101 to S105.

[0019] Step S101: Obtain a preset component library. The component library contains multiple types of components and stores component information corresponding to each type of component. The multiple types of components include text components, field components, barcode components, line segment components, image components, and table components. The component information includes component attribute information.

[0020] In this embodiment of the invention, the preset component library refers to a set of components that have been configured before the modeling operation of the current print template is executed and can be invoked during the modeling process. Obtaining the component library may include loading the component library from a local configuration file, storage, database, or server, or it may include accessing a component library that has already been loaded into memory, without requiring the component library to be rebuilt each time a print template is created.

[0021] In this embodiment of the invention, components are basic design units that can be selected and added to the printing canvas. The components in the component library describe basic information about the corresponding type of print content and do not represent specific printable objects already existing in the printing canvas. The components in the component library can be displayed in the component panel of the print template design interface for user selection.

[0022] Different types of components are suitable for different printing content. Text components can be used to configure text content such as titles, descriptions, headers, or footers; field components can be used to represent business fields such as document numbers, dates, and customer names; barcode components can be used to represent data such as document numbers, logistics codes, or asset codes as barcodes; line components can be used to create separator lines or auxiliary lines; image components can be used to represent company logos, seals, or attachment images; and table components can be used to represent aggregated data such as product details, approval comments, or expense details. In other implementations, the component library may also include other types of components such as QR code components, watermark components, seal components, pagination components, or dynamic detail components.

[0023] The component information for each component type describes the basic configuration and usage of the corresponding component, including at least component attribute information. Component attribute information indicates the configurable properties of the corresponding component and its initial configuration information. Different types of components may have some of the same properties, or they may have unique properties corresponding to their functions.

[0024] In some implementations, component information may also include component metadata, drag-and-drop rules, property panel configuration information, and data binding capabilities. Component metadata may include component identifier, component name, component icon, component category, default width, default height, whether data binding is allowed, whether child components are supported, and whether component composition is supported. The component identifier distinguishes different components in the component library and differs from the component instance identifier set when the component instance is generated. The component name, component icon, and component category are used to display and organize the corresponding components in the component panel. The default width and default height determine the initial size of the component instance. Information such as whether data binding is allowed, whether child components are supported, and whether component composition is supported determines the executable operations of the corresponding component during the print template design process. Drag-and-drop rules can be used to limit the interaction and initial layout processing methods when a component is added to the print canvas from the component panel.

[0025] Step S102: In response to the operation of adding the component selected from the component library to the printing canvas, a corresponding component instance is generated in the printing canvas according to the component attribute information corresponding to the selected component.

[0026] In this embodiment of the invention, the printing canvas is a graphical design area used to carry component instances and present the layout of the printing template. The printing canvas can be a blank canvas corresponding to a newly created printing template, or it can be an existing printing template canvas that already contains some component instances. Therefore, this embodiment does not require that the printing template be created starting from a blank canvas; component instances can also be added based on an existing printing template.

[0027] Components can be added to the print canvas by dragging and dropping them from the component panel, or by clicking, double-clicking, or selecting from a menu. Users can select the same component multiple times as needed, or select different types of components.

[0028] A component instance is a specific printable object generated in the print canvas based on components from the component library. Components in the component library provide basic descriptions of their respective types, while component instances record the actual configuration state of that component in the current print template. The same component can generate one or more component instances in a print template, and different types of components can also generate corresponding component instances, thus combining different printable content in the same print canvas.

[0029] When generating a component instance, corresponding component instance properties can be created for the component instance based on the component property information of the selected component, and its initial layout can be determined based on the component's position in the print canvas. Component instance properties can be used to record the component instance's position, size, style, display hierarchy, content configuration, and data binding information, etc.

[0030] Step S103: In response to a layout adjustment operation on a component instance in the printed canvas or a property setting operation on a component instance, update the component instance property of the corresponding component instance.

[0031] In this embodiment of the invention, layout adjustment operation refers to the operation of changing the position, size, orientation, arrangement, or display hierarchy of component instances in the printed canvas. Users can change the position of component instances by dragging them, change their width or height by dragging their control points, or directly input the position and size through the properties panel. Layout adjustment operations may also include operations such as rotation, alignment, moving up, moving down, placing on top, or placing at the bottom.

[0032] In some implementations, the print canvas can display grid guidelines or alignment lines. When a user moves or resizes a component instance, the position or size of the component instance can be adjusted according to the grid guidelines, alignment lines, or preset snapping rules. For example, when a component instance is near a grid intersection, the edge of another component instance, or the center line, the component instance can be snapped to the corresponding position for alignment and layout of multiple component instances.

[0033] Attribute settings can be performed through the attribute panel in the print template design interface. After the user selects a component instance, the attribute panel displays the configurable attribute items for that component instance and allows for setting operations on the corresponding attribute items. The attribute settings can include the component instance's layout attributes, style attributes, and unique attributes corresponding to the component's functionality. Different types of components may have different specific attribute items.

[0034] The results of layout adjustment and attribute setting operations are recorded in the corresponding component instance's properties. For example, moving a component instance updates its position property, scaling it updates its size property, adjusting its display order updates its display hierarchy, and modifying its font, color, or border updates its corresponding style property. When updating component instance properties, you can update only the property item corresponding to the current operation while keeping other component instance properties unchanged. Therefore, the current layout and attribute configuration of each component instance in the print canvas can be recorded through its corresponding component instance properties.

[0035] In some implementations, the print canvas can also support copying, deleting, and grouping operations for component instances. The copy operation can generate a new component instance based on the component instance properties of the copied component instance; the delete operation can remove the corresponding component instance from the print canvas; and the grouping operation can establish a grouping relationship between multiple component instances.

[0036] In step S104, in response to the data binding operation of the component instance, the field path of the business field selected from the external business data source is written to the component instance property of the corresponding component instance to record the data binding information of the corresponding component instance.

[0037] In this embodiment of the invention, an external business data source refers to a data source capable of providing business data to the print template. For example, an external business data source can be a data model associated with a target document, which may include the target document's main table fields, sub-table fields, or aggregated data. In different business scenarios, the external business data source can provide business fields such as document number, date, customer name, product details, approval comments, and image resource address.

[0038] Field paths are used to indicate the location of business fields within an external business data source. For business fields with hierarchical relationships, the field path can be composed of the node names of the corresponding fields in the data hierarchy, allowing the corresponding business fields to be located in the business data based on the field path when using the print template later. The specific representation of the field path can be determined based on the data structure of the external business data source.

[0039] Data binding operations can include users selecting business fields for component instances from a field panel or other data selection interface. The system obtains the corresponding field path based on the selected business field and records this field path in the component instance properties of the component instance to be bound. Here, the data binding relationship is the correspondence between the component instance to be bound and the business fields in the external business data source, and the field path is the record form of this data binding relationship in the component instance properties.

[0040] During the print template modeling phase, only the field paths of the business fields need to be recorded, without having to write the actual field values ​​of the business fields into the print template model. Later, during previewing or runtime printing, the field values ​​can be retrieved from the corresponding business data based on these field paths. Therefore, the same print template model can be used with data from different business documents.

[0041] Data binding is not a mandatory operation for every component instance. For component instances that need to display fixed content, fixed attribute values ​​can be directly recorded in the component instance properties. For component instances such as field components, barcode components, image components, or table components that need to determine the printed content based on business data, data binding relationships can be established according to actual needs. The field organization method of external business data sources and the specific process of writing field paths will be further explained in subsequent embodiments.

[0042] Step S105: Generate a print template model including each component instance based on the configuration information of the print canvas and the component instance attributes of each component instance.

[0043] In this embodiment of the invention, the configuration information of the printing canvas is used to describe the page and canvas settings corresponding to the printing template, and may include information such as paper size, paper orientation, and page margins. In some embodiments, the configuration information of the printing canvas may also include the canvas scaling ratio or other configuration information related to the design area of ​​the printing template.

[0044] In this embodiment of the invention, when generating a print template model, each component instance in the current print canvas can be traversed to obtain the component instance attributes of each component instance, and the configuration information of the print canvas and the component instance attributes of each component instance can be organized into structured template data. Since the data binding information of the component instance is recorded in the component instance attributes in the form of field paths, the layout, attribute configuration, and data binding information of the component instances can be incorporated into the print template model simultaneously when organizing the print template model.

[0045] A print template model is a structured model that describes the print canvas and its component instances; it is not the final, rendered print file. The print template model records the page configuration, component instance set, and configuration status of each component instance corresponding to the print template, serving as the data foundation for subsequent saving, publishing, loading, previewing, or printing.

[0046] In addition to the configuration information of the print canvas and the attributes of component instances, the print template model can also record information such as the type of the component corresponding to each component instance, the composition relationship between component instances, the parent-child hierarchy relationship, relative coordinates, display hierarchy order, and resource references, as needed. For cases where multiple component instances do not have a composition relationship or a parent-child hierarchy relationship, each component instance can be recorded separately. For objects with an internal hierarchical structure, such as table component instances or composite component instances, the component instances they contain can be organized according to the corresponding hierarchical relationship.

[0047] Through the above steps, this invention can add different types of printable content, such as text, fields, barcodes, line segments, images, and tables, as components to the print canvas. It records the layout, attribute configuration, and data binding information of each component instance through component instance attributes, and then generates a print template model based on the print canvas configuration information and the component instance attributes of each component instance. This improves the configuration flexibility of the print template and reduces the complexity of print template construction and model generation caused by the scattered processing of configuration data and business field association information for different types of print elements.

[0048] In one embodiment of the present invention, the component attribute information includes public attribute information and proprietary attribute information; The common attribute information includes layout attributes and style attributes that can be shared by different types of components. The layout attributes include position, size, and display hierarchy order. The style attributes include border, background color, transparency, font, font size, color, and alignment. The proprietary attribute information includes functional attributes unique to the corresponding type of component. Specifically, the proprietary attribute information of the field component includes the field path and formatting rules, the proprietary attribute information of the barcode component includes the code system and data source, the proprietary attribute information of the image component includes the image source and scaling method, and the proprietary attribute information of the table component includes column structure, row height, table header, cell style, and detailed data source.

[0049] In this embodiment of the invention, component attribute information is used to describe the configurable attribute items of the corresponding type of component, while component instance attributes are used to record the actual attribute values ​​of the component instance formed after the component is added to the print canvas. Component attribute information may include attribute name, attribute category, attribute value type, selectable value range, and attribute editing method, etc. By dividing component attribute information into public attribute information and private attribute information, common attributes of different types of components can be reused while retaining the functional differences between each type of component.

[0050] In public attribute information, position can be represented using horizontal and vertical coordinates, size can be represented using width and height, and the display hierarchy order is used to determine the drawing order when multiple component instances overlap. Layout attributes can also include properties such as rotation angle and visibility. Style attributes such as border can further include border line style, border width, and border color; font can include font name and font style; alignment can include horizontal alignment and vertical alignment. Here, sharing corresponding attributes among different component types means that the attribute has the same or similar configuration meaning and processing method in different component types, and does not require every type of component to have all public attributes.

[0051] Specific attribute information describes the functional configuration that distinguishes a component of a certain type from other component types. For text components, specific attribute information can include the text content and how the text content is valued; the text content can be fixed text or the evaluation result of an expression. For field components, the field path indicates the location of the business field in the external business data source and can point to the main table field or sub-table field of the target document; formatting rules can include date format, numeric format, amount format, and null value handling rules, etc., to convert the obtained business field values ​​into a predetermined display format.

[0052] The barcode component's code system is used to determine the barcode encoding rules, and the data source is used to determine the data to be encoded. The data source can be a business field or an expression. The barcode component's proprietary attribute information may also include attributes such as error correction level and whether to display text. The line segment component's proprietary attribute information may include start point, end point, line width, line type, and line color. Line segment components typically use fixed attribute values ​​and do not establish data binding relationships with external business data.

[0053] The image source for the image component can be a static image resource, or an image address, attachment identifier, or binary resource indicated by a business field; the scaling method is used to determine the size adaptation relationship between the image resource and the display area of ​​the component instance. The image component can also be configured with cropping attributes, and the transparency and rotation angle of the image component can be configured according to the corresponding public attributes.

[0054] The column structure of a table component, also known as the column model, records the columns contained in the table, as well as the corresponding fields, column widths, display formats, and styles. The row model of a table component can include row height and row styles. The table header records the header content for each column, and cell styles can include cell borders, background color, font, and alignment. The detail data source represents the sub-tables or collections of data corresponding to the table component, enabling the table component to generate corresponding table content based on multiple detail data entries in the detail data source.

[0055] If the component library also includes other types of components, their proprietary attribute information can be configured in the same way. For example, the proprietary attribute information for a watermark component can include the watermark text, tilt angle, and arrangement density. The watermark text can be fixed text or a data binding relationship can be established with a business field representing the document status. The font and transparency of the watermark component can be configured according to the corresponding public attributes. The proprietary attribute information for a QR code component can include the code system, error correction level, whether to display text, and data source.

[0056] The values ​​of component instance properties can be fixed or determined based on business fields, expressions, or functions. For component instance properties whose values ​​are determined based on external business data, the corresponding value method and value content can be recorded.

[0057] By using the above attribute layering method, the repetitive definition and processing of common attributes such as position, size and style in the attribute modeling process of different types of components can be reduced. At the same time, the unique functions of components such as fields, barcodes, line segments, images and tables can be expressed through proprietary attribute information, which makes it easier to organize and process the attributes of different types of components.

[0058] like Figure 2 As shown, in one embodiment of the present invention, step S102 above generates a corresponding component instance in the printing canvas according to the component attribute information corresponding to the selected component, including steps S201 to S203.

[0059] Step S201: Generate a unique component instance identifier for the component instance to be generated.

[0060] In this invention, the component instance identifier is used to distinguish different component instances in the print template. The component instance identifier is different from the type information corresponding to the component in the component library: the component type information is used to indicate whether the component instance is a text component, field component, barcode component, line segment component, image component, or table component, while the component instance identifier is used to point to the specific component instance generated based on the corresponding component.

[0061] The component instance identifier must be unique at least within the scope of component instances contained in the current print template, and may also be globally unique within the print template system. The component instance identifier may be generated using a universally unique identifier, a serial number that increments according to a predetermined rule, a combination of time information and a random number, or other identifier generation methods that can distinguish different component instances.

[0062] After a component instance is generated, its instance identifier can be used as an index within the canvas component instance collection. Subsequent actions such as setting properties, binding data, moving, deleting, grouping, saving, or rendering the component instance can be performed based on this instance identifier, thus preventing operations intended for one component instance from being mistakenly applied to other component instances.

[0063] Step S202: Establish the component instance attributes of the component instance to be generated based on the component attribute information corresponding to the selected component, and use the default attribute values ​​in the component attribute information as the initial values ​​of the component instance attributes.

[0064] In this embodiment of the invention, component attribute information is used to describe the configurable attribute items and their default attribute values ​​of the selected component. When creating component instance attributes, a corresponding attribute set can be generated according to the attribute items in the component attribute information, and the default attribute values ​​corresponding to each attribute item can be copied into the attribute set. The default attribute values ​​may include default values ​​of common attributes such as default width, default height, default display level, default visibility state, default border, default background color, default transparency, default font, default font size, default color, and default alignment, and may also include default values ​​of proprietary attributes corresponding to the selected component.

[0065] For example, default attribute values ​​for text components may include default text content and text style; default attribute values ​​for field components may include default formatting rules and null value handling methods; default attribute values ​​for barcode components may include default barcode type, error correction level, and whether to display text; default attribute values ​​for image components may include default image source and scaling method; and default attribute values ​​for table components may include default column structure, row height, table header, and cell style. For attribute items without preset default attribute values, their initial values ​​can be set to null or to system-defined initial values.

[0066] In one implementation, default property values ​​can be copied to component instance properties, preventing the component instance properties from referencing mutable property data alongside the default property values ​​in the component library. For properties containing multiple layers of data, such as column structures and cell styles, each layer of data can be copied. Therefore, subsequent modifications to the component instance properties will not change the default property values ​​in the component library.

[0067] Component instances can also record the type of their corresponding component, so that the appropriate attribute settings and processing methods can be determined later based on the component type. When a component instance is first generated, its data binding information can be empty. After the user performs a data binding operation on the component instance, the corresponding data binding information is written to the component instance properties.

[0068] Step S203: Determine the initial coordinates of the component instance to be generated based on the added position of the selected component in the printed canvas, and use the initial coordinates as the initial value of the position attribute of the component instance to be generated.

[0069] Among them, multiple component instances generated from the same component each have a unique component instance identifier and mutually independent component instance attributes; when the component instance attributes of any component instance are updated, the component attribute information of the component corresponding to that component instance in the component library remains unchanged.

[0070] In this embodiment of the invention, the printing canvas can use a two-dimensional coordinate system to represent the position of the component instance. For example, the upper left corner of the printing canvas or printable area can be used as the origin of the coordinate system, with the horizontal direction as the x-coordinate direction and the vertical direction as the y-coordinate direction, and the position of the component instance can be represented by the x-coordinate and y-coordinate. The coordinate values ​​can be represented in pixels, millimeters, points, or other preset units.

[0071] When a user adds a component by dragging and dropping, the addition position can be determined based on the mouse pointer's position when the component is released. When a user adds a component by clicking, double-clicking, or selecting from a menu, the addition position can be determined from a preset position, the current cursor position, or an empty space in the print canvas. When the print canvas is zoomed or scrolled, the interface coordinates can be converted to print canvas coordinates based on the print canvas's zoom level and the current display area.

[0072] In some implementations, the coordinates calculated based on the added location can be corrected according to grid guidelines, alignment lines, or preset snapping rules. For example, the edge or center position of a component instance can be snapped to adjacent grids, the edges of other component instances, or alignment lines. The corrected coordinates are used as the initial values ​​for the component instance's position attribute.

[0073] For default position values ​​already set in the component properties, these can be replaced by initial coordinates determined based on the actual addition location. The initial size of the component instance can use the default width and height recorded in the component properties. After setting the component instance identifier, component instance properties, and initial coordinates, the component instance can be added to the corresponding component instance collection on the print canvas and displayed at the appropriate location on the print canvas.

[0074] In this embodiment of the invention, when multiple component instances are generated based on the same component, a corresponding component instance identifier is regenerated each time a component instance is generated, and component instance attributes are established separately. Each component instance can inherit the default attribute values ​​of the same component, but the inherited component instance attributes are stored separately and do not share variable attribute data with each other.

[0075] When users modify the style or proprietary properties of any component instance through the properties panel, or adjust the position, size, and display hierarchy of any component instance through the print canvas, the changes are only written to the component instance properties of that specific component instance. For data binding operations, the field path of the selected business field is also only written to the component instance properties of the component instance to be bound. The component property information and their default property values ​​of the corresponding component in the component library remain unchanged, as do the component instance properties of other component instances generated from the same component.

[0076] In this way, the components in the component library can be reused as the basic configuration for generating component instances. The same component can generate multiple component instances with independent configuration states in a single print template, thereby avoiding the impact of adjusting one component instance on components in the component library or other component instances.

[0077] like Figure 3 As shown, in one embodiment of the present invention, the above step S104, in response to the data binding operation of the component instance, writes the field path of the business field selected from the external business data source into the component instance attribute of the corresponding component instance, including steps S301 to S304.

[0078] Step S301: Obtain the metadata corresponding to the external business data source. The metadata includes field information of each business field in the external business data source and the hierarchical relationship between each business field.

[0079] In this embodiment of the invention, an external business data source refers to a data source independent of the print template model and capable of providing business data to component instances. For example, an external business data source can be a data model associated with the target document, which may include data structures such as a document master table, sub-tables, detail collections, or nested objects. External business data sources can also originate from the database of a business system, business interfaces, or other data models capable of providing structured business data.

[0080] In this embodiment of the invention, metadata is used to describe the data structure of the external business data source, rather than the actual business data corresponding to the target document at a certain moment. The field information of a business field may include field identifier, field name, field code, field type, belonging object, parent field, and whether it is a collection field. The hierarchical relationship between business fields can be used to represent the main table, sub-table, or nested object to which the business field belongs, as well as the superior-subordinate relationship between different business fields.

[0081] In one implementation, the document metadata of the target document is pre-associated with the corresponding data model. When the user enters the print template design interface, the external business data source corresponding to the target document is determined based on the association, and the metadata of the external business data source is obtained.

[0082] Step S302: Construct a field tree based on the field information and hierarchical relationship of each business field. The field tree includes multiple field nodes, each field node corresponding to a business field and associated with the field path of the corresponding business field.

[0083] In this embodiment of the invention, when constructing the field tree, one or more root field nodes can be determined first based on the parent field or the object to which each business field belongs. Then, according to the hierarchical relationship between the business fields, the field nodes corresponding to the lower-level business fields are sequentially set as child nodes of the corresponding upper-level field nodes. Thus, the field tree can represent the main table fields, sub-table fields, nested object fields, and collection fields in the external business data source in a hierarchical manner.

[0084] Field nodes can record information such as the field name, field type, and field path of the corresponding business field. The field path can be generated based on the field identifier or field code corresponding to the field node and its parent nodes at all levels. For example, field identifiers at all levels can be connected in order from the root field node to the current field node to form a field path that can locate the corresponding business field in an external business data source. For sub-tables or collection fields, the field path can also contain information indicating the collection hierarchy.

[0085] The constructed field tree can be displayed in the field panel or data source panel of the print template design interface, allowing users to find the business fields to be bound according to the hierarchical relationship between business fields. When the external business data source includes multiple data models, field trees can also be constructed for each data model separately, and multiple field trees can be organized into a data source collection.

[0086] Step S303: In response to the operation of selecting a target field node from the field tree for the component instance to be bound, obtain the field path associated with the target field node.

[0087] In this embodiment of the invention, the user can first select the component instance to be bound in the printing canvas, then enter the data binding settings interface through the property panel corresponding to the component instance, and select the target field node from the field tree. The operation of selecting the target field node can be by clicking, double-clicking, or dragging the corresponding field node, or by searching for the business field in the field tree and then confirming the corresponding field node.

[0088] In one implementation, the system can also determine whether a component instance is allowed to establish a data binding relationship based on the data binding capability of the component corresponding to the component instance to be bound, and determine whether the data source attribute of the component instance matches the field type of the business field corresponding to the target field node. For example, a table component typically selects the field node corresponding to a sub-table field or a collection field, while an image component can select a field node to represent an image address, attachment identifier, or binary resource.

[0089] Once a target field node is selected, its associated field paths can be read directly from that target field node; alternatively, field paths can be regenerated based on the target field node and its parent nodes at all levels. Field paths are used to identify the location of the selected business field in the external business data source.

[0090] Step S304: Write the field path associated with the target field node as the value content into the component instance attribute of the component instance to be bound, and set the value retrieval method in the component instance attribute to field binding value retrieval, so as to establish a data binding relationship between the component instance to be bound and the business field corresponding to the target field node.

[0091] In one implementation, value retrieval configuration information can be set in the component instance properties of the component instance to be bound. This configuration information includes the value retrieval method and the value content. When the value retrieval method is field binding, the value content is the field path associated with the target field node. Therefore, the value retrieval method determines which external business data source the component instance needs to obtain, and the value content determines the specific business field to be retrieved.

[0092] Setting the value retrieval method to field binding can also be used to mark the corresponding value configuration information as a dynamic value configuration. During the print template modeling phase, the field path of the business field is recorded, not the actual field value of that business field in the current business data. When previewing the print template or printing during runtime, the field value can be retrieved from the corresponding preview data or current business data based on the field path.

[0093] Data binding is established between the component instance to be bound and the business field corresponding to the target field node, and is recorded in the component instance property of the component instance in the form of value configuration information, without changing the component property information of the corresponding component in the component library. When reselecting a business field for the component instance, the original field path can be replaced with the field path of the newly selected business field; when canceling data binding, the corresponding field path can be deleted and the value retrieval method can be adjusted accordingly.

[0094] Besides field binding for value retrieval, component instance properties can also be retrieved using fixed values, expressions, or functions. When using fixed values, the retrieved value can be a pre-set fixed value; when using expressions, the retrieved value can be the expression to be evaluated; when using functions, the retrieved value can be the function identifier or function call information of a backend extension function. Backend extension functions can return complex data that is difficult to provide directly by binding fields based on the corresponding business logic.

[0095] Different types of component instances can use field values ​​obtained through field paths according to their respective functions. For example, a field component can use a field value as text to be displayed, a barcode component can use a field value as data to be encoded, an image component can interpret a field value as an image address, attachment identifier, or binary resource, and a table component can interpret a field value as a collection of details. The specific processing and rendering methods of bound data for different types of component instances will be further explained in subsequent embodiments.

[0096] By using the above method, the business fields in the external business data source are organized into a field tree according to the hierarchical relationship, and the field path of the business field selected by the user is recorded in the component instance property of the corresponding component instance. This allows the data binding relationship between the component instance and the business field to be recorded without writing the actual business data into the print template model.

[0097] In one embodiment of the present invention, the component information corresponding to each type of component further includes component rendering information, which is used to determine the renderer corresponding to each type of component.

[0098] Component rendering information is used to establish the correspondence between various types of components and their corresponding renderers. Component rendering information may include renderer identifiers, renderer call addresses, or other information that can identify the renderer. Renderers can be implemented as rendering functions, rendering classes, or rendering modules, and are used to generate the visual content of a component instance based on its attributes and corresponding data.

[0099] Different component types correspond to renderers that can handle their specific attributes and data. For example, text components correspond to text renderers, field components to field renderers, barcode components to barcode renderers, line segment components to line segment renderers, image components to image renderers, and table components to table renderers. Therefore, the appropriate renderer can be determined based on the component rendering information of the component instance, without needing to centrally process all rendering rules for different component types during a unified rendering process.

[0100] like Figure 4 As shown, in one embodiment of the present invention, in order to present the current display effect of each component instance according to the component instance attributes and preview data during the print template design stage, the method of the present invention further includes a process of generating a print template preview, which includes steps S401 to S403.

[0101] Step S401: Obtain preview data for generating a print template preview.

[0102] Preview data is used to simulate or represent business data during the actual use of the print template in the print template design phase. Preview data can be pre-set sample data from the system, current document data from the target document, or user-specified test data. The data structure of the preview data can be consistent with the data structure of the external business data source corresponding to the print template, so that the corresponding field values ​​can be obtained based on the field paths recorded in the component instance properties.

[0103] Preview data can include main table data, sub-table data, or detail collections, and can also include data such as image addresses, attachment identifiers, or binary resources. For table components, multiple sample details can be set in the preview data to form multiple rows of table content; for barcode components, sample field values ​​that can be encoded can be set; for image components, static image resources or field values ​​that can locate image resources can be set.

[0104] Step S402: For component instances with data binding relationships, obtain the field values ​​of the corresponding business fields from the preview data according to the field paths recorded in the corresponding component instance attributes.

[0105] For component instances with data binding relationships, the retrieval method and value content can be read from their component instance properties. When the retrieval method is field binding, the value content is the field path of the corresponding business field. The system can access the data objects in the preview data sequentially according to the hierarchy represented by the field path to obtain the field value of the business field corresponding to the field path.

[0106] The field value corresponding to the field path can be data in various forms such as text, number, date, image resource information, object, or collection. After obtaining the field value, it can be passed to the corresponding renderer according to the type of the component instance. If the field path does not exist in the preview data or the corresponding field value is empty, blank content, default content, or preset prompt content can be displayed according to the null value handling rules set in the component instance properties.

[0107] For component instances that do not have data binding relationships, the content to be rendered can be determined directly based on the fixed attribute values ​​recorded in their component instance properties. For component instances that use expression evaluation or function evaluation, the corresponding expression can be evaluated or the corresponding function can be called during the preview stage, and the result can be used as the data to be rendered.

[0108] Step S403: Call the corresponding renderer according to the component rendering information of the component corresponding to each component instance, and render each component instance according to the component instance attributes and the field values ​​obtained when the corresponding component instance has a data binding relationship, so as to generate a print template preview.

[0109] Specifically, for component instances with data binding relationships, when the component instance corresponds to a field component, the corresponding renderer renders the field value as text; when the component instance corresponds to a barcode component, the corresponding renderer encodes the field value as a barcode graphic; when the component instance corresponds to an image component, the corresponding renderer obtains the image resource based on the field value and renders it; when the component instance corresponds to a table component, the corresponding renderer uses the field value as a details set and renders it row by row.

[0110] During preview rendering, you can iterate through each component instance in the print canvas, determine and call the corresponding renderer based on the component rendering information of each component instance. For component instances with data binding relationships, the renderer receives the component instance properties of that component instance and the field values ​​obtained according to the field path; for component instances without data binding relationships, the renderer can determine the content to be rendered based on the component instance properties of that component instance.

[0111] The position and size properties of a component instance determine its rendering area on the print canvas. The display hierarchy order determines the drawing order when multiple component instances overlap. Style properties such as border, background color, transparency, font, font size, color, and alignment determine the display style of the rendered result. The renderer also processes the component content according to the specific properties of the corresponding component type and draws the rendering results of each component instance onto the print canvas to form a print template preview.

[0112] The renderer for the text component can render fixed text based on the text content attribute of the text component, or it can render the evaluation result of an expression as text. The renderer for the line segment component can draw line segments based on component instance attributes such as start point, end point, line width, line type, and color. For static image components, the corresponding renderer can render based on the static image resource recorded in the component instance attributes.

[0113] When a component instance corresponds to a field component, the obtained field value can be processed according to the field component's formatting rules. For example, the field value can be converted into corresponding text according to date, number, or amount format, and then the converted text can be drawn onto the print canvas by combining component instance properties such as font, font size, color, and alignment.

[0114] When a component instance corresponds to a barcode component, the data to be encoded can be a field value obtained from a field path or the result of an expression evaluation. The barcode renderer can convert the data to be encoded into the corresponding barcode graphic and draw it onto the printing canvas based on the code system, error correction level, size, and whether to display text set in the component instance properties.

[0115] When a component instance corresponds to an image component, the field value can represent an image address, attachment identifier, or binary resource. The image renderer can load or parse the corresponding image resource based on the field value, and draw the image within the corresponding rendering area according to the component instance properties such as scaling, opacity, cropping, and rotation angle.

[0116] When a component instance corresponds to a table component, field values ​​can be sub-table data or other forms of detail collections. The table renderer can generate a table based on the column structure, header, row height, and cell styles of the table component, and retrieve the content of the corresponding columns from each detail data in the detail collection according to the field correspondence recorded in the column structure, forming the table content row by row. When previewing using sample data, multiple sample details can be generated or read to present a preview effect of a multi-row table.

[0117] Using the above preview rendering method, print template previews containing different types of component instances can be generated based on component instance attributes and preview data during the print template design stage. This allows different forms of content, such as field values, barcode graphics, image resources, and detailed tables, to be presented on the print canvas according to the processing methods of the corresponding components.

[0118] like Figure 5As shown, in one embodiment of the present invention, in order to update the corresponding print template preview when the component instance attributes change and to reduce repeated rendering of the unchanged component instances, the method of the present invention further includes a process of partially refreshing the print template preview, which includes steps S501 to S504.

[0119] Step S501: In response to a layout adjustment operation, attribute setting operation, or data binding operation on the target component instance, update the component instance attributes of the target component instance and send a partial refresh notification for the target component instance to the canvas rendering layer.

[0120] The target component instance refers to the component instance targeted by this layout adjustment operation, attribute setting operation, or data binding operation. The system can determine the target component instance from the set of component instances corresponding to the print canvas based on the component instance identifier of the target component instance, and write the attribute values ​​generated by the operation into its component instance properties.

[0121] For example, when moving or scaling a target component instance, its position or size attributes can be updated; when modifying font, color, border, or alignment through the properties panel, the corresponding style attributes can be updated; when reselecting a business field, the field path in the data binding information can be updated. After the component instance attributes are updated, a partial refresh notification is sent to the canvas rendering layer so that the canvas rendering layer can perform a refresh based on the updated component instance attributes.

[0122] A partial refresh notification can include the component instance identifier of the target component instance and the attribute identifier or attribute category of the updated attribute, and may also include the attribute values ​​before and after the update. After receiving a partial refresh notification, the canvas rendering layer can determine the target component instance that needs to be re-rendered based on the component instance identifier, without having to traverse and re-render all component instances in the print canvas.

[0123] In one implementation, the canvas rendering layer can maintain corresponding rendering nodes or rendering objects for each component instance. During partial refresh, only the rendering node or rendering object corresponding to the target component instance is updated, thus achieving linkage between the update of component instance properties and the print template preview.

[0124] Step S502: Determine the partial refresh method of the target component instance based on whether the updated component instance attributes involve changes in data binding information.

[0125] In this embodiment of the invention, it can be determined whether the update involves changes to data binding information based on the attribute identifier, attribute category, or value configuration information of the updated attribute. Alternatively, the component instance attributes before and after the update can be compared to determine whether the field path, value retrieval method, or data source has changed.

[0126] If the update does not involve changes to data binding information, it means that the method or source of the target component instance for obtaining the data to be rendered will not change, and the updated component instance properties can be used directly for re-rendering. If the update involves changes to data binding information, it means that the field path, table data source, barcode data source, or image data source corresponding to the target component instance has changed, and the data to be rendered needs to be re-determined based on the changed data binding information.

[0127] When an operation updates the properties of multiple component instances simultaneously, if any of the updated properties involves changes in data binding information, a partial refresh method that re-fetches the field value can be used; if none of the updated properties involve changes in data binding information, a partial refresh method that directly re-renders can be used.

[0128] Step S503: When the updated component instance properties do not involve changes in data binding information, the corresponding renderer is called according to the updated component instance properties, and only the target component instance is re-rendered.

[0129] In this embodiment of the invention, when the updated component instance attributes do not involve changes in data binding information, the corresponding renderer can be determined based on the component rendering information of the component corresponding to the target component instance, and the updated component instance attributes can be provided to the renderer. For target component instances without data binding relationships, the renderer can directly determine the content to be rendered based on the component instance attributes; for target component instances with data binding relationships but whose layout or style has only changed this time, the field values ​​previously obtained from the preview data can continue to be used without re-parsing the field paths.

[0130] For example, when the position changes, the position of the corresponding rendering node of the target component instance can be updated; when the size changes, its rendering area can be updated; when the font or color changes, the original content to be displayed can be used and redrawn according to the updated font or color. For the area where the target component instance was located before it moved, it can be handled by updating the independent rendering node or clearing the original rendering result of the target component instance.

[0131] Here, re-rendering only the target component instance means not re-executing the data retrieval and rendering process of other component instances in the print canvas. Other component instances in the print canvas continue to maintain their original rendering results.

[0132] Step S504: When the updated component instance properties involve changes in data binding information, the field values ​​of the corresponding business fields are retrieved from the preview data according to the field paths recorded in the updated data binding information, and the corresponding renderer is called according to the retrieved field values ​​to re-render only the target component instance to update the print template preview.

[0133] Changes in location, size, font, or color attributes are considered changes that do not involve data binding information, while changes in field paths, table data sources, barcode data sources, or image data sources are considered changes that involve data binding information.

[0134] In this embodiment of the invention, when the updated component instance attribute involves changes in data binding information, the field path can be read from the updated value configuration information, and the preview data can be accessed according to the field path to re-obtain the field value of the corresponding business field. The preview data can be sample data, current document data, or user-specified test data.

[0135] After retrieving the field values, the corresponding renderer can be invoked based on the component rendering information of the target component instance, and the retrieving field values ​​and the component instance properties of the target component instance can be provided to the renderer. For example, when the table data source changes, the corresponding detail collection can be retrieved again and the table content updated; when the barcode data source changes, the barcode graphic can be regenerated based on the new field values; when the image data source changes, the corresponding image resources can be reloaded based on the new field values.

[0136] Both re-fetching field values ​​and re-rendering are performed on the target component instance and do not re-fetch or re-render other component instances. After the rendering result of the target component instance is updated, the updated rendering result can be displayed in the print canvas, thereby updating the print template preview.

[0137] For ease of distinction, attributes that do not change the data source, such as position, size, font, color, border, background color, transparency, and alignment, can be called static attributes. When static attributes change, it is usually sufficient to redraw the target component instance according to the updated attribute values.

[0138] Field paths, table data sources, barcode data sources, image data sources, and other configuration information used to determine dynamic content can be called dynamic attributes. When dynamic attributes change, the data to be rendered needs to be re-obtained or recalculated according to the updated configuration information before updating the dynamic content of the target component instance. For component instances that use expressions or functions for value retrieval, when the corresponding expression or function call information changes, it can also be re-evaluated and the same partial refresh method used for changes in data binding information can be applied.

[0139] By using the partial refresh method described above, users can adjust the layout, attributes, or data binding of component instances and then view the updated display effect of the target component instance in the print canvas, reducing the need to save the template and then go to the preview or print page for verification. At the same time, since it eliminates the need to re-fetch and render data for all component instances in the print canvas, it reduces the processing overhead of redrawing the entire page.

[0140] In one embodiment of the present invention, the component library can also support the access of newly added component types. The access information for the newly added component type may include component metadata, component attribute information and their default attribute values, attribute panel configuration information, data binding capabilities, and component rendering information. The system can add the newly added component type to the component library based on this access information, generate corresponding component options in the component panel based on the component name, component icon, and component category, generate corresponding attribute editing items based on the attribute panel configuration information, and establish a correspondence between the newly added component type and the corresponding renderer based on the component rendering information.

[0141] After a new type of component is added to the component library, it can generate a component instance with independent component instance attributes when it is added to the print canvas, in the same way as existing components. It can also perform data binding based on its data binding capabilities, participate in print template preview and runtime printing based on its component rendering information, and save the configuration state of the corresponding component instance to the print template model.

[0142] For example, when adding a QR code component to the component library, you can configure the component name, component icon, default width, and default height. You can also configure attributes such as code type, error correction level, whether to display text, and data source in the component's properties information, and configure the QR code renderer. After integration, the QR code component can be displayed in the component panel and can be added to the print canvas, its instance properties configured, business fields bound, a QR code preview generated, and saved to the print template model.

[0143] like Figure 6 As shown, in one embodiment of the present invention, step S105 above generates a print template model including each component instance based on the configuration information of the print canvas and the component instance attributes of each component instance, including steps S601 to S603.

[0144] Step S601: Based on the combination relationship and parent-child hierarchy relationship between component instances, establish a component tree with each component instance as a node.

[0145] In this embodiment of the invention, a composition relationship can be established when a user performs a composition operation on multiple component instances, indicating that multiple component instances belong to the same composition object. A parent-child hierarchy is used to represent the containment relationship between component instances. For example, a table component instance can contain component instances used to represent table headers, fields, or cell content; a composition component instance can contain text component instances, line segment component instances, or image component instances that participate in the composition.

[0146] In this embodiment of the invention, when establishing a component tree, corresponding nodes can be created for each component instance based on the component instance identifier, and the connection relationships between nodes can be determined based on the combination relationship and parent-child hierarchy relationship between the component instances. Component instances not included by other component instances can correspond to the root node in the component tree; if the component tree includes multiple root nodes, a virtual root node can also be set, and each root node can be set as a child node of the virtual root node.

[0147] The component tree is used to record the structural relationships between component instances. The display hierarchy order of component instances determines the drawing order when component instances overlap, while the parent-child hierarchy represents the containment relationship between component instances; these two belong to different levels of hierarchy information. In the component tree, a correspondence can be established between nodes and the component instance properties of the corresponding component instances through the component instance identifiers recorded in each node.

[0148] The component tree can be dynamically updated as the grouping or parent-child hierarchy changes during the user's editing of the print template. Alternatively, it can be built by centrally based on the component instances and their relationships in the current print canvas when generating the print template model.

[0149] Step S602: In response to the template saving operation, the configuration information of the printing canvas, the component tree, the type of each component instance, and the component instance attributes of each component instance are organized into the printing template model according to a unified template data structure.

[0150] The component instance attributes include position, size, style, and display hierarchy order; for component instances with data binding relationships, the component instance attributes also include the field path of the corresponding business field.

[0151] In this embodiment of the invention, the template saving operation can be triggered by the user clicking the save control, executing a shortcut key operation, or issuing other template saving commands. Upon receiving the template saving operation, the configuration information of the current print canvas, the component tree, and the current component instance attributes of each component instance can be read, and the read information can be organized into a unified template data structure.

[0152] Before saving the template, when the user moves, scales, copies, deletes, moves up, moves down, pins, or groups component instances, the system can synchronously update the collection of component instances in the print canvas, the component instance properties of the corresponding component instances, and the grouping and parent-child hierarchical relationships between the component instances. Therefore, when the template is saved, it retrieves the latest configuration state of each component instance in the current print canvas.

[0153] The configuration information for the print canvas can include paper size, paper orientation, and page margins, as well as design configuration information such as canvas scaling and grid lines. The canvas scaling and grid lines can be written into the print template model when the design state needs to be saved.

[0154] The type of the component instance is used to indicate whether the component instance belongs to a text component, field component, barcode component, line segment component, image component, or table component. This is so that the corresponding attribute interpretation method can be determined according to the component type, and the corresponding component rendering information and renderer can be determined from the component library based on the component type.

[0155] The position and size of a component instance describe its layout on the printed canvas; styles describe display effects such as borders, background color, transparency, font, font size, color, and alignment; and the display hierarchy order determines the drawing order of each component instance. Component instance properties may also include rotation angle, visibility, and proprietary properties corresponding to the corresponding component type.

[0156] For component instances with data binding relationships, the field path of the business field is recorded as part of the data binding information in the component instance properties. In some implementations, the component instance properties can also record the value retrieval method and value content to distinguish between fixed value retrieval, field binding value retrieval, expression value retrieval, or function value retrieval. The print template model can also record image resource references and other information used to restore the component instance configuration state as needed.

[0157] A unified template data structure can include a canvas configuration section and a component tree section. Each node in the component tree can record or associate the type of the corresponding component instance, component instance attributes, and child nodes. Therefore, the print template model can describe the print page, the collection of component instances, the structural relationships between component instances, and the configuration state of each component instance, rather than simply fixing the print template to print page code or the final print image.

[0158] For example, text component instances can be used to form titles, field component instances to represent basic document information, table component instances to represent detailed data, barcode component instances to represent document numbers, and image component instances to represent company logos or signatures. These different types of component instances, along with their layouts, attributes, and data binding information, can all be organized into the print template model according to a unified template data structure.

[0159] Step S603: Serialize and store the printed template model.

[0160] In this embodiment of the invention, serialization refers to converting a structured print template model into a data format that can be stored or transmitted. JSON, XML, binary data, or a custom format can be used to serialize the print template model, as long as the serialized data retains the configuration information of the print canvas, the component tree, and the component instance attributes of each component instance.

[0161] The serialized print template model can be stored in a database, file system, or object storage space, and can be associated with corresponding documents, business types, or template identifiers. In some implementations, the name, version, creation time, modification time, or publication status of the print template model can also be recorded for subsequent loading, editing, publishing, or runtime printing.

[0162] When the print template is reopened later, the serialized data can be deserialized, the print canvas can be restored according to the configuration information of the print canvas, and each component instance can be restored according to the component tree and the component instance properties corresponding to each node.

[0163] like Figure 7 As shown, in one embodiment of the present invention, step S601 above establishes a component tree with each component instance as a node based on the combination relationship and parent-child hierarchy relationship between each component instance, including steps S701 and S702.

[0164] Step S701: For the component instance corresponding to the table component or the combined component instance formed by combining multiple component instances, determine the component instance corresponding to the table component or the combined component instance as the parent component instance, and determine the component instances contained in the parent component instance as the child component instances.

[0165] For a table component instance, its sub-component instances can be component instances used to represent table headers, field content, or cell content. For a composite component instance, its sub-component instances can be multiple component instances selected by the user and used for a combination operation. The composite component instance itself represents the overall object after combination, while each sub-component instance still retains its corresponding component instance properties.

[0166] Parent and child component instances can be associated using component instance identifiers. For example, a parent component instance can record the identifiers of its contained child component instances, and a child component instance can record the identifier of its corresponding parent component instance. A child component instance can also serve as the parent component instance of other component instances, thus forming a multi-level nested parent-child hierarchy.

[0167] Step S702: According to the parent-child hierarchy relationship between the parent component instance and each child component instance, the node corresponding to the parent component instance is taken as the parent node, and the node corresponding to each child component instance is taken as the child node of the parent node. The relative coordinates of the corresponding child component instance relative to the parent component instance are recorded in the child node corresponding to each child component instance to establish the component tree.

[0168] The relative coordinates of each child component instance with respect to its parent component instance can be calculated based on their positions on the printed canvas. For example, if the parent component instance is located at (Xp, Yp) and the child component instance is located at (Xc, Yc), then the relative coordinates of the child component instance with respect to its parent component instance can be expressed as (Xc - Xp, Yc - Yp). The relative coordinates can be calculated with the top-left corner of the parent component instance as the origin, or based on other preset reference points.

[0169] In the component tree, the node corresponding to the parent component instance is used to record or associate the component instance properties of the parent component instance, and the node corresponding to each child component instance is a child node of the corresponding parent node. The child node can record the child component instance identifier, the parent component instance identifier, and the relative coordinates, and can also record the display hierarchy order of the child component instance.

[0170] For multi-level nested parent-child hierarchical relationships, parent and child nodes can be recursively created in the same way. Component instances not contained by other component instances serve as the root node or the child node of the virtual root node. This allows the formation of a component tree that can represent the hierarchical relationships between table component instances, composite component instances, and their internal component instances.

[0171] In one embodiment of the present invention, in order to maintain the relative positional relationship between the parent component instance and each child component instance when the parent component instance moves, the method of the present invention further includes: In response to the movement operation of the parent component instance, the position of each child component instance after movement is determined according to the position of the parent component instance after movement and the relative coordinates of each child component instance relative to the parent component instance. The position of each child component instance after movement is written into the position attribute of the corresponding child component instance to keep the relative position of each child component instance relative to the parent component instance unchanged before and after the parent component instance is moved.

[0172] In this embodiment of the invention, after the parent component instance is moved, the relative coordinates of each child component instance with respect to the parent component instance can remain unchanged, and the new positions of each child component instance can be calculated based on the new position of the parent component instance. For example, if the position of the parent component instance after moving is (Xp′, Yp′), and the relative coordinates of the child component instance with respect to the parent component instance are (ΔX, ΔY), then the position of the child component instance after moving can be determined as (Xp′ + ΔX, Yp′ + ΔY).

[0173] After determining the positions of each child component instance after it has been moved, the position properties of each child component instance can be updated individually, and the display position of the corresponding child component instance in the print canvas can be updated synchronously. For component instances with multi-level parent-child hierarchies, the positions of each level of child component instances can be determined step by step according to the component tree, starting from the moved parent component instance.

[0174] During the overall movement of the parent component instance and its child component instances, the relative coordinates between each child component instance and the parent component instance remain unchanged, and the parent-child hierarchy in the component tree also remains unchanged. Therefore, when moving a table component instance or a composite component instance, its internal component instances can be moved synchronously, avoiding changes in the positional relationships between internal components after the overall movement.

[0175] Using the above method, the print canvas configuration, component instance properties, data binding information, composition relationships, and parent-child hierarchy relationships can be organized into a structured print template model. The internal structure of complex component objects can be saved through component trees and relative coordinates, which facilitates the saving and subsequent restoration of print templates.

[0176] In one embodiment of the present invention, the component information further includes component rendering information, which is used to determine the renderer corresponding to each type of component.

[0177] In this embodiment of the invention, the component rendering information used for runtime printing can be the same as the component rendering information used when generating the print template preview during the design phase. The print template model records the type of the component corresponding to each component instance. During runtime, the component rendering information of the corresponding component can be determined from the component library based on the component type, and then the renderer to be called can be determined. Therefore, it is not necessary to save the renderer itself separately in each component instance.

[0178] Different types of components can be assigned to renderers that can handle their specific attributes and data. For example, text components correspond to text renderers, field components to field renderers, barcode components to barcode renderers, line segment components to line segment renderers, image components to image renderers, and table components to table renderers.

[0179] like Figure 8As shown, in one embodiment of the present invention, in order to generate print output based on the configured print template model and current business data during runtime, the method of the present invention further includes a runtime rendering process of the print template, which includes steps S801 to S805.

[0180] Step S801: During runtime printing, load the print template model and current business data.

[0181] In this embodiment of the invention, runtime printing refers to the process of generating print output based on a pre-configured print template model and actual business data. The print template model can be a print template model that has been saved or published after design, and can be loaded from a database, file system, or object storage space.

[0182] Current business data refers to the actual data corresponding to the business object to be printed. For example, when printing a purchase order, current business data may include the order number, supplier, date, product details, and receipt information; when printing an outbound slip, current business data may include the warehouse, consignee, material details, and barcode data. Current business data can be read from the business system's database, business interfaces, or the data model associated with the target document.

[0183] The data structure of the current business data can correspond to the data structure of the external business data source used in the print template design phase, so that the field paths recorded in the print template model can be used to locate the corresponding business fields in the current business data.

[0184] Step S802: Parse the print template model to obtain the configuration information of the print canvas, each component instance, and the component instance attributes of each component instance.

[0185] In this embodiment of the invention, when the print template model is stored in serialized form, it can be deserialized first to recover the structured data in the print template model. When parsing the print template model, configuration information of the print canvas, such as paper size, paper orientation, and page margins, can be obtained, as well as the type, component instance identifier, and component instance attributes of each component instance.

[0186] When the print template model includes a component tree, the component tree can be parsed to obtain the composition relationships, parent-child hierarchy relationships, and relative coordinates between component instances. For component instances with parent-child hierarchy relationships, the position of each child component instance in the page area can be determined based on the position of the parent component instance and the relative coordinates of the child component instances.

[0187] The parsed component instance properties can include position, size, style, display hierarchy order, proprietary properties, and data binding information. For component instances with data binding relationships, the data binding information can include the method of retrieving values ​​and the field path used as the value content.

[0188] Step S803: Traverse each component instance. For a component instance with a data binding relationship, obtain the field value of the corresponding business field from the current business data according to the field path recorded in the component instance attribute of the component instance.

[0189] In this embodiment of the invention, when traversing each component instance, the traversal can be performed according to the node order represented by the component tree, or the processing order can be determined by combining the display hierarchy order of each component instance. For component instances that do not have a parent-child hierarchy relationship, the traversal can be performed according to their recording order in the print template model or their display hierarchy order.

[0190] When the value retrieval method of a component instance property is field binding, the corresponding field path can be read, and the current business data can be accessed according to the data hierarchy represented by the field path to obtain the field value of the corresponding business field. The field value can be text, number, date, image resource information, object, or detail collection.

[0191] If the field path does not exist in the current business data or the corresponding field value is empty, blank content, default content, or preset prompt content can be used according to the null value handling rules in the component instance properties. For component instances that use fixed value retrieval, the fixed value recorded in the component instance properties can be read directly; for component instances that use expression retrieval or function retrieval, the corresponding expression can be evaluated or the corresponding backend extension function can be called to determine the data to be rendered.

[0192] Step S804: Call the corresponding renderer according to the component rendering information of the component corresponding to each component instance, and render each component instance according to the component instance attributes of each component instance and the field values ​​obtained for component instances with data binding relationships.

[0193] In this embodiment of the invention, for each component instance, the corresponding component and its rendering information can be determined from the component library according to the type of the corresponding component, and the corresponding renderer can be called according to the component rendering information. The renderer determines the layout and style of the component instance according to the component instance attributes, and determines the rendering content of the component instance according to the obtained field values, fixed values, expression evaluation results, or function return results.

[0194] The text renderer can output fixed text or the evaluation result of an expression; the field renderer can convert field values ​​into text according to formatting rules; the barcode renderer can generate barcode graphics from the data to be encoded according to attributes such as code system, error correction level, and whether to display text; the line segment renderer can draw line segments according to the start point, end point, line width, line type, and color.

[0195] Image renderers can interpret field values ​​as image addresses, attachment identifiers, or binary resources, and generate image rendering results based on scaling, transparency, cropping attributes, and rotation angles. Table renderers can interpret field values ​​as a collection of details, retrieve the content of the corresponding columns from each detailed data entry based on column structure, headers, row height, and cell styles, and generate table content row by row.

[0196] Step S805: Based on the position, size, and display hierarchy order in the component instance attributes of each component instance, combine the rendering results of each component instance into the page area determined according to the configuration information of the printing canvas to generate the final print output.

[0197] In this embodiment of the invention, the paper size, paper orientation, page margins, and printable area of ​​the printed page can be determined based on the configuration information of the printing canvas. For overlay printing scenarios, the output position of each component instance relative to the pre-printed page can also be determined based on the configuration information of the printing canvas.

[0198] The position and size of each component instance determine its placement and area of ​​the rendered result within the page area, while the display hierarchy order determines the stacking order when multiple rendered results overlap. For component instances with a parent-child hierarchy, the rendered results of the parent component instance and each child component instance can be combined into a single object using the component tree and relative coordinates, and then this single object can be placed within the page area.

[0199] After combining the rendering results of each component instance, page drawing data, PDF files, image files, or print data that the printer can process can be generated and used as the final print output. The print output can also generate watermarks, signatures, barcodes, images, or dynamic details based on the component instances contained in the print template model.

[0200] Design-time print template previews can determine the layout, style, and content to be rendered for each component instance based on the component instances and their properties in the print canvas; runtime printing can process the component instances and their properties obtained from parsing the print template model accordingly. Design-time print template previews and runtime printing can use the same component instance property interpretation and retrieval rules to handle fixed values, field paths, expressions, or functions, thus reducing differences in component layout and content processing between the two.

[0201] like Figure 9 As shown, in one embodiment of the present invention, in order to reuse a single component instance or component combination in the source print template for the target print template and adapt the copied component instance to the external business data source corresponding to the target print template, the method of the present invention further includes a component instance copying process, which includes steps S901 to S906.

[0202] Step S901: Obtain a component copy request for the target print template. The component copy request is used to specify the source document, the source print template, and one or more source component instances to be copied.

[0203] In this embodiment of the invention, the target print template can be a newly created print template that the user is currently editing or an existing print template. The user can initiate a component copy request in the design interface of the target print template and determine the source of the component instance to be copied through the source document selection interface and the source print template selection interface.

[0204] The object to be copied can be a single source component instance or a combination of multiple source component instances. For example, a title formed by a text component instance can be copied, as can a signature area formed by a combination of text component instances, line segment component instances, and image component instances. For table component instances or composite component instances, when the user selects a parent component instance, its contained child component instances can also be included as objects to be copied to maintain the structural integrity of the copied object.

[0205] The source document and the target document corresponding to the target print template can belong to different business types. For example, the header title area, company logo area, barcode area, signature area, or detailed table area of ​​the purchase order print template can be copied to the print template of the sales order, delivery note, or approval form.

[0206] Step S902: Read the source component instances to be copied from the source print template, and parse the source component instances into a copyable component model. The copyable component model includes the type of the component corresponding to each source component instance, component instance attributes, parent-child hierarchy relationship, relative coordinates, display hierarchy order, resource references, and data binding information.

[0207] In this embodiment of the invention, a print template model corresponding to the source print template can be loaded according to the component copy request, and the corresponding source component instance can be read from the print template model according to the component instance identifier of each source component instance to be copied. For source component instances with parent-child hierarchical relationships, the corresponding parent node, child node, and hierarchical relationship between nodes can also be read according to the component tree.

[0208] A copyable component model is an intermediate model used to pass component instance configurations between source and target print templates. The copyable component model can preserve the component type, public property values, private property values, coordinates, size, style, display hierarchy order, parent-child hierarchy, relative coordinates, resource references, and data binding information corresponding to each source component instance.

[0209] For objects that primarily use fixed attribute values, such as text component instances and line segment component instances, their text content, font, border, color, start point, end point, line width, and line style can be written into the copyable component model. For image component instances, barcode component instances, and table component instances, information such as image resource references, barcode configurations, table column structure, row height, table headers, cell styles, detailed data sources, and sub-component relationships can also be written.

[0210] Step S903: In the target printing template, according to the type of the component corresponding to each source component instance, a target component instance corresponding to each source component instance is generated, and the component instance attributes and resource references of each target component instance are set according to the reproducible component model.

[0211] In this embodiment of the invention, when generating a target component instance, the corresponding component can be determined from the component library according to the type of the component corresponding to each source component instance, and the corresponding target component instance can be created in the target print template in the same way as the component instance is generated. Each target component instance generates a new component instance identifier instead of using the component instance identifier of the source component instance, so as to avoid duplicate component instance identifiers in the target print template.

[0212] When copying multiple source component instances, a mapping between source component instance identifiers and target component instance identifiers can be established. This mapping can be used to subsequently convert the parent-child hierarchy relationships between source component instances into parent-child hierarchy relationships between target component instances.

[0213] Configurations such as position, size, style, proprietary attributes, and display hierarchy order from a copyable component model can be written into the component instance properties of the corresponding target component instance. For component instances containing resource references, such as images, you can directly copy resource references that are accessible in the target print template, or you can copy the corresponding resource to a storage location accessible by the target print template and write the new resource references into the target component instance.

[0214] After copying, users can still move, scale, or modify the target component instance's properties within the target print template's print canvas without altering the source component instance in the original print template.

[0215] Step S904: When the source component instance to be copied includes multiple component instances with parent-child hierarchical relationships, the corresponding parent-child hierarchical relationships and relative positional relationships are reconstructed among the target component instances according to the reproducible component model.

[0216] In this embodiment of the invention, when the object to be copied includes multiple source component instances with a parent-child hierarchical relationship, the parent-child hierarchical relationship between the source component instances can be converted into the parent-child hierarchical relationship between the corresponding target component instances based on the correspondence between the source component instance identifier and the target component instance identifier.

[0217] For each source child component instance, its corresponding source parent component instance can be determined. Then, within the target component instance, the corresponding target child component instance and target parent component instance can be identified, and the target child component instance can be set as a child component instance of the target parent component instance. For multi-level nested component instances, the corresponding hierarchical relationship can be recursively reconstructed according to the source component tree.

[0218] The relative coordinates of each source child component instance with respect to its source parent component instance can be used as the relative coordinates of the corresponding target child component instance with respect to its target parent component instance. Therefore, even if the component composition is copied to other locations within the target print template, the relative positional relationships between the target component instances within the composition can be maintained. Regarding the display hierarchy order of multiple source component instances, their relative order can be maintained within the target print template, and their specific hierarchy values ​​can be adjusted based on the display hierarchy of existing component instances in the target print template.

[0219] Step S905: For each source component instance with data binding information, the corresponding data binding information in the reproducible component model is used as the initial data binding information of the corresponding target component instance; in response to a data binding operation on any target component instance with initial data binding information, the source field path in the initial data binding information of the target component instance is replaced with the field path of the business field selected from the external business data source corresponding to the target print template.

[0220] In this embodiment of the invention, the source print template and the target print template may correspond to different external business data sources, and their business fields and field paths may differ. Therefore, for a source component instance with data binding information, the source field path and its value method can be retained as the initial data binding information of the corresponding target component instance.

[0221] Initial data binding information serves as a hint about the existing data binding relationships of the target component instance, allowing users to understand the data content used by that component instance in the source print template. When the source and target print templates use the same or compatible data structures, the initial data binding information can continue to be used; when their data structures differ, the business fields can be reselected from the field tree corresponding to the target print template.

[0222] After the user reselects a business field, the field path of the newly selected business field is written to the component instance property of the target component instance to replace the source field path in the initial data binding information. For multiple target component instances with data binding information copied to the target print template, their field paths can be updated separately. For static component instances such as text component instances and line segment component instances that do not need to be associated with business data, the copied properties can be directly retained without updating the data binding.

[0223] Step S906: Add each target component instance to the printing canvas of the target printing template, and generate the printing template model corresponding to the target printing template based on the configuration information of the printing canvas of the target printing template, the component instance attributes of each component instance in the target printing template, and the parent-child hierarchy and relative position relationship between each component instance in the target printing template.

[0224] In this embodiment of the invention, when adding a target component instance to the printing canvas of the target printing template, the position of the source component instance in the source printing template can be used, or the position of each target component instance can be adjusted as a whole according to the pasting position specified by the user or a preset offset. When copying multiple target component instances with a parent-child hierarchical relationship, the relative positional relationship between each target component instance can be maintained while adjusting the overall position.

[0225] When generating the print template model corresponding to the target print template, both the original component instances in the target print template and the target component instances generated in this copy should be included in the print template model. The component tree should be established or updated based on the parent-child hierarchy and relative position relationships between the component instances in the target print template. The print canvas configuration information of the target print template, the type of each component instance, component instance attributes, resource references, and data binding information can be organized according to a unified template data structure.

[0226] The copied target component instance, as a regular component instance in the target print template, can continue to participate in print template preview, template saving, template publishing, and runtime printing. For example, the signature area composed of text component instances, line segment component instances, and image component instances in the purchase order print template can be copied to the sales order print template, retaining its font, border, image resources, and internal relative positions, and the data binding information that needs to be changed can be reset according to the data source of the sales order.

[0227] The above method allows for the reuse of individual component instances or component combinations from existing print templates in the target print template. It also adapts the data source of the target print template while preserving component instance properties, resource references, and internal structure, thereby reducing the need to repeatedly add components and configure component properties.

[0228] In a specific application example, a user can create a purchase order print template, adding a text component instance as a title at the top of the print canvas, and adding multiple field component instances to bind business fields such as order number, supplier, date, and handler. They can also add a table component instance, binding its detailed data source to a purchase details collection, and configuring columns such as product name, quantity, unit price, and amount. After adjusting component instance properties such as font, column width, and borders, the user can preview the adjustments through the print template and generate the corresponding print template model for the purchase order after completing the configuration.

[0229] In another specific application example, users can configure the print canvas according to the label size, add field component instances to display the material name, add barcode component instances and bind the material code, and also add image component instances to display the company logo. Barcode component instances can be configured with the code type and whether to display text, while image component instances can be configured with the image source and scaling method. After completing the configuration, a print template model for label printing can be generated.

[0230] As can be seen from the above embodiments of the present invention, the modeling method for generating printing templates based on different types of components of the present invention achieves at least the following beneficial effects: 1. A component library manages different types of components, including text components, field components, barcode components, line segment components, image components, and table components. Common and proprietary attribute information describes the shared attributes and unique functional attributes of different component types, enabling the modeling of different types of print content in a relatively uniform manner while preserving the functional differences between component types. Each component instance generated from the components has independent component instance attributes, allowing for separate layout adjustments and attribute settings. This improves the flexibility of print template configuration and reduces the complexity of separately modeling and processing different types of print elements.

[0231] 2. By writing the field paths of business fields from external business data sources into the component instance properties, a data binding relationship is established between the component instance and the business fields. This allows the print template model to simultaneously record the layout configuration and data value information of the component instance. At runtime, the field values ​​can be retrieved from the current business data based on the corresponding field paths, enabling field components, barcode components, image components, and table components to generate corresponding print content based on the business data.

[0232] 3. The component tree records the combination relationship and parent-child hierarchy relationship between component instances, and the relative coordinates record the position of the child component instance relative to the parent component instance, so that objects with internal structure, such as table components and composite components, can be saved and adjusted as a whole; by organizing the configuration information, component tree, component type, component instance attributes and data binding information of the print canvas into a structured print template model and serializing and storing it, the page configuration, component layout, style, hierarchy relationship and data binding relationship of the print template can be completely saved, and can be parsed and reconstructed in the subsequent editing and printing process.

[0233] 4. By using component rendering information, the appropriate renderer is determined for different types of components, and each component instance is rendered based on preview data. This enables the generation of print template previews corresponding to the current component instance attributes during the design phase. When component instance attributes change, only the corresponding component instance needs to be re-rendered, and the corresponding field values ​​are retrieved again when data binding information changes, thus reflecting template adjustments promptly and reducing unnecessary overall rendering. At runtime, the same print template model can be parsed, and print output can be generated based on current business data and component instance attributes, which helps reduce the difference between the print template preview during the design phase and the print output during runtime.

[0234] 5. By parsing component instances in the source print template into a reproducible component model and reconstructing the component instance attributes, resource references, parent-child hierarchy relationships, and relative position relationships of the corresponding component instances in the target print template, a single component instance or component combination in an existing print template can be reused. For data binding information that differs between different business data sources, the original field path can be replaced according to the business field corresponding to the target print template, thereby reducing the repetitive configuration of similar print areas and improving the convenience of building print templates across documents and templates.

[0235] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0236] Based on the same inventive concept, embodiments of the present invention also provide a modeling apparatus for generating print templates based on different types of components, which can be used to implement the modeling method for generating print templates based on different types of components described in the above embodiments, as described in the following embodiments. Since the principle of the modeling apparatus for generating print templates based on different types of components is similar to that of the modeling method for generating print templates based on different types of components, embodiments of the modeling apparatus for generating print templates based on different types of components can be found in embodiments of the modeling method for generating print templates based on different types of components, and repetitions will not be repeated. As used below, the terms "unit" or "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0237] Figure 10 This is a structural block diagram of a modeling device for generating printing templates based on different types of components according to an embodiment of the present invention, such as... Figure 10 As shown, in one embodiment of the present invention, the modeling apparatus for generating printing templates based on different types of components includes: Component library acquisition unit 1 is used to acquire a preset component library. The component library contains multiple types of components and stores component information corresponding to each type of component. The multiple types of components include text components, field components, barcode components, line segment components, image components, and table components. The component information includes component attribute information. The component instance generation unit 2 is used to generate a corresponding component instance in the printing canvas in response to the operation of adding the component selected from the component library to the printing canvas, based on the component attribute information corresponding to the selected component. Instance property update unit 3 is used to update the component instance properties of the corresponding component instance in response to a layout adjustment operation of the component instance in the printed canvas or a property setting operation of the component instance. Data binding unit 4 is used to respond to the data binding operation on the component instance by writing the field path of the business field selected from the external business data source to the component instance property of the corresponding component instance to record the data binding information of the corresponding component instance. The template model generation unit 5 is used to generate a print template model including each component instance based on the configuration information of the print canvas and the component instance attributes of each component instance.

[0238] In one embodiment of the present invention, the component instance generation unit includes: The instance identifier generation module is used to generate a unique component instance identifier for the component instance to be generated. The instance property creation module is used to create the component instance properties of the component instance to be generated based on the component property information corresponding to the selected component, and to use the default property values ​​in the component property information as the initial values ​​of the component instance properties. The initial coordinate determination module is used to determine the initial coordinates of the component instance to be generated based on the addition position of the selected component in the printed canvas, and use the initial coordinates as the initial value of the position attribute of the component instance to be generated; Among them, multiple component instances generated from the same component each have a unique component instance identifier and mutually independent component instance attributes; when the component instance attributes of any component instance are updated, the component attribute information of the component corresponding to that component instance in the component library remains unchanged.

[0239] In one embodiment of the present invention, the data binding unit includes: The metadata acquisition module is used to acquire the metadata corresponding to the external business data source. The metadata includes field information of each business field in the external business data source and the hierarchical relationship between each business field. The field tree construction module is used to construct a field tree based on the field information and hierarchical relationship of each business field. The field tree includes multiple field nodes, each field node corresponds to a business field and is associated with the field path of the corresponding business field. The field path acquisition module is used to acquire the field path associated with the target field node in response to the operation of selecting a target field node for the component instance to be bound from the field tree; The data binding establishment module is used to write the field path associated with the target field node as the value content into the component instance property of the component instance to be bound, and set the value retrieval method in the component instance property to field binding value retrieval, so as to establish a data binding relationship between the component instance to be bound and the business field corresponding to the target field node.

[0240] In one embodiment of the present invention, the component information corresponding to each type of component further includes component rendering information, wherein the component rendering information is used to determine the renderer corresponding to each type of component; The device further includes: The preview data acquisition unit is used to acquire preview data for generating a print template preview; The preview field value acquisition unit is used to obtain the field value of the corresponding business field from the preview data for component instances with data binding relationship, based on the field path recorded in the corresponding component instance properties; The preview rendering unit is used to call the corresponding renderer according to the component rendering information of the component corresponding to each component instance, and render each component instance according to the component instance properties and the field values ​​obtained when the corresponding component instance has a data binding relationship, so as to generate a print template preview. Specifically, for component instances with data binding relationships, when the component instance corresponds to a field component, the corresponding renderer renders the field value as text; when the component instance corresponds to a barcode component, the corresponding renderer encodes the field value as a barcode graphic; when the component instance corresponds to an image component, the corresponding renderer obtains the image resource based on the field value and renders it; when the component instance corresponds to a table component, the corresponding renderer uses the field value as a details set and renders it row by row.

[0241] In one embodiment of the present invention, the device further includes: The refresh notification unit is used to update the component instance properties of the target component instance in response to layout adjustment operations, attribute setting operations, or data binding operations on the target component instance, and to send a partial refresh notification for the target component instance to the canvas rendering layer. The refresh method determination unit is used to determine the partial refresh method of the target component instance based on whether the updated component instance attributes involve changes in data binding information; The property refresh unit is used to call the corresponding renderer based on the updated component instance properties when the updated component instance properties do not involve changes in data binding information, and only re-render the target component instance. The data refresh unit is used to retrieve the field value of the corresponding business field from the preview data according to the field path recorded in the updated data binding information when the updated component instance property involves changes in data binding information, and call the corresponding renderer according to the retrieved field value to re-render only the target component instance to update the print template preview. Changes in location, size, font, or color attributes are considered changes that do not involve data binding information, while changes in field paths, table data sources, barcode data sources, or image data sources are considered changes that involve data binding information.

[0242] In one embodiment of the present invention, the template model generation unit includes: The component tree building module is used to build a component tree with each component instance as a node, based on the composition relationship and parent-child hierarchy relationship between component instances. The template model organization module is used to organize the configuration information of the print canvas, the component tree, the type of each component instance, and the component instance attributes of each component instance into the print template model in response to the template saving operation according to a unified template data structure. The component instance attributes include position, size, style, and display hierarchy order; for component instances with data binding relationships, the component instance attributes also include the field path of the corresponding business field. The template model storage module is used to serialize and store the printed template model.

[0243] In one embodiment of the present invention, the component tree building module includes: The parent-child instance determination submodule is used to determine the component instance corresponding to the table component or the combined component instance formed by combining multiple component instances as the parent component instance, and to determine the component instances contained in the parent component instance as the child component instances. The component tree construction submodule is used to construct the component tree by taking the node corresponding to the parent component instance as the parent node and the node corresponding to each child component instance as the child node of the parent node according to the parent-child hierarchy relationship between the parent component instance and each child component instance, and recording the relative coordinates of the corresponding child component instance relative to the parent component instance in the child node of each child component instance.

[0244] In one embodiment of the present invention, the device further includes: The linkage movement unit is used to respond to the movement operation of the parent component instance, determine the position of each child component instance after movement according to the position of the parent component instance after movement and the relative coordinates of each child component instance relative to the parent component instance, and write the position of each child component instance after movement into the position attribute of the corresponding child component instance, so as to keep the relative position of each child component instance relative to the parent component instance unchanged before and after the parent component instance is moved.

[0245] In one embodiment of the present invention, the component information further includes component rendering information, which is used to determine the renderer corresponding to each type of component; The device further includes: The runtime loading unit is used to load the print template model and current business data during runtime printing. The model parsing unit is used to parse the print template model to obtain the configuration information of the print canvas, each component instance, and the component instance attributes of each component instance; The runtime field value acquisition unit is used to traverse each component instance. For a component instance with a data binding relationship, it retrieves the field value of the corresponding business field from the current business data according to the field path recorded in the component instance attribute of the component instance. The runtime rendering unit is used to call the corresponding renderer based on the component rendering information of the component corresponding to each component instance, and to render each component instance based on the component instance properties and the field values ​​obtained for component instances with data binding relationships. The print output generation unit is used to combine the rendering results of each component instance into a page area determined according to the configuration information of the print canvas, based on the position, size and display hierarchy order in the component instance attributes of each component instance, to generate the final print output.

[0246] In one embodiment of the present invention, the device further includes: The copy request acquisition unit is used to acquire a component copy request for a target print template. The component copy request is used to specify the source document, the source print template, and one or more source component instances to be copied. The copy model generation unit is used to read each source component instance to be copied from the source printing template and parse each source component instance into a copyable component model. The copyable component model includes the type of the component corresponding to each source component instance, component instance attributes, parent-child hierarchy relationship, relative coordinates, display hierarchy order, resource references and data binding information. The target instance generation unit is used to generate target component instances corresponding to each source component instance in the target printing template according to the type of the component corresponding to each source component instance, and to set the component instance attributes and resource references of each target component instance according to the reproducible component model. The hierarchical relationship reconstruction unit is used to reconstruct the corresponding parent-child hierarchical relationship and relative position relationship between each target component instance according to the reproducible component model when the source component instance to be copied includes multiple component instances with parent-child hierarchical relationship. The initial binding setting unit is used to set the corresponding data binding information in the reproducible component model as the initial data binding information of the corresponding target component instance for each source component instance that has data binding information. The binding path update unit is used to replace the source field path in the initial data binding information of any target component instance with the field path of the business field selected from the external business data source corresponding to the target print template in response to a data binding operation on any target component instance with initial data binding information. The target template generation unit is used to add each target component instance to the printing canvas of the target printing template, and generate the printing template model corresponding to the target printing template according to the configuration information of the printing canvas of the target printing template, the component instance attributes of each component instance in the target printing template, and the parent-child hierarchy and relative position relationship between each component instance in the target printing template.

[0247] To achieve the above objectives, according to another aspect of this application, a computer device is also provided. For example... Figure 11 As shown, the computer device includes a memory, a processor, a communication interface, and a communication bus. The memory stores a computer program that can run on the processor. When the processor executes the computer program, it implements the steps in the method of the above embodiments.

[0248] The processor can be a central processing unit (CPU). The processor can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or combinations of the above types of chips.

[0249] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs, and units, such as the program units corresponding to the above-described method embodiments of the present invention. The processor executes various functional applications and data processing of the processor by running the non-transitory software programs, instructions, and modules stored in the memory, thereby implementing the methods described in the above-described method embodiments.

[0250] The memory may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created by the processor, etc. Furthermore, the memory may include high-speed random access memory and non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory may optionally include memory remotely located relative to the processor, which can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0251] The one or more units are stored in the memory and, when executed by the processor, perform the methods described in the above embodiments.

[0252] The specific details of the aforementioned computer equipment can be understood by referring to the relevant descriptions and effects in the above embodiments, and will not be repeated here.

[0253] To achieve the above objectives, according to another aspect of this application, a computer-readable storage medium is also provided, which stores a computer program that, when executed in a computer processor, implements the steps in the modeling method for generating printing templates based on different types of components described above. Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk drive (HDD), or solid-state drive (SSD), etc.; the storage medium may also include combinations of the above types of memory.

[0254] To achieve the above objectives, according to another aspect of this application, a computer program product is also provided, including a computer program / instructions that, when executed by a processor, implement the steps of the modeling method for generating print templates based on different types of components described above.

[0255] Obviously, those skilled in the art will understand that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device, or fabricating them separately as individual integrated circuit modules, or fabricating multiple modules or steps as a single integrated circuit module. Thus, the present invention is not limited to any particular hardware and software combination.

[0256] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A modeling method for generating print templates based on different types of components, characterized in that, include: Obtain a preset component library, which contains various types of components and stores component information corresponding to each type of component. The various types of components include text components, field components, barcode components, line segment components, image components, and table components. The component information includes component attribute information. In response to the operation of adding the component selected from the component library to the printing canvas, a corresponding component instance is generated in the printing canvas according to the component attribute information corresponding to the selected component; In response to layout adjustment operations on component instances in the printed canvas or property setting operations on component instances, update the component instance properties of the corresponding component instances. In response to a data binding operation on a component instance, the field path of the business field selected from the external business data source is written to the component instance property of the corresponding component instance to record the data binding information of the corresponding component instance; Based on the configuration information of the print canvas and the component instance attributes of each component instance, a print template model including each component instance is generated.

2. The modeling method for generating printing templates based on different types of components according to claim 1, characterized in that, The component attribute information includes public attribute information and proprietary attribute information; The common attribute information includes layout attributes and style attributes that can be shared by different types of components. The layout attributes include position, size, and display hierarchy order. The style attributes include border, background color, transparency, font, font size, color, and alignment. The proprietary attribute information includes functional attributes unique to the corresponding type of component. Specifically, the proprietary attribute information of the field component includes the field path and formatting rules, the proprietary attribute information of the barcode component includes the code system and data source, the proprietary attribute information of the image component includes the image source and scaling method, and the proprietary attribute information of the table component includes column structure, row height, table header, cell style, and detailed data source.

3. The modeling method for generating printing templates based on different types of components according to claim 1, characterized in that, The step of generating a corresponding component instance in the print canvas based on the component attribute information corresponding to the selected component includes: Generate a unique component instance identifier for the component instance to be generated; Based on the component attribute information corresponding to the selected component, the component instance attributes of the component instance to be generated are established, and the default attribute values ​​in the component attribute information are used as the initial values ​​of the component instance attributes. Based on the added position of the selected component in the printed canvas, the initial coordinates of the component instance to be generated are determined, and the initial coordinates are used as the initial value of the position attribute of the component instance to be generated; wherein, multiple component instances generated from the same component each have a unique component instance identifier and mutually independent component instance attributes; when the component instance attribute of any component instance is updated, the component attribute information of the component corresponding to that component instance in the component library remains unchanged.

4. The modeling method for generating printing templates based on different types of components according to claim 1, characterized in that, The step of responding to a data binding operation on a component instance by writing the field path of the business field selected from the external business data source into the component instance property of the corresponding component instance includes: Obtain the metadata corresponding to the external business data source, the metadata including field information of each business field in the external business data source and the hierarchical relationship between each business field; A field tree is constructed based on the field information and hierarchical relationship of each business field. The field tree includes multiple field nodes, each field node corresponding to a business field and associated with the field path of the corresponding business field. In response to the operation of selecting a target field node from the field tree for the component instance to be bound, the field path associated with the target field node is obtained; The field path associated with the target field node is written as the value content into the component instance property of the component instance to be bound, and the value retrieval method in the component instance property is set to field binding value retrieval, so as to establish a data binding relationship between the component instance to be bound and the business field corresponding to the target field node.

5. The modeling method for generating printing templates based on different types of components according to claim 1, characterized in that, The component information corresponding to each type of component also includes component rendering information, which is used to determine the renderer corresponding to each type of component. The method further includes: Obtain preview data used to generate a print template preview; For component instances with data binding relationships, the field values ​​of the corresponding business fields are obtained from the preview data based on the field paths recorded in the corresponding component instance properties. The corresponding renderer is invoked based on the component rendering information of each component instance. Each component instance is then rendered according to its attributes and the field values ​​obtained when the corresponding component instances have data binding relationships, to generate a print template preview. Specifically, for component instances with data binding relationships, when the component instance corresponds to a field component, the corresponding renderer renders the field value as text; when the component instance corresponds to a barcode component, the corresponding renderer encodes the field value as a barcode graphic; when the component instance corresponds to an image component, the corresponding renderer obtains the image resource based on the field value and renders it; and when the component instance corresponds to a table component, the corresponding renderer uses the field value as a detail set and renders it row by row.

6. The modeling method for generating printing templates based on different types of components according to claim 5, characterized in that, Also includes: In response to layout adjustment operations, attribute setting operations, or data binding operations on the target component instance, update the component instance attributes of the target component instance and send a partial refresh notification for the target component instance to the canvas rendering layer. The partial refresh method of the target component instance is determined based on whether the updated component instance properties involve changes in data binding information; When the updated component instance properties do not involve changes in data binding information, the corresponding renderer is called according to the updated component instance properties, and only the target component instance is re-rendered; When the updated component instance properties involve changes in data binding information, the field values ​​of the corresponding business fields are retrieved from the preview data based on the field paths recorded in the updated data binding information. The corresponding renderer is then called based on the retrieved field values ​​to re-render only the target component instance, thereby updating the print template preview. Changes in position, size, font, or color attributes are considered changes that do not involve data binding information, while changes in field paths, table data sources, barcode data sources, or image data sources are considered changes that do involve data binding information.

7. The modeling method for generating printing templates based on different types of components according to claim 1, characterized in that, The step of generating a print template model including each component instance based on the configuration information of the print canvas and the component instance attributes of each component instance includes: Based on the composition relationship and parent-child hierarchy relationship between component instances, a component tree is built with each component instance as a node; In response to the template saving operation, the configuration information of the print canvas, the component tree, the type of each component instance, and the component instance attributes of each component instance are organized into the print template model according to a unified template data structure; wherein, the component instance attributes include position, size, style, and display hierarchy order; for component instances with data binding relationships, the component instance attributes also include the field path of the corresponding business field; The printed template model is serialized and stored.

8. The modeling method for generating printing templates based on different types of components according to claim 7, characterized in that, The step of establishing a component tree with each component instance as a node based on the composition relationship and parent-child hierarchy relationship between component instances includes: For a component instance corresponding to a table component or a composite component instance formed by combining multiple component instances, the component instance corresponding to the table component or the composite component instance is determined as the parent component instance, and the component instances contained in the parent component instance are determined as child component instances. Based on the parent-child hierarchy relationship between the parent component instance and each child component instance, the node corresponding to the parent component instance is taken as the parent node, and the node corresponding to each child component instance is taken as the child node of the parent node. The relative coordinates of the corresponding child component instance relative to the parent component instance are recorded in the child node corresponding to each child component instance to establish the component tree.

9. The modeling method for generating printing templates based on different types of components according to claim 8, characterized in that, The method further includes: In response to the movement operation of the parent component instance, the position of each child component instance after movement is determined according to the position of the parent component instance after movement and the relative coordinates of each child component instance relative to the parent component instance. The position of each child component instance after movement is written into the position attribute of the corresponding child component instance to keep the relative position of each child component instance relative to the parent component instance unchanged before and after the parent component instance is moved.

10. The modeling method for generating printing templates based on different types of components according to claim 1, characterized in that, The component information also includes component rendering information, which is used to determine the renderer corresponding to each type of component. The method further includes: During runtime printing, the print template model and current business data are loaded. The printing template model is parsed to obtain the configuration information of the printing canvas, each component instance, and the component instance attributes of each component instance; Iterate through each component instance. For component instances with data binding relationships, retrieve the field value of the corresponding business field from the current business data based on the field path recorded in the component instance attribute of the component instance. The corresponding renderer is called based on the component rendering information of the component corresponding to each component instance, and each component instance is rendered based on the component instance properties and the field values ​​obtained for component instances with data binding relationships. Based on the position, size, and display hierarchy order of each component instance in its component instance properties, the rendering results of each component instance are combined into the page area determined according to the configuration information of the print canvas to generate the final print output.

11. The modeling method for generating printing templates based on different types of components according to claim 1, characterized in that, The method further includes: Obtain a component copy request for the target print template, wherein the component copy request is used to specify the source document, the source print template, and one or more source component instances to be copied; Read the source component instances to be copied from the source print template, and parse the source component instances into a copyable component model. The copyable component model includes the type of the component corresponding to each source component instance, component instance attributes, parent-child hierarchy relationship, relative coordinates, display hierarchy order, resource references and data binding information. In the target printing template, target component instances corresponding to each source component instance are generated according to the type of the component corresponding to each source component instance, and the component instance attributes and resource references of each target component instance are set according to the reproducible component model; When the source component instance to be copied includes multiple component instances with a parent-child hierarchy, the corresponding parent-child hierarchy and relative position relationship between each target component instance are reconstructed according to the reproducible component model. For each source component instance with data binding information, the corresponding data binding information in the reproducible component model is used as the initial data binding information of the corresponding target component instance; in response to a data binding operation on any target component instance with initial data binding information, the source field path in the initial data binding information of the target component instance is replaced with the field path of the business field selected from the external business data source corresponding to the target print template; Each target component instance is added to the printing canvas of the target printing template, and a printing template model corresponding to the target printing template is generated based on the configuration information of the printing canvas of the target printing template, the component instance attributes of each component instance in the target printing template, and the parent-child hierarchy and relative position relationship between each component instance in the target printing template.

12. A modeling apparatus for generating print templates based on different types of components, characterized in that, include: The component library acquisition unit is used to acquire a preset component library, which contains multiple types of components and stores component information corresponding to each type of component. The multiple types of components include text components, field components, barcode components, line segment components, image components, and table components. The component information includes component attribute information. The component instance generation unit is used to generate a corresponding component instance in the printing canvas in response to the operation of adding a component selected from the component library to the printing canvas, based on the component attribute information corresponding to the selected component. The instance property update unit is used to update the component instance properties of the corresponding component instance in response to a layout adjustment operation of the component instance in the printed canvas or a property setting operation of the component instance. The data binding unit is used to respond to the data binding operation on the component instance by writing the field path of the business field selected from the external business data source to the component instance property of the corresponding component instance to record the data binding information of the corresponding component instance. The template model generation unit is used to generate a print template model including each component instance based on the configuration information of the print canvas and the component instance attributes of each component instance.

13. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 11.

14. A computer-readable storage medium having a computer program / instructions stored thereon, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method according to any one of claims 1 to 11.

15. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method according to any one of claims 1 to 11.