A method and related apparatus for rendering layout documents

By parsing the layout document structure in a non-native rendering environment, allocating depth index ranges and merging order, the problems of abnormal display of layer overlay and template fusion were solved, achieving high-fidelity rendering of layout documents and improving the accuracy and reliability of cross-platform rendering.

CN123115552APending Publication Date: 2026-11-17BEIJING SURSEN ELECTRONIC TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611346468.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-01
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

In environments lacking native layout document rendering engines, existing technologies cannot effectively manage the layer stacking order of layout documents and the occlusion relationship between template content and body text content, resulting in display abnormalities, especially when rendering across platforms, failing to faithfully reproduce the visual effects of the document.

Method used

By analyzing the page structure of the layout document, identifying layers and templates, assigning non-overlapping depth index intervals, and determining the merging order based on the stacking order attribute, the drawing objects are accurately rendered to the corresponding layer containers. Combined with font mapping and dynamic injection rules, high-fidelity rendering is achieved.

Benefits of technology

It resolves issues related to layer overlay misalignment and template fusion display abnormalities, improves the accuracy and reliability of cross-platform rendering, and ensures high-fidelity display of layout documents in non-native environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123115552A_ABST
    Figure CN123115552A_ABST
Patent Text Reader

Abstract

This application discloses a rendering method and related apparatus for layout documents, relating to the field of document processing. By analyzing the page structure and template reference relationships, it assigns non-overlapping depth index intervals to drawing objects within each preset layer, fundamentally avoiding overlay errors caused by depth conflicts between objects within layers. Simultaneously, it determines the merging order based on the relative relationship between the stacking order attributes of the template and the target page, ensuring the correct hierarchical logic of the template and page content during fusion rendering and resolving display anomalies caused by inconsistent stacking contexts. Finally, rendering is performed by combining depth indexes and merging order, ensuring that each drawing object accurately falls into its corresponding layer container. This guarantees the display consistency of layer overlay and template fusion in non-native rendering environments, improving the accuracy and reliability of cross-platform rendering.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of document processing technology, and in particular to a method and apparatus for rendering layout documents. Background Technology

[0002] Layout-based documents, as a fixed-layout electronic document format, are widely used in fields such as electronic documents, certificates, and invoices.

[0003] With the increasing demand for cross-platform access, in environments lacking native formatted document rendering engines, such as general web browsers or lightweight readers, directly parsing and rendering formatted documents has become a technological trend.

[0004] However, existing rendering solutions, when handling complex document layouts, typically render the drawn objects in the document in a planar manner according to the parsing order, lacking a unified and in-depth management capability for the macro-layer structure and micro-template nesting relationships within the document. This approach leads to problems such as disordered layer stacking order and incorrect occlusion relationships between template content and body text when rendering documents containing multiple layers, such as background, body, and foreground layers, as well as those referencing template pages, such as watermarks, headers, and footers. Consequently, it fails to faithfully reproduce the original visual effect of the document.

[0005] In summary, existing technologies suffer from issues with the abnormal display of layer overlay and template fusion in non-native rendering environments for formatted documents. Summary of the Invention

[0006] In view of the above problems, this application provides a method and related apparatus for rendering layout documents to achieve high-fidelity rendering of layout documents. The specific solution is as follows:

[0007] The first aspect of this application provides a method for rendering a layout document, including:

[0008] Analyze the page structure of the layout document, identify the multiple preset layers contained in the target page, and the templates referenced by the target page;

[0009] Assign non-overlapping depth index ranges to the drawing objects in each preset layer to obtain the depth index of each drawing object;

[0010] Based on the relative relationship between the stacking order attribute of the template and the stacking order attribute of the target page, determine the merging order of the drawing objects of the template and the drawing objects of the target page;

[0011] Based on depth indexing and merging order, each drawing object is rendered to its corresponding layer container.

[0012] In one possible implementation, non-overlapping depth index ranges are assigned to drawing objects within each preset layer to obtain the depth index of each drawing object, including:

[0013] Based on the layer type of the preset layer, determine the corresponding preset index range, where the preset index ranges corresponding to different layer types do not overlap;

[0014] Calculate the depth index of the object to be drawn based on the object identifier and the preset index range.

[0015] In one possible implementation, based on depth indexing and merging order, each drawing object is rendered to its corresponding layer container, including:

[0016] Build an independent layer container for each preset layer;

[0017] Add the drawing object to the corresponding layer container, and set the stacking style property of the drawing object in the layer container according to the depth index.

[0018] In one possible implementation, the merging order of the template's drawing objects and the target page's drawing objects is determined based on the relative relationship between the template's stacking order attribute and the target page's stacking order attribute, including:

[0019] When the stacking order property of the template meets the first preset condition, the template's drawing object is merged into the lower layer of the target page's drawing object;

[0020] When the stacking order property of the template meets the second preset condition, the template's drawing object is merged into the upper layer of the target page's drawing object.

[0021] In one possible implementation, the method also includes:

[0022] If a template references a child template, the content of the child template is loaded recursively.

[0023] After merging the drawing objects of the templates at each level with the drawing objects of the target page, they are uniformly sorted according to the depth index.

[0024] In one possible implementation, the method also includes:

[0025] The font names of text objects are matched based on a pre-defined font mapping table to generate a font fallback list;

[0026] Parse the embedded font files in the layout document, generate font injection rules, and inject them into the current rendering environment.

[0027] In one possible implementation, the embedded font files in the layout document are parsed, font injection rules are generated, and injected into the current rendering environment, including:

[0028] Locate and extract the binary data of the embedded font file from the layout document;

[0029] Convert binary data into string data with a preset encoding format;

[0030] Read the header bytes of the embedded font file and determine the font type identifier of the embedded font file based on the header bytes;

[0031] Based on string data and font type identifier, a cascading style rule is constructed. The cascading style rule includes a font name attribute and a resource location attribute pointing to string data. The resource location attribute includes a data protocol header, a font type identifier, and string data.

[0032] Inject Cascading Style Rules into the document header and monitor font loading status. Once it is confirmed that the embedded font file has been loaded, allow text objects to be rendered using the font fallback list.

