File processing method and device, computer equipment and storage medium

By parsing and mapping OFD files, high-fidelity PDF files are generated, solving the problem of low conversion efficiency in existing technologies and making it suitable for high-concurrency and batch processing scenarios.

CN121580973APending Publication Date: 2026-02-27CHINA LIFE INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511790887.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-01
Publication Date
2026-02-27

AI Technical Summary

Technical Problem

In existing technologies, converting OFD files to PDF files is inefficient and unsuitable for high-concurrency, batch processing server-side scenarios, especially since virtual printing technology is costly.

Method used

By parsing the OFD file, a document object model is obtained. An intermediate model is then built based on the document object model, and the intermediate model is mapped to generate the target PDF file.

Benefits of technology

It improves the conversion efficiency between OFD and PDF files, making it suitable for high-concurrency and batch processing scenarios. The generated target PDF files have high fidelity, with no errors or damage to the content and layout.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121580973A_ABST
    Figure CN121580973A_ABST
Patent Text Reader

Abstract

The invention relates to a file processing method and device, computer equipment and a storage medium. The method belongs to the technical field of file processing, and comprises the following steps: analyzing an OFD file to obtain a document object model; constructing an intermediate model based on the document object model; and performing mapping processing on the intermediate model to obtain a target portable document format (PDF) file corresponding to the OFD file. According to the method, the OFD file is analyzed to obtain the document object model, then the document object model is converted into the intermediate model, and the intermediate model is accurately mapped to obtain the target PDF file, so that the conversion efficiency between the OFD file and the PDF file is improved, and the method is suitable for high-concurrency and batch processing scenes; and the obtained target PDF file does not have the condition of content or typesetting disorder or damage, so that high-fidelity conversion from the OFD file to the PDF file is realized.
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 document processing method, apparatus, computer equipment, and storage medium. Background Technology

[0002] Currently, OFD (Open Fixed-layout Document) files are mainly used in the fields of electronic documents, electronic invoices, and electronic certificates, while PDF (Portable Document Format) is supported by the vast majority of office software, printing devices, and enterprise workflows.

[0003] Currently, the main way to convert OFD files to PDF files is through virtual printing. However, virtual printing technology incurs significant overhead in launching graphical applications and the printing process, resulting in low efficiency and making it unsuitable for high-concurrency, batch processing server-side scenarios. Summary of the Invention

[0004] Therefore, it is necessary to provide a file processing method, apparatus, computer equipment, and storage medium that can effectively improve file processing efficiency and is suitable for high-concurrency scenarios, addressing the aforementioned technical problems.

[0005] Firstly, this application provides a document processing method. The method includes:

[0006] The OFD file is parsed to obtain the document object model;

[0007] Based on the document object model, construct an intermediate model;

[0008] The intermediate model is mapped to obtain the target PDF file corresponding to the OFD file.

[0009] In one embodiment, the OFD file is parsed to obtain a document object model, including:

[0010] The OFD file is decompressed to obtain the corresponding OFD byte stream;

[0011] Determine the document root directory based on the OFD byte stream;

[0012] Based on the document's root directory, retrieve the list of public resources and page tree information for the document;

[0013] Based on the document public resource list and page tree information, the document object model is determined.

[0014] In one embodiment, determining the document root directory based on the OFD byte stream includes:

[0015] Obtain the boot file based on OFD byte stream;

[0016] Determine the document root directory based on the boot file.

[0017] In one embodiment, the document object model is determined based on the document public resource list and page tree information, including:

[0018] Based on the page tree information and the document public resource list, the resource attribute information of the content objects of each file page is determined; among them, the content objects include text objects, path objects and image objects;

[0019] Based on the resource attribute information of the content objects of each file page, determine the page list, resource dictionary, and page content instruction set;

[0020] Generate a document object model based on the page list, resource dictionary, and page content instruction set.

[0021] In one embodiment, an intermediate model is constructed based on the document object model, including:

[0022] Based on the resource dictionary in the Document Object Model and the page content instruction set of each file page, the content objects of each file page in the Document Object Model are parsed and processed to obtain the parsing results of each file page;

