Method and apparatus for merging files of multiple formats into one OFD file
The method and apparatus convert multiple files into a unified OFD format, addressing storage and sharing inconveniences by maintaining format consistency and stability, facilitating easier handling of diverse file types.
Patent Information
- Application Number
- JP2024526875
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2021-11-05
- Filing Date
- 2022-11-04
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2042-11-04
AI Technical Summary
Current methods for merging multiple files result in inconvenient offline storage, sharing, and viewing, especially with non-uniform formats like DOC, WPS, and PPTX, which are prone to content changes and lack long-term storage safety.
A method and apparatus for converting multiple files into OFD format, creating a base structure, extracting and packaging file resources to generate a unified OFD file, handling duplicate IDs, and merging directories to maintain hierarchical structure.
Enables easier archiving, transferring, and sharing of files with consistent format and display standards, ensuring stability and uniformity across different file formats.
Smart Images

Figure 2024538357000001_ABST
Abstract
Description
[Technical field]
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS This application claims priority to a Chinese patent application filed with the China Patent Office on November 5, 2021, application number 202111305218.4, and entitled "Method and apparatus for merging multiple format files into one OFD file," the entire contents of which are incorporated herein by reference.
[0002] The present invention relates to the field of merging and displaying methods, and in particular to an apparatus and method for merging files of multiple formats into one OFD file. [Background technology]
[0003] Currently, the merging of multiple files is based on the premise of not destroying the originals, and involves analyzing and rendering the files in a reader device to merge multiple files into a single file so that they can be read all at once. However, the files are essentially still multiple files; only the way in which they are read has changed, making it inconvenient to store, share, transfer, and read files offline.
[0004] On October 14, 2016, the World Standards Day, the National Standardization Administration of China formally approved and published the national standard GB / T 33190-2016 "Electronic File Storage and Exchange Format Layout Document" (abbreviated as OFD) based on independent methods. OFD is the abbreviation of Open Fixed-layout Document, which is China's independent and controllable electronic file layout document format, and its corresponding international standard is PDF. OFD layout files have a fixed layout, no layout shift, and are what you see, what you get (WYSIWYG), and can be regarded as the "digital paper" of the computer age. It is an ideal document format for issuing electronic documents, transmitting digital information, and archiving. Traditional electronic file archiving formats have no unified national or industrial standards, and stream file formats such as DOC, WPS, and PPTX in document storage work are easy to change in content and have potential safety risks during the transfer process, which does not meet the requirements for long-term storage of electronic files. Summary of the Invention [Problem to be solved by the invention]
[0005] SUMMARY OF THE PRESENT EMBODIMENT It is an object of the present invention to provide a method and apparatus for merging files of multiple formats into one OFD file, which overcomes one or more of the problems of the conventional methods mentioned above. [Means for solving the problem]
[0006] The method and apparatus proposed by the present invention for merging files of multiple formats into one OFD file includes: converting a plurality of files of different formats into an OFD format file; creating a base OFD file structure; Extracting the OFD format files and obtaining a extracted folder; copying file resources corresponding to the OFD format file into a base OFD file structure and packaging to generate an integrated and merged OFD file.
[0007] In some embodiments, the file formats include wps, doc / docx, xls / xlsx, ppt / pptx, cad, jpg, tif, gif, png, pdf, html.
[0008] In some embodiments, the step of extracting the OFD format file includes changing the extension .ofd of the OFD file to .zip to form a compressed file, and extracting the compressed file to obtain a extracted folder.
[0009] In some embodiments, the step of packaging to generate an integrated and merged OFD file comprises: Copying the file contents and file resources in the folder into a base OFD file structure while maintaining the hierarchical structure; merging directories of multiple OFD format files onto an underlying OFD file structure and moving files referenced by the directories; replacing duplicate resource ids and moving associated file resources; packaging the folder and generating a merged OFD format file.
[0010] In some embodiments, the step of merging directories of multiple OFD format files onto a single underlying OFD file structure and moving files referenced by the directories includes: overwriting the OFD.xml in the first OFD file with the OFD.xml in the base OFD file structure; Analyzing files under the Doc_N directory under the same file directory, reading the doucment.xml file, writing the content of ofd:Pages in the doucment.xml file into the corresponding xml of the base OFD file structure, and adjusting the content of the corresponding ofd:Pages BaseLog if multiple OFD files have the same file path.
[0011] In some embodiments, the step of replacing duplicate resource ids and moving associated file resources comprises: Traverse resource IDs from the first page, copy file resources referenced by the IDs into the corresponding folder, and if there is a duplication in the IDs, change the ID, rename the file resource, and copy it under the corresponding folder.
[0012] How to merge files in multiple formats into one OFD file using file-within-file merging? obtaining a file within a plurality of files; converting the file in the file into an OFD format file; creating a base OFD file structure; Extracting the OFD format files and obtaining a extracted folder; copying and packaging file resources corresponding to the OFD format file into a base OFD file structure to generate an integrated and merged OFD file; Includes.
[0013] In some embodiments, the file within the file includes a file processing sheet, a final draft, and previous revisions.
[0014] A system for merging files of multiple formats into a single OFD file includes a client and a server, The client can upload files of different formats and receive and display the merged OFD format file. The server is used to store and execute computer instructions to implement the above-mentioned method of merging files of multiple formats into an OFD file and / or the method of merging files within a file.
[0015] An apparatus for merging files of multiple formats into one OFD file includes at least one storage medium and at least one processor, the at least one storage medium is adapted to store computer instructions; The at least one processor is adapted to execute the computer instructions to implement the method of merging files of multiple formats into an OFD file and / or the method of merging files within a file as described above.
[0016] The advantages of the apparatus and method for merging files of multiple formats into an OFD file described in the present invention are as follows:
[0017] According to the device and method for merging files of multiple formats into an OFD file described in the present invention, files of different formats are used to form an OFD format file with a unified format and display standard, making it easier to unify the formats of multiple files of the same or different formats and archive, transfer, view, and share them as a whole.
[0018] Using this method, a set of multiple sub-documents such as file processing sheets, final drafts, and past revisions can be converted and merged into a single OFD format file in a unified manner. For the content and images of the electronic official documents formed, OCR methods can be used to extract full-text content data and scan the images, which are then merged into a two-layer OFD format file. Metadata for electronic archiving can be embedded in the OFD file. [Brief description of the drawings]
[0019] [Figure 1] 4 is a flowchart of a method for merging files of multiple formats into an OFD file in some embodiments of the present invention. [Diagram 2] 1 is a diagram showing the hierarchical organization of an OFD file. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0020] Semantic interpretation The essence of an OFD file is a compressed package of one xml file.
[0021] A system for merging files of multiple formats into one OFD file proposed in some embodiments of the present invention includes a client and a server, and in relation to what is shown in FIG. 1, merging files of multiple formats into one OFD file using this system includes the following steps:
[0022] Step 1. Select and upload files in the client. The file formats to be uploaded include but are not limited to wps, doc / docx, xls / xlsx, ppt / pptx, cad, jpg, tif, gif, png, pdf, html.
[0023] Step 2. The server receives the files uploaded by the client, determines the formats of different files, and according to the formats of the files, calls the corresponding conversion method to convert the files into PDF format files, and further converts the PDF format files into OFD files in OFD format. The conversion to PDF format files according to the formats of the files includes the following steps:
[0024] 1) For wps, doc / docx files, use Word.Application to generate pdf. The specific steps are as follows:
[0025] 1.1.Open the Word application, 1.2.Hide the word, 1.3.Get all documents open in Word and return a Documents object. 1.4. Call the Open method in the Documents object to open the document and return the open document object, Document. 1.5. Call the ExportAsFixedFormat method of the Document object to save the document in PDF format. 1.6. Close the document, 1.7.Exit the Word application.
[0026] 2) For xls / xlsx, generate pdf using Excel.Application. Specific steps are as follows:
[0027] 2.1.Open the Excel application, 2.2.Hide Excel, 2.3.Get all open documents in Excel and return a Documents object. 2.4. Call the Open method in the Documents object to open the document and return the open document object, Document. 2.5. Call the ExportAsFixedFormat method of the Document object to save the document in PDF format. 2.6. Close the document, 2.7.Exit the Word application.
[0028] 3) For ppt / pptx, use PowerPoint.Application to generate the pdf.
[0029] 4)For cad, use Aspose.CAD to generate pdf, here when layers in CAD design have different size, auto scale feature will scale layers according to uniform page size in PDF, when scaled, if CAD is displayed in black and white in PDF, you can override this feature using setBackgroundColor and set required background and shape color.
[0030] 5) Convert jpg, tif, gif, png images to pdf using PdfWriter, the specific steps are as follows:
[0031] 5.1. Create a PDF document, 5.2. Add a page, 5.3. Load the image, 5.4. Draw an image to a PDF, set its position and size within the PDF file, 5.5. Save and exit.
[0032] Step 3. The server creates a base OFD file structure (the base OFD file structure contains only the structure).
[0033] Step 4. The client traverses multiple OFD files, and the server creates a new file directory, copies multiple OFD files traversed by the client into the new file directory of the server, renames the extensions of the OFD files in the new file directory to .zip, and performs file extraction on the .zip file to obtain the extracted OFD folder of the corresponding OFD files. The hierarchical organizational structure is shown in Figure 2.
[0034] Step 5. The server copies the file contents and file resources in the folder into the base OFD file structure while maintaining the hierarchical structure, packages them, and generates an integrated and merged OFD file. Specifically, the process includes the following steps:
[0035] Step 5.1. Merge multiple OFD folder directories on the base OFD file structure, and the OFD.xml file in the xml file package of the OFD folder is the entry file, which overwrites the OFD.xml in the first OFD file with the OFD.xml in the base OFD file structure.
[0036] Step 5.2. Move the referenced file to the directory. The server parses the files under the Doc_N directory under the same file directory, reads the doucment.xml file in the xml file package, writes the contents of ofd:Pages in the doucment.xml file into the corresponding xml in the base OFD file structure sequentially, and adjusts the contents of the corresponding ofd:Pages BaseLog if there are the same file paths in multiple OFD folders. For example, if the page number of file 1 is ' <ofd:page baseloc=""Pages / Page_11 / Content.xml”" id=""12” / ">', when subsequent files are merged, continue incrementing from Pages_12,ID=13 and copy the files under the corresponding page numbers. If all n file directories are 1 to 10, then it is necessary to adjust the file directories of these folders so that the adjusted directories are 1 to 10, 11 to 20, ..., {(n-1)*10+1} to (n*10), and then copy the corresponding files that are referenced. The script information is as follows: JPEG2024538357000002.jpg163170
[0037] Step 5.3. Replace duplicate resource ids. The server traverses the contents of the Pages content.xml, traverses the resource ids from the first page, copies the file resources referenced by the ids into the corresponding folder, and if there is a duplicate id, changes the id, renames the file resource, and copies it into the xml file package under the corresponding OFD folder.
[0038] Step 5.4. Merge file resources in xml file packages in multiple OFD folders to form one xml file package, change the extension to ofd, and generate an integrated and merged OFD file.
[0039] The above file resources include fonts, font sizes, images, text, etc.
[0040] Step 5.3 above may be performed in preference to step 5.2.
[0041] The method for merging files within a file using the above method for merging files of multiple formats into an OFD file includes the following steps.
[0042] S1. From Version.xml in the root directory, obtain multiple files within a file, including a file processing sheet, the final draft, and each previous revision.
[0043] Convert the file in S2.File to OFD format file.
[0044] S3. Create the base OFD file structure.
[0045] S4. After traversing the multiple OFD files, the server creates a new file directory, copies the multiple OFD files that have been traversed into the new file directory of the server, renames the .ofd extensions of the OFD files in the new file directory to .zip, performs file extraction on the .zip file, and obtains an OFD folder after extraction of the corresponding OFD files.
[0046] S4. The server copies the file contents and file resources in the OFD folder into the base OFD file structure while maintaining the hierarchical structure, packages them, and generates an integrated and merged OFD file. Specifically, the process includes the following steps:
[0047] Step 5.1. Merge multiple OFD folder directories on the base OFD file structure, and the OFD.xml file is the entry file, which overwrites the OFD.xml in the first OFD file with the OFD.xml in the base OFD file structure.
[0048] S5.2. Move the referenced file to the directory. The server parses the files under the Doc_N directory under the same file directory, reads the doucment.xml file in the xml file package, writes the contents of ofd:Pages in the doucment.xml file sequentially into the corresponding xml of the base OFD file structure, and adjusts the contents of the corresponding ofd:Pages BaseLog if there are the same file paths in multiple OFD files.
[0049] S5.3. Replace duplicate resource IDs. The server traverses the contents of the Pages content.xml in the xml file package, traverses the resource IDs from the first page, copies the file resources referenced by the IDs into the corresponding folder, and if there is a duplicate ID, changes the ID, renames the file resource, and copies it under the corresponding OFD folder.
[0050] S5.4. Package the OFD folder, rename the extension to ofd, and generate the unified and merged OFD file.
[0051] By merging files within files as described above, the historical records of the files can be merged into a single whole, making it easier to archive, transfer, view, and share the files within files as a whole.
[0052] In some embodiments of the present invention, an apparatus for merging files of multiple formats into one OFD file is provided, comprising at least one storage medium and at least one processor: At least one storage medium is adapted to store computer instructions; At least one processor is adapted to execute the computer instructions to implement the method of merging files of multiple formats into an OFD file and / or the method of merging files within a file as described above.
[0053] The above description is only the preferred embodiment of the present invention. Those skilled in the art can make some similar modifications and improvements without departing from the inventive concept of the present invention, which should also be regarded as within the protection scope of the present invention.< / ofd:page>
Claims
1. 1. A method for merging files of multiple formats into one OFD file, comprising the steps of: converting a plurality of files of different formats into an OFD format file; creating a base OFD file structure; Decompressing a plurality of OFD format files and acquiring a folder after the files are decompressed; copying and packaging file resources corresponding to the OFD format file into a base OFD file structure to generate an integrated and merged OFD file; 13. A method for merging files of multiple formats into one OFD file, comprising:
2. The file formats include: wps, doc / docx, xls / xlsx, ppt / pptx, cad, jpg, tif, gif, png, pdf, html 2. The method of claim 1, wherein the file is a file of a plurality of formats.
3. The step of extracting the OFD format file is a step of changing the extension .ofd of the OFD file to .zip to form a compressed file, extracting the compressed file, and obtaining the extracted folder.
2. The method of claim 1, wherein the file is a file of a plurality of formats.
4. The step of packaging to generate an integrated and merged OFD file includes: merging directories of multiple OFD format files on a base OFD file structure and moving files referenced by the directories; replacing duplicate resource ids and moving associated file resources; packaging the folder and generating a merged OFD format file; 2. The method for merging files of multiple formats into an OFD file according to claim 1, wherein:
5. The step of merging directories of multiple OFD format files onto a single base OFD file structure and moving files referenced by the directories includes: overwriting OFD.xml in the first OFD file with OFD.xml in the base OFD file structure; Analyzing files under the Doc_N directory under the same file directory, reading the doucment.xml file, writing the content of ofd:Pages in the doucment.xml file into the corresponding xml of the base OFD file structure, and adjusting the content of the corresponding ofd:Pages BaseLog when the file paths of multiple OFD files are the same; 5. The method for merging files of multiple formats into an OFD file according to claim 4, wherein:
6. The step of replacing duplicate resource ids and moving associated file resources comprises: A step of traversing resource IDs from the first page, copying file resources referenced by the IDs into the corresponding folder, and if there is a duplication of the IDs, changing the IDs, renaming the file resources, and copying them under the corresponding folder.
5. The method for merging files of multiple formats into an OFD file according to claim 4, wherein:
7. A method for merging files in a file using a method for merging files in multiple formats into an OFD file, comprising the steps of: Retrieving a file within a plurality of files using Version.xml in the root directory; converting the file in the file into an OFD format file; creating a base OFD file structure; Decompressing a plurality of OFD format files and acquiring a folder after the files are decompressed; copying and packaging file resources corresponding to the OFD format file into a base OFD file structure to generate an integrated and merged OFD file; 13. A method for merging files of multiple formats into one OFD file, comprising:
8. The files within the file include a file processing sheet, a final draft, and each of the past revisions. The merging method according to claim 7 .
9. A system for merging files of multiple formats into one OFD file, comprising: A system including a client and a server, The client is used to upload files of different formats, and receives and displays the merged OFD format file; The server is used to implement the method of merging files of multiple formats into an OFD file according to any one of claims 1 to 6 or the method of merging according to any one of claims 7 to 8 by storing and executing computer instructions. A system characterized by:
10. An apparatus for merging files of multiple formats into one OFD file, comprising: The apparatus comprises at least one storage medium and at least one processor; the at least one storage medium is adapted to store computer instructions; The at least one processor is adapted to implement the method of merging files of multiple formats into an OFD file according to any one of claims 1 to 6 or the merging method according to any one of claims 7 to 8 by executing the computer instructions. An apparatus comprising:
Citation Information
Patent Citations
OFD file merging display and directory generation method
CN111753502A
Generic Infrastructure for converting documents between formats with merge capabilities
US20030182450A1
Document format processing apparatus and document format processing method
US20150046797A1