[0033] A second aspect of this application provides a rendering apparatus for a layout document, comprising:

[0034] The structure parsing module is used to parse the page structure of a layout document, identify multiple preset layers contained in the target page, and the templates referenced by the target page;

[0035] The index allocation module is used to allocate non-overlapping depth index intervals to drawing objects in each preset layer, thereby obtaining the depth index of each drawing object;

[0036] The template fusion module is used to determine the merging order of the template's drawing objects and the target page's drawing objects based on the relative relationship between the template's stacking order attribute and the target page's stacking order attribute.

[0037] The layered rendering module is used to render each drawing object to its corresponding layer container based on depth indexing and merging order.

[0038] A third aspect of this application provides a rendering device for a layout document, comprising:

[0039] At least one processor; and,

[0040] A memory that is communicatively connected to at least one processor; wherein,

[0041] The memory stores instructions that can be executed by at least one processor to enable at least one processor to implement the rendering method of the layout document of the first aspect or any implementation thereof.

[0042] The fourth aspect of this application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements a method for rendering a layout document according to the first aspect or any implementation thereof.

[0043] By employing the aforementioned technical solutions, the rendering method and related apparatus for layout documents provided in this application, through parsing the page structure and template reference relationships, assigns non-overlapping depth index ranges to drawing objects within each preset layer, fundamentally avoiding overlay errors caused by depth conflicts between objects within layers. Simultaneously, the merging order is determined based on the relative relationship between the stacking order attributes of the template and the target page, ensuring the correct hierarchical logic of the template and page content during fusion rendering and resolving display anomalies caused by inconsistent stacking contexts. Finally, rendering is performed by combining depth indexes and merging order, ensuring that each drawing object accurately falls into its corresponding layer container, guaranteeing the display consistency of layer overlay and template fusion in non-native rendering environments, and improving the accuracy and reliability of cross-platform rendering. Attached Figure Description

[0044] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.

[0045] Figure 1 A flowchart illustrating a method for rendering the layout document provided in this application;

[0046] Figure 2 A system composition example diagram for the rendering method of the layout document provided in this application;

[0047] Figure 3 Example diagram of the data interaction process of the OFD document rendering engine system that implements the above-mentioned layout document rendering method provided in this application;

[0048] Figure 4 The OFD document rendering engine three-stage module interaction architecture diagram for the above-mentioned implementation of the layout document rendering method provided in this application;

[0049] Figure 5 A flowchart illustrating a method for rendering the layout document provided in this application;

[0050] Figure 6 A schematic diagram of the structural composition of the rendering device for the layout document provided in this application. Detailed Implementation

[0051] The embodiments of this application are described below with reference to the accompanying drawings. The terminology used in the implementation section of this application is for explaining specific embodiments only and is not intended to limit the scope of this application.

[0052] As will be known to those skilled in the art, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.

[0053] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.

[0054] When processing layout documents, such as OFD documents, in non-native rendering environments like web browsers, existing technologies typically employ a planar rendering approach. This involves placing all drawing objects within the document into the same rendering context and drawing them sequentially according to the parsing order. However, layout documents, especially OFD documents conforming to the GB / T 33190-2017 standard, have complex structural characteristics: each page is clearly divided into three macro layers: Background, Body, and Foreground, with each layer containing multiple drawing objects. Furthermore, the document supports template pages; for example, watermarks and header / footer templates are referenced by multiple content pages, forming a nested structure.

[0055] In the absence of a unified approach to in-depth management, at least the following specific problems exist:

[0056] Because all objects share the same depth space, and the rendering order is determined by the parsing order rather than the layer semantics defined in the document, background objects that should be at the bottom layer may be incorrectly rendered on top of the main or foreground layer, disrupting the original visual hierarchy of the document and causing a disorder in the layer stacking order.

[0057] When a page references a template, existing technologies lack the ability to parse the template's ZOrder property, making it impossible to recursively load nested templates and determine the relative overlap between template content and page content. This leads to incorrect occlusion relationships, such as watermarks covering the main text and stamps being obscured by text, resulting in abnormal template fusion and display issues.

[0058] Depth index conflict manifests as an issue where objects within different layers are assigned overlapping depth values, causing the rendering engine to be unable to correctly determine their order and further exacerbating display anomalies.

[0059] These problems are particularly prominent in serious scenarios such as electronic documents and electronic certificates, resulting in a serious discrepancy between the displayed document and the original document.

[0060] To address the aforementioned issues, this application provides a method and related apparatus for rendering layout documents.

[0061] See Figure 1 This application provides a flowchart illustrating a method for rendering layout documents.

[0062] This method is suitable for faithfully reproducing the visual effects of complex documents in environments lacking native typographic document rendering engines. For example... Figure 1 As shown, the solution mainly includes the following steps:

[0063] Step 101: Analyze the page structure of the layout document, identify the multiple preset layers contained in the target page and the templates referenced by the target page.

[0064] It should be noted that preset layers refer to the macroscopic visual layering structure defined in the layout document standard, such as background layer, main content layer, and foreground layer. These layers usually exist as independent nodes or containers in the document's data structure to distinguish different types of visual elements. Templates, on the other hand, refer to reusable content units referenced by the target page, such as watermark pages, header and footer templates, or signature templates. They are independent of the target page's inherent content in terms of data structure and are only associated with the target page through reference relationships.

[0065] Optionally, the system first extracts the layout information of the target page from the description file of the layout document.

[0066] This step lays the data foundation for subsequent implementation of macro-level layer isolation and micro-level content fusion by clearly distinguishing between preset layers and templates, two different types of data objects, during the parsing phase, thus avoiding rendering logic errors caused by conceptual confusion.

[0067] Step 102: Assign non-overlapping depth index intervals to the drawing objects in each preset layer to obtain the depth index of each drawing object.

[0068] Specifically, for each preset layer identified, the system assigns a unique numerical range as the depth index range based on its layer type.

[0069] For example, a first numerical range can be assigned to the background layer, a second numerical range to the subject layer, and a third numerical range to the foreground layer, and these three ranges are strictly separated on the number axis and do not overlap with each other.