[0023] An intermediate model is obtained based on the parsing results of each file page.

[0024] In one embodiment, the intermediate model is mapped to obtain the target PDF file corresponding to the OFD file, including:

[0025] Obtain the initial PDF file; the initial PDF file contains the same number of pages and page size as the OFD file;

[0026] Based on the intermediate model, the content of the initial PDF file is drawn to obtain the target PDF file corresponding to the OFD file; the content drawing includes text drawing, path drawing and image drawing.

[0027] Secondly, this application also provides a document processing apparatus. The apparatus includes:

[0028] The first processing module is used to parse and process OFD files to obtain document object models;

[0029] The second processing module is used to build an intermediate model based on the document object model;

[0030] The third processing module is used to map the intermediate model to obtain the target PDF file corresponding to the OFD file.

[0031] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps.

[0032] The OFD file is parsed to obtain the document object model;

[0033] Based on the document object model, construct an intermediate model;

[0034] The intermediate model is mapped to obtain the target portable document format PDF file corresponding to the OFD file.

[0035] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:

[0036] The OFD file is parsed to obtain the document object model;

[0037] Based on the document object model, construct an intermediate model;

[0038] The intermediate model is mapped to obtain the target portable document format PDF file corresponding to the OFD file.

[0039] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:

[0040] The OFD file is parsed to obtain the document object model;

[0041] Based on the document object model, construct an intermediate model;

[0042] The intermediate model is mapped to obtain the target portable document format PDF file corresponding to the OFD file.

[0043] The aforementioned file processing method, apparatus, computer equipment, and storage medium parse and process OFD files to obtain a Document Object Model (DOM). An intermediate model is constructed based on the DOM. The intermediate model is then mapped to obtain the target portable document format (PDF) file corresponding to the OFD file. In this application, the OFD file is parsed to obtain a DOM, which is then converted into an intermediate model. This intermediate model is then precisely mapped to obtain the target PDF file. This not only improves the conversion efficiency between OFD and PDF files, making it suitable for high-concurrency and batch processing scenarios, but also ensures that the resulting PDF file does not suffer from content or layout errors or corruption, achieving high-fidelity conversion from OFD to PDF files. Attached Figure Description

[0044] Figure 1 This is a diagram illustrating the application environment of the file processing method provided in this embodiment.

[0045] Figure 2 This is a flowchart illustrating the first file processing method provided in this embodiment;

[0046] Figure 3 This is a flowchart illustrating the process of determining the document object model provided in this embodiment;

[0047] Figure 4 This is a schematic diagram of the process for obtaining the intermediate model provided in this embodiment;

[0048] Figure 5 This is a schematic diagram of the process for obtaining the target PDF file provided in this embodiment;

[0049] Figure 6 This is a flowchart illustrating the second file processing method provided in this embodiment;

[0050] Figure 7 This is a structural block diagram of a file processing device provided in this embodiment;

[0051] Figure 8 This is an internal structural diagram of the computer device provided in this embodiment. Detailed Implementation

[0052] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0053] The file processing method provided in this application can be executed by a terminal device or by a server. That is, the method can be applied to, for example... Figure 1 The application environment shown is illustrated below. Taking a server application as an example, server 104 receives a conversion request for an OFD file from terminal device 102, parses the OFD file to obtain a Document Object Model (DOM). Based on the DOM, the server constructs an intermediate model. The server then performs mapping processing on the intermediate model to obtain the target PDF file corresponding to the OFD file.

[0054] The server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers. The terminal device 102 can be a smart terminal such as a mobile phone or computer.

[0055] In one embodiment, such as Figure 2 As shown, a file processing method is provided, which can be applied to... Figure 1 Let's take the server in the example of this as an illustration. Figure 2 As shown, it includes the following steps:

[0056] S201, parse and process the OFD file to obtain the document object model.