[0070] Subsequently, the local identifiers or numbers of each drawn object within its respective layer are mapped to this dedicated range, generating a globally unique depth index.

[0071] This depth index allocation method based on interval isolation establishes the absolute hierarchical relationship between macro layers from a mathematical perspective. This allows drawing objects belonging to different preset layers to be automatically assigned to the correct macro layer based solely on the size of their depth index during global sorting. This eliminates the need to repeatedly query the layer affiliation of objects during the rendering loop, ensuring the strict correctness of the layer stacking order while significantly reducing the computational overhead during rendering.

[0072] Step 103: Based on the relative relationship between the stacking order attribute of the template and the stacking order attribute of the target page, determine the merging order of the drawing objects of the template and the drawing objects of the target page.

[0073] Specifically, for the template referenced by the target page, the system reads the stacking order attribute value in the template definition and the stacking order attribute value of the target page itself, and determines the vertical position of the template content relative to the page content by comparing the magnitude of the two values ​​or satisfying preset conditions.

[0074] For example, when the template's stacking order attribute indicates that it should be at the bottom, the system merges the sequence of drawable objects contained in the template before the sequence of drawable objects on the target page; conversely, if it indicates that it should be at the top, it merges it after.

[0075] This approach solves the display anomaly caused by the traditional solution where template content can only be added to the page content in a fixed manner. It can accurately meet diverse micro-overlay requirements, such as background watermarks needing to be displayed at the bottom and electronic signatures needing to float above the main text, and achieves flexible and dynamic integration of template content and page content in the vertical direction.

[0076] It should be noted that the order of steps 102 and 103 can be reversed or performed simultaneously.

[0077] Step 104: Based on depth indexing and merging order, render each drawing object to its corresponding layer container.

[0078] Specifically, the system integrates template drawing objects and page drawing objects into a unified queue to be rendered according to the merging order determined in the aforementioned steps, and then sorts the queue globally according to the depth index of each object.

[0079] Then, the sorted queue is traversed, each drawing object is added to the layer container corresponding to its preset layer, and its stacking style properties within the layer container are set according to the object's depth index.

[0080] It is understandable that the layer container here is a logical or physical carrier used in the rendering environment to hold elements of the same macro level, while the cascading style properties are parameters natively supported by the rendering environment to control the occlusion relationship of elements.

[0081] In this way, this embodiment accurately maps the abstract logical sorting result into physical rendering instructions that can be executed by the rendering environment, ensuring that the final output page can strictly reproduce the original visual effect defined by the layout document in both the macro-layer isolation and micro-template fusion dimensions.

[0082] In summary, the rendering method for layout documents provided in this application, by analyzing the page structure and template reference relationships, assigns non-overlapping depth index ranges to drawing objects within each preset layer, fundamentally avoiding overlay errors caused by depth conflicts between objects within layers. Simultaneously, by determining the merging order based on the relative relationship between the stacking order attributes of the template and the target page, it ensures the correct hierarchical logic of the template and page content during fusion rendering, resolving display anomalies caused by inconsistent stacking contexts. Finally, by combining depth indexing and merging order for rendering, each drawing object accurately falls into its corresponding layer container, guaranteeing the display consistency of layer overlay and template fusion in non-native rendering environments, and improving the accuracy and reliability of cross-platform rendering.

[0083] For example, see Figure 2 The system composition example diagram for the implementation of the rendering method for layout documents provided in this application is shown.

[0084] This diagram is a sample of the OFD document rendering engine system components that implement the layout document rendering method.

[0085] As shown in the figure, the entire engine is based on OFD ZIP parsing (input source), receives the parsed document data, and works together through eight internal functional modules to finally output a high-fidelity page rendering result.

[0086] The page box calculation module is responsible for converting OFD page dimensions from millimeters to pixels precisely and calculating the scaling ratio to adapt to different screen displays; the layer separation rendering module constructs independent DOM containers to control the stacking order by assigning non-overlapping fixed Z-axis index intervals to the Background, Body, and Foreground layers; and the template fusion module recursively loads nested templates referenced by the page and determines the merging order of the templates and the main content based on the ZOrder property.

[0087] In addition, the color space conversion module converts CMYK or Gray colors to the Web-supported RGB format; the font mapping module works with the font dynamic loading module to solve the problems of font name variations and embedded font rendering by using a pre-defined mapping table and dynamically injecting @font-face rules; the hybrid rendering engine module intelligently selects SVG or Canvas for drawing based on the object type; and finally, the rendering output module integrates the processing results of each module, applies page size and rotation information, and generates a complete OFD page DOM structure.

[0088] For example, see Figure 3 This is an example diagram of the data interaction process of the OFD document rendering engine system that implements the above-mentioned layout document rendering method provided in this application.

[0089] like Figure 3 As shown, after parsing the OFD document, the ZIP parsing module outputs the page size to the page box calculation module and the font file to the font dynamic loading module. After calculating the scaling ratio, the page box calculation module passes the page box information to the layer separation rendering module. After loading the embedded font, the font dynamic loading module passes the font name to the font mapping module to generate the font-family. At the same time, the layer separation rendering module assigns the Z-axis index and passes it to the template fusion module. The template fusion module recursively loads templates and merges the drawing object list before outputting it to the color space conversion module to generate RGB colors. Finally, the font mapping module and the color space conversion module converge the relevant attributes to the hybrid rendering engine module. After rendering and generating DOM elements, this module passes them to the rendering output module, thereby integrating and generating the final DOM output.

[0090] For example, see Figure 4 The diagram below shows the three-stage module interaction architecture of the OFD document rendering engine for the above-mentioned implementation of the layout document rendering method provided in this application.

[0091] like Figure 4 As shown, the entire rendering process is divided into three logical stages from top to bottom: Stage I: resource and data parsing; Stage II: layout calculation and visual transformation; and Stage III: rendering, compositing, and output.

[0092] In Phase I, the OFD ZIP parser processes the raw resources and passes the calculation parameters to the page box / coordinate calculation module in Phase II, while simultaneously triggering dynamic font loading and font semantic mapping. Phase II also performs color space conversion (ICC) in parallel. Subsequently, the font semantic mapping results from Phase I and the calculation and conversion results from Phase II are combined into Phase III, where they are sequentially rendered through layer separation and the template fusion engine for object merging and sorting. Finally, the compositing queue is input to the hybrid rendering engine (Core) for drawing, achieving full-process control from resource parsing to high-fidelity rendering output.

[0093] Based on the first embodiment described above, this embodiment further details the specific implementation method of macroscopic layer depth isolation as a second embodiment.

[0094] As one implementation method, non-overlapping depth index intervals are assigned to drawing objects within each preset layer to obtain the depth index of each drawing object, including:

[0095] Based on the layer type of the preset layer, determine the corresponding preset index range, where the preset index ranges corresponding to different layer types do not overlap; calculate the depth index of the drawing object based on the object identifier of the drawing object and the preset index range.

[0096] Specifically, when parsing the page structure of a layout document, the system will identify the layer type of each preset layer, such as background type, main content type, or foreground type.

[0097] For each layer type, the system pre-configures a unique numerical range as the preset index range for that type. To ensure absolute isolation between macro-level layers, these preset index ranges are strictly separated on the numerical axis.

[0098] For example, a first numerical range can be assigned to the background type, a second numerical range to the main content type, and a third numerical range to the foreground type. A certain buffer interval can be reserved between two adjacent numerical ranges, or a sufficiently large span can be set to ensure that numerical overlap does not occur even if the number of objects reaches the theoretical limit.

[0099] After determining the preset index range, the system uses the object identifier of the drawing object within its own layer, such as the object ID or parsing number, as the offset and superimposes it onto the base index value corresponding to the layer type, thereby calculating the global depth index of the drawing object.

[0100] This dual-binding calculation logic, which defines the range of layer types and the position of object identifiers, mathematically ensures that drawing objects belonging to different macro layers have naturally distinguishable depth index value ranges.

[0101] The technical effect is that when the rendering engine performs global sorting, it only needs to compare the numerical values ​​of the depth index to automatically complete the placement and layering of macro layers. There is no need to repeatedly query or judge the layer belonging attributes of objects during the sorting process. This not only completely eliminates cross-layer rendering errors caused by object ID conflicts or differences in parsing timing, but also significantly reduces the time complexity of the sorting algorithm and improves the rendering performance of large documents.

[0102] Furthermore, as one implementation method, based on depth indexing and merging order, each drawing object is rendered to its corresponding layer container, including:

[0103] Build an independent layer container for each preset layer; add the drawing objects to the corresponding layer container, and set the stacking style properties of the drawing objects in the layer container according to the depth index.

[0104] Specifically, after completing the calculation of the depth index and global sorting, the system enters the physical rendering mapping stage.

[0105] First, the system creates an independent layer container for each preset layer. This container is the logical or physical carrier in the rendering environment used to hold all visual elements at the same macro level.

[0106] Subsequently, the system adds each drawing object to its corresponding layer container according to its preset layer.

[0107] The key is that for each drawing object within the container, the system sets the stacking style properties of that object within the container based on its previously calculated depth index.

[0108] It should be noted that the cascading style property in this application is a higher-level concept, referring to the parameters or instructions natively supported by the current rendering environment for controlling the occlusion relationship of elements in the direction perpendicular to the screen.

[0109] In a web browser environment, this property may manifest as a hierarchical control parameter in a CSS stylesheet; while in native applications, desktop clients, or other custom graphics rendering engines, this property may manifest as a drawing order parameter in a drawing API, the priority weight of scene graph nodes, or the writing order of the video memory buffer.

[0110] Therefore, this cascading style attribute should not be understood as being limited to implementation methods specific to certain front-end technologies. By accurately translating the abstract logical depth index into native cascading style attributes recognizable by the rendering environment, this embodiment achieves a lossless mapping from document data structure to the final visual presentation. This ensures that within the same macro layer, each drawn object can be stacked and displayed strictly according to the micro-order defined in the document, thereby guaranteeing the accuracy of high-fidelity reproduction of the layout document.

[0111] Based on the first embodiment, this embodiment further details the specific implementation of micro-template fusion sorting as the third embodiment.

[0112] As one implementation method, the merging order of the template's drawing objects and the target page's drawing objects is determined based on the relative relationship between the template's stacking order attribute and the target page's stacking order attribute, including:

[0113] When the template's stacking order property meets the first preset condition, the template's drawing object is merged into the lower layer of the target page's drawing object; when the template's stacking order property meets the second preset condition, the template's drawing object is merged into the upper layer of the target page's drawing object.

[0114] Specifically, the system reads the stacking order attribute values ​​from the template definition data and the target page's own stacking order attribute values. The stacking order attribute here is a parameter used in layout document standards to define the vertical stacking order of elements, such as the ZOrder value.

[0115] The first preset condition usually refers to the template's stacking order attribute value being less than the target page's stacking order attribute value, or the template being explicitly marked as a background type. In this case, the system determines that the template content should be used as the background of the page. Therefore, when building the rendering queue, all the drawing objects contained in the template are inserted in front of the target page's drawing object sequence, so that it is visually located below the page content.

[0116] Conversely, the second preset condition usually refers to the template's stacking order attribute value being greater than or equal to the target page's stacking order attribute value, or the template being explicitly marked as a foreground type; in this case, the system appends the template drawing object to the end of the page drawing object sequence, making it visually overlay on the page content.

[0117] This dynamic determination method based on attribute comparison overcomes the limitation of traditional rendering schemes where template content can only be fixedly added before or after the page content. For example, when processing electronic documents, watermark templates need to be displayed at the bottom to avoid obscuring the main text, while electronic signature templates need to float above the main text to ensure legal validity. This embodiment, through the above-mentioned dynamic merging logic, enables the same rendering engine to accurately adapt to these two diametrically opposed overlay requirements, achieving flexible and precise vertical integration of template content and page content.

[0118] Furthermore, as one implementation method, if a template references a sub-template, the content of the sub-template is loaded recursively; after merging the drawing objects of each level of templates with the drawing objects of the target page, they are uniformly sorted according to the depth index.