[0057] OFD files are a domestically developed document format, short for Open Fixed-layout Document. In this application, OFD files refer to files that need to be converted to PDF. The Document Object Model (DOM) is a cross-platform, programming language-independent interface (convention) that represents a structured document as a tree structure composed of nodes and objects.

[0058] As an optional implementation of this application, the OFD file is parsed to obtain the internal XML structure of the OFD file, and a document object model is constructed based on the XML structure.

[0059] Another optional implementation of this application involves inputting an OFD file into a first file processing model, which then outputs a document object model. The first file processing model can be a trained neural network model.

[0060] S202, build an intermediate model based on the document object model.

[0061] The intermediate model is a platform-independent, semantically rich intermediate model.

[0062] As an optional implementation of this application, file content information and content attribute information are obtained based on the document object model, and an intermediate model is constructed based on the file content information and content attribute information.

[0063] Another optional implementation of this application involves inputting the document object model into a second document processing model, and then having the second document processing model output an intermediate model. The second document processing model can be a trained neural network model.

[0064] S203, perform mapping processing on the intermediate model to obtain the target PDF file corresponding to the OFD file.

[0065] The target PDF file refers to a PDF file with the same content as the OFD file, that is, a file converted from an OFD file to PDF format.

[0066] Optionally, in this embodiment, the file content contained in the intermediate model is mapped to the initial PDF file to obtain the target PDF file corresponding to the OFD file.

[0067] Optionally, another possible implementation of the file processing method in this embodiment is to optimize the target PDF file and output the corresponding byte stream. The byte stream corresponding to the target PDF file is stored in a file management system, and the storage address is sent to the terminal device so that the terminal device can obtain the byte stream corresponding to the target PDF file based on the storage address. Optionally, another possible implementation of optimizing the target PDF file in this embodiment is to optimize the fonts in the target PDF file so that all fonts in the target PDF file are correctly embedded and subsetted. The optimized target PDF file is then compressed; specifically, the PDF document compression option is enabled, compressing the text and image streams to obtain a compressed target PDF file. The compressed target PDF file is then serialized; specifically, the document saving method is called to write the document object into the byte stream and save it, finally obtaining the byte stream corresponding to the target PDF file.

[0068] The aforementioned file processing method parses the OFD file to obtain a Document Object Model (DOM). An intermediate model is then constructed based on the DOM. The intermediate model is then mapped to obtain the target portable document format (PDF) file corresponding to the OFD file. In this application, the OFD file is parsed to obtain a DOM, which is then converted into an intermediate model. This intermediate model is then precisely mapped to obtain the target PDF file. This not only improves the conversion efficiency between OFD and PDF files, making it suitable for high-concurrency and batch processing scenarios, but also ensures that the resulting PDF file does not suffer from content or layout errors or corruption, achieving high-fidelity conversion from OFD to PDF files.

[0069] In one embodiment, to obtain a more accurate document object model, such as Figure 3 As shown, in S201, an optional implementation of parsing and processing the OFD file to obtain the Document Object Model includes:

[0070] S301, decompress the OFD file to obtain the OFD byte stream corresponding to the OFD file.

[0071] Optionally, in this embodiment, the OFD file is decompressed using a decompression tool (e.g., ZipInputStream), the input OFD byte stream is read, and the OFD byte stream is decompressed into a temporary structure in memory to obtain the OFD byte stream corresponding to the OFD file.

[0072] S302, determine the document root directory based on OFD byte stream.

[0073] As an optional implementation of this application, the OFD byte stream is parsed to obtain the document root directory.

[0074] Another optional implementation of this application embodiment is to obtain the boot file based on the OFD byte stream. Based on the boot file, the document root directory is determined. Specifically, the OFD.xml file, i.e., the boot file, is read from the OFD byte stream in the temporary structure. In this embodiment, an optional implementation for determining the document root directory based on the boot file is to parse the boot file using a parser (e.g., JAXB or DOM) to obtain a Java object, and then locate the document root directory based on the Java object.

[0075] S303, based on the document root directory, retrieves the document's public resource list and page tree information.