[0119] Specifically, layout documents often contain complex template nesting structures. For example, a page template might reference a header template, which in turn might reference a company logo template. To address this, the system employs a recursive loading strategy: when it detects that the current template references a child template, it pauses the merging operation of the current template and prioritizes further parsing and loading all the content of the child template; once the child template is loaded, its content is back-merged into the parent template, until the content of all nested levels of templates has been fully extracted.

[0120] The key is that after completing the recursive loading of all levels and merging the drawing objects of each level template with the drawing objects of the target page into a total set to be rendered, the system does not simply maintain the original order within each template or arrange them according to the loading order. Instead, it must treat all drawing objects in the set as a whole and reorder them uniformly according to the global depth index determined in the aforementioned embodiment.

[0121] This is because templates at different levels may belong to different macro layers. For example, a child template belongs to the background layer and a parent template belongs to the foreground layer. If only local order is maintained, it is very easy to cause errors in cross-layer occlusion relationships.

[0122] By using a unified sorting method, regardless of how many layers of template nesting there are, all drawn objects will eventually be automatically placed into the correct global visual layer based on the depth index range corresponding to their respective macro layer and their own offset within the layer.

[0123] For example, even if a deeply nested logo template is wrapped in multiple upper-level templates in the data structure, as long as its depth index indicates that it belongs to the foreground layer, it can be correctly displayed above all background and main content after unified sorting. This completely solves the common problem of lost or misaligned levels in complex nested documents and ensures the accuracy of high-fidelity rendering.

[0124] Based on the first embodiment, this embodiment further details the dual font processing and dynamic injection method in the layout document rendering process, as the fourth embodiment.

[0125] As one implementation method, the method further includes:

[0126] The font names of text objects are matched based on a pre-defined font mapping table to generate a font fallback list; embedded font files in the layout document are parsed to generate font injection rules and inject them into the current rendering environment.

[0127] Specifically, font names defined in layout documents often have multiple variations. For example, the same font may have multiple expressions such as full name, abbreviation, name with character set suffix, or historical name. Furthermore, different rendering environments or operating systems do not have a unified standard for recognizing font names.

[0128] To address this compatibility issue, the system maintains a pre-defined font mapping table, which records the correspondence between various name variants of commonly used fonts in layout documents and their available font names in the current rendering environment.

[0129] When the font name attribute of a text object is parsed, the system first performs an exact match or a fuzzy match in the mapping table. If a match is successful, a font fallback list containing multiple candidate font names is generated in order of priority. If no specific font is matched, the original name is combined with the general font family name to generate a fallback list.

[0130] This approach ensures that even if a specific font is missing in the rendering environment, the visually closest alternative font can be found through the fallback list, avoiding layout errors.

[0131] At the same time, for the special font files embedded in the layout document, the system does not simply use them as static resources, but dynamically parses and generates font injection rules that conform to the current rendering environment specifications.

[0132] The font injection rule here is a higher-level concept, referring to any declarative configuration or set of instructions that enables the rendering environment to recognize and use font data in memory. Its specific form depends on the type of rendering environment. For example, in a web browser environment, it may be manifested as specific style sheet rules, while in a native graphics engine, it may be manifested as font registration API call parameters or resource descriptors.

[0133] Through the dual collaboration of font mapping and dynamic injection, this embodiment not only solves the matching problem of inconsistent font names across platforms, but also makes up for the lack of local font library in the rendering environment, providing complete font resource guarantee for high-fidelity rendering.

[0134] Furthermore, as one implementation method, the embedded font files in the layout document are parsed, font injection rules are generated and injected into the current rendering environment, including the following steps.

[0135] First, locate and extract the binary data of the embedded font file from the layout document.

[0136] Specifically, when parsing the document resource package, the system locates the embedded font file based on the path index in the resource description file and reads its raw binary stream into memory.

[0137] Then, the binary data is converted into string data in a preset encoding format.

[0138] Since most rendering environments' resource loading interfaces expect to receive text-formatted input rather than raw byte streams, binary data needs to be converted into a secure text encoding format, such as Base64 encoding or other custom secure transmission encoding, to ensure that font data is not truncated or corrupted by special characters during transmission.

[0139] Next, the header bytes of the embedded font file are read, and the font type identifier of the embedded font file is determined based on the header bytes.

[0140] Specifically, different types of font files have specific magic numbers or file header signatures. For example, TrueType fonts usually start with a specific four-byte sequence, while WOFF fonts are identified by another specific set of bytes.

[0141] The system can automatically identify the specific format type of a font file by reading a few bytes from the beginning of the file and comparing them with a known signature, without relying on unreliable external metadata such as file extensions.

[0142] This step is crucial for properly handling documents with mixed format embeddings.

[0143] Based on this, cascading style rules are constructed using string data and font type identifiers.

[0144] This cascading style rule includes at least the font name attribute and a resource location attribute that points to string data.

[0145] The structural design of the resource location attribute is the key to this embodiment. It includes the data protocol header, font type identifier, and the aforementioned converted string data.

[0146] The data header informs the rendering environment that the source of subsequent data is inline data rather than a network address; the font type identifier indicates to the rendering engine which decoder to use to parse the subsequent data; and the string data is the actual payload of the font file.

[0147] This self-contained resource location attribute structure allows the rendering environment to directly obtain complete font resources from the rules without initiating additional asynchronous network requests, thus achieving instant availability of font resources.

[0148] Finally, the constructed cascading style rules are injected into the document header, and the font loading status is monitored. Once it is confirmed that the embedded font file has been loaded, text objects are allowed to be rendered using the font fallback list.

[0149] Specifically, the system inserts the generated rules into the configuration area or style context of the rendering environment, and tracks the parsing and readiness status of the font through the state listener provided by the rendering environment. Only when the system confirms that the embedded font has been successfully loaded and is available for use will the text object drawing process be triggered, and the font name just injected in the fallback list will be used first.

[0150] This synchronous waiting method effectively avoids text flickering or temporary revert to the default font due to the font not being fully loaded, ensuring the final presentation is consistent with the original design of the layout document.

[0151] It is understandable that although the above process describes the complete chain from binary extraction to rule injection, in actual implementation, the execution order of each step can be adjusted according to the characteristics of the rendering environment. For example, in some rendering environments that support direct binary input, the encoding conversion step can be omitted, and the binary data can be directly encapsulated as resource location attributes. These variations are all within the scope of protection of this application.

[0152] For example, see Figure 5 This application provides a flowchart illustrating a method for rendering layout documents.

[0153] This diagram illustrates the complete process of processing OFD documents in a non-native rendering engine within a client-side browser.

[0154] The entire process is clearly divided into three logical layers from top to bottom: the data parsing layer, the resource calculation layer, and the rendering output layer. Each layer contains continuous execution steps, which ultimately transform the OFD ZIP input source into a high-fidelity page rendering result.

[0155] The process begins at the data parsing layer.

[0156] S1: Load the OFD ZIP package, use the ZIP parsing library to decompress the document, read the OFD.xml entry file and resource files such as Document.xml, complete the basic parsing, and provide data support for subsequent operations.

[0157] Then it enters the resource computing layer.

[0158] S2: Parse the page structure and identify the Background, Body, Foreground layers and various drawing objects on the page;

[0159] Then S3 and S4 are executed in parallel.

[0160] S3: Next, page box calculations are performed in parallel to complete the precise conversion and scaling from millimeters to pixels;

[0161] S4: Dynamic font loading to inject embedded fonts into the browser environment;

[0162] S6: Then combine the two results and perform color space conversion to uniformly convert CMYK or Gray to the Web-supported RGB format.

[0163] The process then proceeds to the rendering output layer.

[0164] S5: First, perform template merging processing, recursively load multi-level nested templates, and determine the merging order of templates and page content based on the ZOrder property;

[0165] S7: Next, perform Z-axis index assignment, assign non-overlapping fixed Z-axis index intervals to the drawing objects in each layer and sort them;

[0166] S8: Then perform hybrid rendering, intelligently selecting either Canvas or SVG engine for drawing based on the object type;

[0167] S9: Finally, through the rendering output step, the results of each module are integrated and page transformations are applied to output the complete OFD page DOM structure, which effectively solves the problems of chaotic layer overlay and abnormal template fusion in non-native environments.

[0168] To more clearly illustrate the application effect of the technical solution of this application in actual business scenarios, this embodiment takes rendering OFD format electronic documents containing official seals, watermarks and special fonts in a web browser environment as an example for specific explanation.

[0169] It is understood that this embodiment is only a specific application example of the technical solution of this application, and the specific values, front-end technical terms and specific file formats involved are intended to assist in understanding and do not constitute a limitation on the protection scope of the foregoing superior embodiment.

[0170] In this application scenario, a user accesses an electronic document conforming to the GB / T 33190-2017 standard via a web browser. The document has a complex page structure, containing three preset layers: a background layer, a body layer, and a foreground layer. It also references a watermark template page and embeds a Founder Xiaobiao Song font file specifically for official documents. The system performs the following rendering process for this document.

[0171] First, regarding the depth isolation of macro layers, the system concretizes the non-overlapping depth index intervals abstracted in the aforementioned embodiments into three fixed numerical segments.

[0172] Specifically, a depth index range with a base value of 2,000,000 is assigned to the drawing objects in the background layer, meaning the depth index of a background object equals 2,000,000 plus the object's ID; a depth index range with a base value of 4,400,000 is assigned to the main content layer, meaning the depth index of a main content object equals 4,400,000 plus the object ID; and a depth index range with a base value of 6,700,000 is assigned to the foreground layer, meaning the depth index of a foreground object equals 6,700,000 plus the object ID.

[0173] This numerical allocation method preserves an index buffer space of over 2 million between layers, so that even if the number of objects in a single layer reaches millions, there will be no cross-layer index overlap.

[0174] During actual rendering, the browser engine only needs to compare these integer-type depth index values ​​to automatically place the background watermark at the bottom layer, the main text content in the middle layer, and the red official seal at the top layer, completely avoiding display errors such as the official seal being obscured by the main text or the watermark covering the text caused by the uncertain parsing order in traditional solutions.

[0175] Secondly, regarding micro-template fusion and font processing, when the system parses the watermark template referenced on the page, it reads its stacking order attribute value. If this attribute value is less than the stacking order attribute value of the main page content, the system automatically merges all drawn objects in the watermark template to the front of the main page object sequence, ensuring that the watermark is visually positioned below the main text.

[0176] For the Founder Xiaobiao Song font used in the official document title, the system first queries the preset font mapping table and attempts to match it with a common font such as SimSun or serif as a fallback option. At the same time, the system extracts the embedded Founder Xiaobiao Song font binary data from the OFD document package, converts it into a Base64 encoded string, and dynamically injects it into the browser environment by constructing a cascading style rule containing the data:font / truetype;base64 protocol header.

[0177] This dual approach ensures that even on terminal devices without the dedicated font installed, the document title is accurately presented with the original font design, guaranteeing the seriousness and legal validity of electronic documents.

[0178] Furthermore, at the graphics rendering level, the system employs a hybrid rendering strategy to balance display quality and rendering performance.

[0179] Specifically, for both vector path objects and text objects, the system uniformly adopts SVG rendering, utilizing its lossless scaling characteristics to ensure sharp and clear text edges and complete details of the official seal pattern.

[0180] For image objects, the system calculates the total number of pixels, specifically the width multiplied by the height. When the number of pixels is greater than 1 million, it is determined to be a large-size image and uses Canvas bitmap rendering to avoid DOM tree expansion and reflow overhead caused by a large number of SVG nodes. When the number of pixels is less than or equal to 1 million, it still uses SVG image element rendering to maintain vector characteristics.

[0181] This adaptive routing method based on object type and size allows the system to significantly reduce browser memory usage and rendering latency while ensuring high-fidelity visual effects.

[0182] Actual testing has verified that when the technical solution of this application is used to render the above-mentioned OFD electronic documents, the layer overlay order accuracy reaches 100% in various mainstream web browsers and screens with different resolutions, the font rendering achieves 100% visual consistency with the original document, and compared with the pure Canvas rendering solution, the overall rendering performance is improved by about 70%, and the first screen loading time is shortened to less than a second.