[0076] The document public resource list is primarily used to define the types and specific attributes of file resources. It serves as the resource management center for OFD files, achieving centralized management, efficient reuse, and a unified style through an ID referencing mechanism. It is the cornerstone for building complex, standardized, and optimized document layouts. The document public resource list contains resources shared by all pages in the document, such as: a font dictionary (mapping font IDs to font files); a color dictionary (predefined colors); and an image dictionary (mapping image IDs to image files). The page tree information defines the file's page structure and order; it is not a list containing specific content, but rather a structure containing references to all page nodes, through which the XML file for each specific page can be located.

[0077] Optionally, in this embodiment, the main document, i.e., the Document.xml file, is obtained based on the document root directory. Based on the main document, the document's public resource list and page tree information are then obtained.

[0078] S304. Determine the document object model based on the document public resource list and page tree information.

[0079] Optionally, in this embodiment, resource attribute information of the content objects of each file page is determined based on page tree information and a document public resource list; wherein, content objects include text objects, path objects, and image objects. Based on the resource attribute information of the content objects of each file page, a page list, resource dictionary, and page content instruction set are determined. A document object model is generated based on the page list, resource dictionary, and page content instruction set. Optionally, in this embodiment, resource attribute information includes location, size, font reference, resource sequence number, etc. The page list may include page ID, page size, number of pages, etc. The resource dictionary includes fonts, images, and colors, etc. A page content instruction set refers to a series of sequentially arranged commands that describe how to "draw" content objects on a page. For example, a text instruction could be: "Draw the string 'Hello, World!' at position (100, 200) using the F001 font, 10pt size, and black color." A path instruction could be: "Draw a 1pt wide red line segment from point (50, 50) to point (150, 150)." or "Fill a blue rectangle from (10, 10) to (100, 100)."

[0080] In this embodiment, the OFD file is decompressed to obtain the corresponding OFD byte stream. Based on the OFD byte stream, the document root directory is determined. Based on the document root directory, the document public resource list and page tree information are obtained. Based on the document public resource list and page tree information, the document object model is determined. This embodiment allows for a more efficient and accurate determination of the document object model.

[0081] Based on the above embodiments, in order to construct intermediate models more accurately and efficiently, such as Figure 4 As shown, one optional implementation of S202 includes:

[0082] S401, based on the resource dictionary in the document object model and the page content instruction set of each file page, parse the content objects of each file page in the document object model to obtain the parsing results of each file page.

[0083] Optionally, in this embodiment, when the content object is a text object, the optional implementation for parsing the text object of each file page in the document object model, based on the resource dictionary in the document object model and the page content instruction set of each file page, is to parse out the text content, font reference code, font size, color, position (X, Y), and transformation matrix. The corresponding font file (e.g., simsun.ttf) is found from the resource dictionary based on the font reference code, and the font is loaded using a component library to obtain its precise measurement information (e.g., ascent height, descent height). Using the font measurement, font size, and transformation matrix, the precise occupied area of ​​the text is calculated to obtain the parsing result of the text object. In this embodiment, an optional implementation for parsing path objects is to parse the path definition, stroke color, fill color, line width, and other attributes to obtain the parsing result. In this embodiment, an optional implementation for parsing image objects is to find the image data based on the resource ID, decode it into a BufferedImage, and record its size and position information to obtain the parsing result. The text parsing result, path parsing result, and image parsing result of each file page are used as the parsing result of each file page.

[0084] S402, based on the parsing results of each file page, obtain the intermediate model.

[0085] Optionally, in this embodiment, the parsing results of each file page are instantiated to obtain an intermediate model.

[0086] In this embodiment, the content objects of each file page in the Document Object Model (DOM) are parsed based on the resource dictionary and the page content instruction set of each file page to obtain the parsing results for each file page. An intermediate model is then obtained based on the parsing results of each file page. This embodiment allows for more efficient construction of the intermediate model and improves the fidelity of the constructed intermediate model.

[0087] Based on the above embodiments, in order to improve the fidelity and efficiency of the generated PDF files, such as Figure 5 As shown, one optional implementation of S203 includes:

[0088] S501, Obtain the initial PDF file.

[0089] The initial PDF file contains the same number of pages and page dimensions as the OFD file. The initial PDF file can be understood as an empty PDF file.

[0090] Optionally, in this embodiment, an open-source library can be used to create a PDDocument object and add new pages to it to obtain an initial PDF file. Subsequently, instructions can be written to the PDF by obtaining the PDPageContentStream object of the page.

[0091] S502, based on the intermediate model, renders the content of the initial PDF file to obtain the target PDF file corresponding to the OFD file.

[0092] Content rendering includes text rendering, path rendering, and image rendering.

[0093] Optionally, in this embodiment, an alternative implementation for text drawing on the initial PDF file based on the intermediate model is to check whether the current PDF document has already embedded the font subset. If not, based on the text parsing results in the intermediate model, the font file is loaded and set to be embedded and subsetted. The font and font size are set in the content stream, and the calculated text starting coordinates are used for drawing.

[0094] Optionally, in this embodiment, an alternative implementation for drawing paths in the initial PDF file based on the intermediate model is to convert the path parsing results in the intermediate model into path operation instructions for the PDF content stream, set the colors and line widths, and then perform stroke or fill operations.

[0095] Optionally, in this embodiment, an alternative implementation for drawing images from an initial PDF file based on an intermediate model is to create a PDF object based on the image parsing results in the intermediate model and draw it to the calculated position.

[0096] In this embodiment, an initial PDF file is obtained; the initial PDF file contains the same number of pages and page size as the OFD file. Based on an intermediate model, content rendering is performed on the initial PDF file to obtain the target PDF file corresponding to the OFD file; the content rendering includes text rendering, path rendering, and image rendering. This embodiment improves the conversion efficiency of OFD files to PDF files and ensures the high fidelity of the converted PDF file.

[0097] In one embodiment, such as Figure 6 As shown, an optional implementation of a file processing method includes:

[0098] S601 decompresses the OFD file to obtain the OFD byte stream corresponding to the OFD file.

[0099] S602, based on OFD byte stream, obtains the boot file.

[0100] S603, based on the boot file, determines the document root directory.

[0101] S604 retrieves the list of public resources and page tree information for a document based on its root directory.

[0102] S605, based on the page tree information and the document public resource list, determine the resource attribute information of the content objects of each file page. The content objects include text objects, path objects, and image objects.

[0103] S606 determines the page list, resource dictionary, and page content instruction set based on the resource attribute information of the content objects of each file page.

[0104] S607 generates a document object model based on the page list, resource dictionary, and page content instruction set.

[0105] S608: Based on the resource dictionary in the document object model and the page content instruction set of each file page, the content objects of each file page in the document object model are parsed and processed to obtain the parsing results of each file page.

[0106] S609: Based on the parsing results of each file page, an intermediate model is obtained.

[0107] S610, Obtain the initial PDF file. The initial PDF file contains the same number of pages and page dimensions as the OFD file.

[0108] S611, based on the intermediate model, performs content rendering on the initial PDF file to obtain the target PDF file corresponding to the OFD file. Content rendering includes text rendering, path rendering, and image rendering.

[0109] In this embodiment, the OFD file is parsed to obtain a Document Object Model (DOM). An intermediate model is constructed based on the DOM. The intermediate model is then mapped to obtain the target portable document format (PDF) file corresponding to the OFD file. This application parses the OFD file to obtain a DOM, then converts the DOM into an intermediate model, and performs precise mapping on the intermediate model to obtain the target PDF file. This not only improves the conversion efficiency between OFD and PDF files, making it suitable for high-concurrency and batch processing scenarios, but also ensures that the resulting PDF file does not suffer from content or layout errors or corruption, achieving high-fidelity conversion from OFD to PDF files.

[0110] Based on the same inventive concept, this application also provides a file processing apparatus for implementing the file processing method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, specific limitations in the following embodiment of the file processing apparatus can be found in the limitations of the file processing method described above, and will not be repeated here.