[0183] These data fully demonstrate that this application can effectively balance the dual requirements of high-fidelity reproduction and high-performance rendering when dealing with complex layout documents.

[0184] It should be emphasized again that the specific index bases such as 2,000,000, 4,400,000, and 6,700,000 mentioned in this embodiment, as well as the specific technical implementation methods such as Base64, SVG, and Canvas, are only preferred examples adapted to the web browser environment.

[0185] In other implementations, the depth index range may be other non-overlapping numerical ranges, and the rendering medium may be replaced by native graphics APIs or other custom drawing engines. As long as they follow the core concept of macro-layer isolation and micro-template fusion established in this application, they shall be considered to fall within the protection scope of this application.

[0186] See Figure 6 This application provides a schematic diagram of the structural composition of the rendering device for the formatted document.

[0187] This device, based on the same inventive concept as the aforementioned method embodiments, is used to achieve high-fidelity rendering in environments lacking native formatted document rendering engines. The device includes a structure parsing module 10, an index allocation module 20, a template fusion module 30, and a layered rendering module 40. These modules work collaboratively through clearly defined data interfaces and timing coordination to jointly complete the conversion process from document data to visual presentation.

[0188] The structure parsing module 10 is used to parse the page structure of the layout document and identify the multiple preset layers contained in the target page and the templates referenced by the target page.

[0189] Specifically, the structure parsing module 10 serves as the data entry point for the entire rendering device, receiving the raw resource stream provided by the underlying file parser.

[0190] This module first reads the description file of the layout document and extracts the layout definition information of the target page from it.

[0191] During the processing, the structure parsing module 10 not only extracts the regular drawing object data, but also performs a special separation and recognition of macro and micro structures: on the one hand, it marks the background layer, main body layer, foreground layer and other preset layers as independent logical nodes; on the other hand, it parses the template reference identifier in the page attributes and establishes the association between the target page and external template resources.

[0192] This separation and identification method ensures that subsequent processing units can clearly distinguish which content belongs to the inherent hierarchical structure of the page and which content belongs to additional elements that need to be dynamically integrated, thus providing an accurate data foundation for macro-level isolation and micro-level integration.

[0193] The structure parsing module 10 outputs the identified layer type information, object list and template reference relationship to the index allocation module 20 and the template fusion module 30 respectively, as the starting input for subsequent processing.

[0194] The index allocation module 20 is used to allocate non-overlapping depth index intervals to drawing objects in each preset layer, thereby obtaining the depth index of each drawing object.

[0195] Specifically, the index allocation module 20 receives layer information and an object list from the structure parsing module 10.

[0196] For each drawing object, this module queries a preset range mapping table to determine the corresponding numerical range based on the type of the preset layer to which it belongs, and calculates a globally unique depth index by combining the object's own identifier.

[0197] For example, for objects belonging to the background layer, their index values ​​are limited to the first numerical range; for objects belonging to the main layer, their index values ​​are limited to the second numerical range, and the first and second numerical ranges are strictly separated on the number line.

[0198] In this way, the index allocation module 20 transforms discrete drawing objects into an ordered dataset with precise hierarchical coordinates. The list of objects with depth indexes output by this module not only includes the geometric and style attributes of the objects themselves, but also carries key values ​​for global sorting. This eliminates the need for subsequent blending and rendering operations to repeatedly trace back to the original layer affiliation, significantly improving data processing efficiency.

[0199] The template fusion module 30 is used to determine the merging order of the template's drawing objects and the target page's drawing objects based on the relative relationship between the template's stacking order attribute and the target page's stacking order attribute.

[0200] Specifically, the template fusion module 30 is the core unit for solving the visual hierarchy correctness of complex documents.

[0201] This module receives a list of page objects from the index allocation module 20 and template reference information from the structure parsing module 10. When a page references a template, the template fusion module first recursively loads the template content of all nested levels, and assigns the drawing objects in each level of the template a depth index that conforms to the macro-layer range to which they belong.

[0202] Subsequently, the module reads the stacking order attribute value in the template definition and compares it with the stacking order attribute value of the target page: if the first preset condition is met, such as the template attribute value being less than the page attribute value, the template object sequence is inserted before the page object sequence; if the second preset condition is met, it is appended after the page object sequence.

[0203] After the initial merging is completed, the template fusion module performs a unified global sort on the integrated full list of objects to ensure that objects, whether they originate from the page itself or are deeply nested templates, are strictly arranged according to the size of the depth index.

[0204] Ultimately, the module outputs a fully ordered queue of objects to be rendered, completely eliminating the occlusion disorder caused by different data sources or nesting levels.

[0205] The layered rendering module 40 is used to render each drawing object to its corresponding layer container based on depth indexing and merging order.

[0206] Specifically, the layered rendering module 40, as the output of the device, receives an ordered object queue from the template fusion module 30.

[0207] This module iterates through each drawing object in the queue, adding it to the pre-built corresponding layer container based on the macro-layer affiliation indicated by its depth index. Simultaneously, the layered rendering module converts the object's depth index into a stacking style property recognizable by the current rendering environment and applies it to the object.

[0208] The layer container here can be an independent node in the rendering tree, an independent buffer in the graphics context, or an independent group in a custom scene graph, depending on the characteristics of the running platform.

[0209] Through this mapping method, the layered rendering module accurately transforms the abstract logical sorting results into a visual stacking effect at the physical level, ensuring that the final output page strictly restores the original design intent of the layout document in both the macro-layer isolation and micro-template fusion dimensions.

[0210] It is understandable that the above division of modules is only a description of logical functions. In actual product implementation, it can be flexibly adjusted according to the characteristics of hardware architecture or software framework.

[0211] For example, in some high-performance implementations, the index allocation module and the template fusion module can be merged into a single pipeline processing unit to reduce memory copy overhead; or in a distributed rendering scenario, the structure parsing module 10 can be deployed independently on the server side, while the other modules run on the client side. As long as the data flow relationships and collaborative logic between the functional units are consistent with the description in this application, they should all be considered to fall within the protection scope of this application.