[0111] In one embodiment, such as Figure 7 As shown, a file processing device 1 is provided, comprising:

[0112] The first processing module is used to parse and process OFD files to obtain document object models;

[0113] The second processing module is used to build an intermediate model based on the document object model;

[0114] The third processing module is used to map the intermediate model to obtain the target PDF file corresponding to the OFD file.

[0115] Based on the apparatus in this embodiment, OFD files are parsed to obtain a Document Object Model (DOM). An intermediate model is constructed based on the DOM. The intermediate model is then mapped to obtain the target portable document format (PDF) file corresponding to the OFD file. This application parses OFD files to obtain a DOM, then converts the DOM into an intermediate model, and performs precise mapping on the intermediate model to obtain the target PDF file. This not only improves the conversion efficiency between OFD and PDF files, making it suitable for high-concurrency and batch processing scenarios, but also ensures that the obtained target PDF file does not suffer from content or layout errors or corruption, achieving high-fidelity conversion from OFD files to PDF files.

[0116] In one embodiment, the first processing module is further specifically used for:

[0117] The OFD file is decompressed to obtain the corresponding OFD byte stream;

[0118] Determine the document root directory based on the OFD byte stream;

[0119] Based on the document's root directory, retrieve the list of public resources and page tree information for the document;

[0120] Based on the document public resource list and page tree information, the document object model is determined.

[0121] In one embodiment, the first processing module is further specifically used for:

[0122] Obtain the boot file based on OFD byte stream;

[0123] Determine the document root directory based on the boot file.

[0124] In one embodiment, the first processing module is further specifically used for:

[0125] Based on the page tree information and the document public resource list, the resource attribute information of the content objects of each file page is determined; among them, the content objects include text objects, path objects and image objects;

[0126] Based on the resource attribute information of the content objects of each file page, determine the page list, resource dictionary, and page content instruction set;

[0127] Generate a document object model based on the page list, resource dictionary, and page content instruction set.

[0128] In one embodiment, the second processing module is further specifically used for:

[0129] Based on the resource dictionary in the Document Object Model and the page content instruction set of each file page, the content objects of each file page in the Document Object Model are parsed and processed to obtain the parsing results of each file page;

[0130] An intermediate model is obtained based on the parsing results of each file page.

[0131] In one embodiment, the third processing module is further specifically used for:

[0132] Obtain the initial PDF file; the initial PDF file contains the same number of pages and page size as the OFD file;

[0133] Based on the intermediate model, the content of the initial PDF file is drawn to obtain the target PDF file corresponding to the OFD file; the content drawing includes text drawing, path drawing and image drawing.

[0134] Each module in the aforementioned file processing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can invoke and execute the operations corresponding to each module.

[0135] In one embodiment, a computer device is provided, the internal structure of which can be shown as follows: Figure 8As shown, the computer device includes a processor, memory, input / output interface, communication interface, display unit, and input device. The processor, memory, and input / output interface are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interface. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interface is used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When executed by the processor, the computer program implements a file processing method. The display unit is used to form a visually visible image and can be a display screen, projection device, or virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0136] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0137] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0138] The OFD file is parsed to obtain the document object model;

[0139] Based on the document object model, construct an intermediate model;

[0140] The intermediate model is mapped to obtain the target PDF file corresponding to the OFD file.

[0141] In one embodiment, when the processor executes the computer program, it further performs the following steps: parsing the OFD file to obtain a document object model, including:

[0142] The OFD file is decompressed to obtain the corresponding OFD byte stream;

[0143] Determine the document root directory based on the OFD byte stream;

[0144] Based on the document's root directory, retrieve the list of public resources and page tree information for the document;

[0145] Based on the document public resource list and page tree information, the document object model is determined.

[0146] In one embodiment, when the processor executes a computer program, it further performs the following steps: determining the document root directory based on the OFD byte stream, including:

[0147] Obtain the boot file based on OFD byte stream;

[0148] Determine the document root directory based on the boot file.

[0149] In one embodiment, when the processor executes the computer program, it further performs the following steps: determining a document object model based on the document public resource list and page tree information, including:

[0150] Based on the page tree information and the document public resource list, the resource attribute information of the content objects of each file page is determined; among them, the content objects include text objects, path objects and image objects;

[0151] Based on the resource attribute information of the content objects of each file page, determine the page list, resource dictionary, and page content instruction set;

[0152] Generate a document object model based on the page list, resource dictionary, and page content instruction set.

[0153] In one embodiment, when the processor executes the computer program, it further performs the following steps: constructing an intermediate model based on the document object model, including:

[0154] Based on the resource dictionary in the Document Object Model and the page content instruction set of each file page, the content objects of each file page in the Document Object Model are parsed and processed to obtain the parsing results of each file page;

[0155] An intermediate model is obtained based on the parsing results of each file page.

[0156] In one embodiment, when the processor executes the computer program, it further performs the following steps: mapping the intermediate model to obtain the target PDF file corresponding to the OFD file, including:

[0157] Obtain the initial PDF file; the initial PDF file contains the same number of pages and page size as the OFD file;

[0158] Based on the intermediate model, the content of the initial PDF file is drawn to obtain the target PDF file corresponding to the OFD file; the content drawing includes text drawing, path drawing and image drawing.

[0159] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:

[0160] The OFD file is parsed to obtain the document object model;

[0161] Based on the document object model, construct an intermediate model;

[0162] The intermediate model is mapped to obtain the target PDF file corresponding to the OFD file.

[0163] In one embodiment, when the computer program is executed by a processor, it further performs the following steps: parsing the OFD file to obtain a document object model, including:

[0164] The OFD file is decompressed to obtain the corresponding OFD byte stream;

[0165] Determine the document root directory based on the OFD byte stream;

[0166] Based on the document's root directory, retrieve the list of public resources and page tree information for the document;

[0167] Based on the document public resource list and page tree information, the document object model is determined.

[0168] In one embodiment, when the computer program is executed by a processor, it further performs the following steps: determining the document root directory based on the OFD byte stream, including:

[0169] Obtain the boot file based on OFD byte stream;

[0170] Determine the document root directory based on the boot file.

[0171] In one embodiment, when the computer program is executed by a processor, it further performs the following steps: determining a document object model based on a list of public resources for documents and page tree information, including:

[0172] Based on the page tree information and the document public resource list, the resource attribute information of the content objects of each file page is determined; among them, the content objects include text objects, path objects and image objects;

[0173] Based on the resource attribute information of the content objects of each file page, determine the page list, resource dictionary, and page content instruction set;

[0174] Generate a document object model based on the page list, resource dictionary, and page content instruction set.

[0175] In one embodiment, when the computer program is executed by a processor, it further performs the following steps: constructing an intermediate model based on the document object model, including:

[0176] Based on the resource dictionary in the Document Object Model and the page content instruction set of each file page, the content objects of each file page in the Document Object Model are parsed and processed to obtain the parsing results of each file page;

[0177] An intermediate model is obtained based on the parsing results of each file page.

[0178] In one embodiment, when the computer program is executed by a processor, it further performs the following steps: mapping the intermediate model to obtain the target PDF file corresponding to the OFD file, including:

[0179] Obtain the initial PDF file; the initial PDF file contains the same number of pages and page size as the OFD file;

[0180] Based on the intermediate model, the content of the initial PDF file is drawn to obtain the target PDF file corresponding to the OFD file; the content drawing includes text drawing, path drawing and image drawing.

[0181] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:

[0182] The OFD file is parsed to obtain the document object model;

[0183] Based on the document object model, construct an intermediate model;

[0184] The intermediate model is mapped to obtain the target PDF file corresponding to the OFD file.

[0185] In one embodiment, when the computer program is executed by a processor, it further performs the following steps: parsing the OFD file to obtain a document object model, including:

[0186] The OFD file is decompressed to obtain the corresponding OFD byte stream;

[0187] Determine the document root directory based on the OFD byte stream;

[0188] Based on the document's root directory, retrieve the list of public resources and page tree information for the document;