[0212] Through the modular architecture described above, the embodiments of this application realize a complete mapping from the method flow to the product structure. The close data dependencies and timing coordination between modules ensure the stability and accuracy of the layout document in high-fidelity display in non-native rendering environments.

[0213] This application also provides a rendering device for layout documents.

[0214] The rendering device for this layout document includes at least one processor and memory that is communicatively connected to at least one processor.

[0215] The memory stores instructions that can be executed by at least one processor, which enables the at least one processor to perform a rendering method for a layout document as described in any of the first to fourth embodiments described above.

[0216] Specifically, the processor can be a general-purpose processor, including a central processing unit (CPU) and a network processor, or it can be a digital signal processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The memory can include volatile memory, such as random access memory (RAM), or non-volatile memory, such as flash memory, hard disk drive (HDD), or solid-state drive (SSD).

[0217] The processor and memory can interact via a bus or other interface circuits. When the rendering device for the layout document is running, the processor calls the program code stored in the memory to perform a series of operations, such as parsing the layout document page structure, allocating depth index ranges, determining the template merging order, and performing layered rendering. This supports the complete execution flow of the high-fidelity rendering method at the physical hardware level. This hardware-software integrated architecture ensures that the macro-layer isolation and micro-template fusion defined in the aforementioned method embodiments can run stably on actual terminal devices, providing users with a smooth and accurate document browsing experience.

[0218] This application also provides a computer-readable storage medium.

[0219] A computer program is stored on a computer-readable storage medium, and when executed by a processor, the computer program implements a method for rendering a layout document as described in any one of the first to fourth embodiments.

[0220] Specifically, a computer-readable storage medium can be a tangible, non-transitory storage device. For example, the medium can be an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory, read-only memory, erasable programmable read-only memory, optical fibers, portable compact disk read-only memory, optical storage devices, magnetic storage devices, etc.

[0221] It is understood that the computer-readable storage medium in this application does not include transient signals themselves, such as radio waves or freely propagating light pulses, but covers various physical media capable of persistently storing data and being read and executed when needed. By embedding the program code implementing the layout document rendering method in such media, software distribution, installation, and upgrades can be easily carried out, ensuring that different computing devices can load and run the same technical solution, thereby achieving cross-platform high-fidelity rendering effects and further expanding the application boundaries and protection scope of the technical solution in this application.

[0222] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0223] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.

[0224] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0225] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.

[0226] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).

Claims

1. A method for rendering a layout document, characterized in that, include: The document's page structure is analyzed to identify multiple preset layers contained in the target page and the template referenced by the target page. Assign non-overlapping depth index intervals to the drawing objects within each preset layer to obtain the depth index of each drawing object; Based on the relative relationship between the stacking order attribute of the template and the stacking order attribute of the target page, the merging order of the drawing objects of the template and the drawing objects of the target page is determined; Based on the depth index and the merging order, each drawing object is rendered to its corresponding layer container.

2. The method for rendering a layout document according to claim 1, characterized in that, Assigning non-overlapping depth index intervals to drawing objects within each of the preset layers to obtain the depth index of each drawing object includes: Based on the layer type of the preset layer, the corresponding preset index range is determined, wherein the preset index ranges corresponding to different layer types do not overlap. The depth index of the drawing object is calculated based on the object identifier of the drawing object and the preset index range.

3. The method for rendering a layout document according to claim 2, characterized in that, The step of rendering each drawing object to its corresponding layer container based on the depth index and the merging order includes: Construct an independent layer container for each of the preset layers; The drawing object is added to the corresponding layer container, and the stacking style attribute of the drawing object in the layer container is set according to the depth index.

4. The method for rendering a layout document according to claim 1, characterized in that, The determination of the merging order of the drawing objects of the template and the drawing objects of the target page based on the relative relationship between the stacking order attribute of the template and the stacking order attribute of the target page includes: When the stacking order attribute of the template meets the first preset condition, the drawing object of the template is merged into the lower layer of the drawing object of the target page; When the stacking order attribute of the template meets the second preset condition, the drawing object of the template is merged into the upper layer of the drawing object of the target page.

5. The method for rendering a layout document according to claim 4, characterized in that, The method further includes: If the template references a sub-template, the content of the sub-template is loaded recursively. After merging the drawing objects of the templates at each level with the drawing objects of the target page, they are uniformly sorted according to the depth index.

6. The method for rendering a layout document according to claim 1, characterized in that, The method further includes: The font names of text objects are matched based on a pre-defined font mapping table to generate a font fallback list; The embedded font files in the layout document are parsed to generate font injection rules and inject them into the current rendering environment.

7. The method for rendering a layout document according to claim 6, characterized in that, The process of parsing the embedded font files in the layout document, generating font injection rules, and injecting them into the current rendering environment includes: Locate and extract the binary data of the embedded font file from the layout document; Convert the binary data into string data with a preset encoding format; Read the header bytes of the embedded font file and determine the font type identifier of the embedded font file based on the header bytes; Based on the string data and the font type identifier, a cascading style rule is constructed, wherein the cascading style rule includes a font name attribute and a resource location attribute pointing to the string data, and the resource location attribute includes a data protocol header, the font type identifier, and the string data; The cascading style rules are injected into the document header, and the font loading status is monitored. Once it is confirmed that the embedded font file has been loaded, the text object is allowed to be rendered using the font fallback list.

8. A rendering device for a formatted document, characterized in that, include: The structure parsing module is used to parse the page structure of the layout document, identify the multiple preset layers contained in the target page and the template referenced by the target page; The index allocation module is used to allocate non-overlapping depth index intervals to drawing objects in each of the preset layers, thereby obtaining the depth index of each drawing object; The template fusion module is used to determine the merging order of the drawing objects of the template and the drawing objects of the target page based on the relative relationship between the stacking order attribute of the template and the stacking order attribute of the target page. The layered rendering module is used to render each of the drawing objects to the corresponding layer container based on the depth index and the merging order.

9. A rendering device for a typed document, characterized in that, include: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform a rendering method for a layout document as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the method for rendering a layout document as described in any one of claims 1 to 7.