[0189] Based on the document public resource list and page tree information, the document object model is determined.

[0190] In one embodiment, when the computer program is executed by a processor, it further performs the following steps: determining the document root directory based on the OFD byte stream, including:

[0191] Obtain the boot file based on OFD byte stream;

[0192] Determine the document root directory based on the boot file.

[0193] In one embodiment, when the computer program is executed by a processor, it further performs the following steps: determining a document object model based on a list of public resources for documents and page tree information, including:

[0194] Based on the page tree information and the document public resource list, the resource attribute information of the content objects of each file page is determined; among them, the content objects include text objects, path objects and image objects;

[0195] Based on the resource attribute information of the content objects of each file page, determine the page list, resource dictionary, and page content instruction set;

[0196] Generate a document object model based on the page list, resource dictionary, and page content instruction set.

[0197] In one embodiment, when the computer program is executed by a processor, it further performs the following steps: constructing an intermediate model based on the document object model, including:

[0198] Based on the resource dictionary in the Document Object Model and the page content instruction set of each file page, the content objects of each file page in the Document Object Model are parsed and processed to obtain the parsing results of each file page;

[0199] An intermediate model is obtained based on the parsing results of each file page.

[0200] In one embodiment, when the computer program is executed by a processor, it further performs the following steps: mapping the intermediate model to obtain the target PDF file corresponding to the OFD file, including:

[0201] Obtain the initial PDF file; the initial PDF file contains the same number of pages and page size as the OFD file;

[0202] Based on the intermediate model, the content of the initial PDF file is drawn to obtain the target PDF file corresponding to the OFD file; the content drawing includes text drawing, path drawing and image drawing.

[0203] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0204] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0205] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A file processing method, characterized in that, The method includes: The document object model (OFD) file of the open layout document is obtained by parsing and processing it. Based on the document object model, construct an intermediate model; The intermediate model is mapped to obtain the target portable document format PDF file corresponding to the OFD file.

2. The method according to claim 1, characterized in that, The process of parsing and processing the Open Layout Document (OFD) file to obtain the Document Object Model includes: The OFD file is decompressed to obtain the OFD byte stream corresponding to the OFD file; Based on the OFD byte stream, determine the document root directory; Based on the document root directory, obtain the document public resource list and page tree information; Based on the document public resource list and the page tree information, the document object model is determined.

3. The method according to claim 2, characterized in that, Determining the document root directory based on the OFD byte stream includes: Based on the OFD byte stream, obtain the boot file; Based on the aforementioned boot file, determine the document root directory.

4. The method according to claim 2, characterized in that, The step of determining the document object model based on the document public resource list and the page tree information includes: Based on the page tree information and the document public resource list, the resource attribute information of the content objects of each file page is determined; wherein, the content objects include text objects, path objects and image objects; Based on the resource attribute information of the content objects of each file page, determine the page list, resource dictionary, and page content instruction set; The document object model is generated based on the page list, resource dictionary, and page content instruction set.

5. The method according to claim 4, characterized in that, The construction of the intermediate model based on the document object model includes: Based on the resource dictionary in the Document Object Model and the page content instruction set of each file page, the content objects of each file page in the Document Object Model are parsed and processed to obtain the parsing results of each file page; An intermediate model is obtained based on the parsing results of each file page.

6. The method according to claim 1, characterized in that, The mapping process of the intermediate model to obtain the target portable document format PDF file corresponding to the OFD file includes: Obtain an initial PDF file; wherein the initial PDF file contains the same number of pages and page size as the OFD file; Based on the intermediate model, the content of the initial PDF file is drawn to obtain the target PDF file corresponding to the OFD file; wherein, the content drawing includes text drawing, path drawing and image drawing.

7. A document processing device, characterized in that, The device includes: The first processing module is used to parse and process OFD files to obtain document object models; The second processing module is used to construct an intermediate model based on the document object model; The third processing module is used to perform mapping processing on the intermediate model to obtain the target PDF file corresponding to the OFD file.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the file processing method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.