Word document image processing method, system and medium based on unpacked file operation

By treating the document data to be processed as a compressed file, and directly accessing and modifying its internal XML file structure, the problem of low efficiency in traditional Word document image processing is solved, and a technology for quickly replacing and inserting images is realized.

CN122433685APending Publication Date: 2026-07-21东莞信宝电子产品检测有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
东莞信宝电子产品检测有限公司
Filing Date
2026-04-23
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

Image replacement or insertion operations in traditional Word documents are inefficient, especially when processing large numbers of documents, which consumes a lot of time and labor costs and is prone to omissions or errors.

Method used

By treating Word documents as compressed files, and utilizing file unpacking operations, we can directly access and modify their internal XML file structure, enabling rapid image replacement and insertion.

Benefits of technology

It improves the efficiency and accuracy of image processing in Word documents, reduces labor costs, and avoids omissions and errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122433685A_ABST
    Figure CN122433685A_ABST
Patent Text Reader

Abstract

The application provides a Word document image processing method, system and medium based on unpacking file operation. The method comprises the following steps: pre-processing the to-be-processed document data, storing the to-be-processed word document data to a specified storage path, changing the file extension to obtain a named document, decompressing the named document to a temporary directory to obtain a modified directory, obtaining target image data and confirmation data of an image processing mode, processing by a preset image processing program to obtain updated image data and a modified relationship file, re-compressing the modified directory and updating the extension, and testing and verifying the output document; thereby, the to-be-processed word document data is treated as a compressed file for processing, the internal XML file structure is directly accessed and modified, and the quick replacement and insertion technology for the images in the document are 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 more specifically, to a method, system, and medium for Word document image processing based on file unpacking operations. Background Technology

[0002] In modern office work and document processing, it is often necessary to replace or insert images in Word documents, such as in updating corporate promotional materials or revising product manuals. Traditional methods, such as manual processing through the Word software interface, are intuitive and simple when dealing with a small number of documents. However, when dealing with a large number of documents, staff need to open each document individually, locate the corresponding image, and perform the replacement or insertion. This process is time-consuming, labor-intensive, and extremely inefficient, drastically increasing labor costs and increasing the risk of omissions or errors.

[0003] With the continuous growth of data volume and the increasing complexity of business needs, there is a need for an efficient, flexible, and accurate method for processing Word document images to address the shortcomings of existing technologies. Summary of the Invention

[0004] The purpose of this application is to provide a method, system, and medium for image processing of Word documents based on file unpacking operations. By treating the Word document data to be processed as a compressed file, the internal XML file structure can be directly accessed and modified, thereby enabling the rapid replacement and insertion of images in the document.

[0005] This application also provides a Word document image processing method based on file unpacking operations, including the following steps: Acquire the document data to be processed and the target image data, and preprocess the document data to be processed to obtain the Word document data to be processed; The Word document data to be processed is stored in a specified storage path and the file extension is changed to obtain a named document; The named document is decompressed to a temporary directory using a preset namespace program, and the modified directory is obtained. Obtain confirmation data for the image processing method, and process the image using a preset image processing program based on the confirmation data to obtain updated image data and modified relationship files; The modified directory is recompressed into an updated named document using a preset compression program, and then output after updating the file extension to Word. The output document is tested and verified using a pre-set script, and the corresponding processing method is obtained based on the verification results.

[0006] Optionally, in the Word document image processing method based on file unpacking operations described in this application, the step of obtaining the document data to be processed and the target image data, and preprocessing the document data to be processed to obtain the Word document data to be processed, specifically includes: Obtain the document data to be processed, and then unify the document data to be processed into a fixed Word version to obtain the Word document data to be processed. Acquire target image data, including new image data, old image data, or added image data.

[0007] Optionally, in the Word document image processing method based on file unpacking operations described in this application, the step of storing the Word document data to be processed in a specified storage path and changing the file extension to obtain a named document specifically includes: The Word document data to be processed is stored in a specified path and marked as the input document area; The pre-defined extension renaming program changes the file extension of the Word document data to a compressed file extension to obtain a named document.

[0008] Optionally, in the Word document image processing method based on file unpacking operations described in this application, the step of unpacking the named document to a temporary directory using a preset namespace program and obtaining the modified directory specifically includes: The named document is decompressed to a temporary directory using a preset namespace program, and a modified directory is obtained, including a media processing module and an XML editing module.

[0009] Optionally, in the Word document image processing method based on file unpacking operations described in this application, obtaining confirmation data for the image processing method, and processing the confirmation data through a preset image processing program to obtain updated image data and modified relationship files, specifically includes: Obtain confirmation data for the image processing method, including replacing image data or adding image data; If the confirmed data is replacement image data, then copy the new image data to the corresponding Word document media resource directory, overwriting the old image data; At the same time, search for the reference relationship data of the old version of the image in the XML editing module and replace it with the new version of the image data; If the confirmed data is new image data, then copy the new image data to the corresponding Word document media resource directory and name it "Update Image Data"; Add a preset XML fragment reference to update image data at the end of the XML editing module, and add a binding relationship to the relationship file to obtain the modified relationship file.

[0010] Optionally, in the Word document image processing method based on file unpacking operations described in this application, the step of testing and verifying the output document through a preset script program and obtaining the corresponding processing method based on the verification result specifically includes: The preset script program checks the media processing module of the output document to confirm whether it contains new or newly added image data. If it is present, open a sample and confirm the image display status; If it is not contained, a warning will be issued.

[0011] Secondly, this application provides a Word document image processing system based on file unpacking operations. The system includes a memory and a processor. The memory stores a program for a Word document image processing method based on file unpacking operations. When the program for the Word document image processing method based on file unpacking operations is executed by the processor, it performs the following steps: Acquire the document data to be processed and the target image data, and preprocess the document data to be processed to obtain the Word document data to be processed; The Word document data to be processed is stored in a specified storage path and the file extension is changed to obtain a named document; The named document is decompressed to a temporary directory using a preset namespace program, and the modified directory is obtained. Obtain confirmation data for the image processing method; based on the confirmation data, process the image using a preset image processing program to obtain updated image data and obtain the modified relationship file. The modified directory is recompressed into an updated named document using a preset compression program, and then output after updating the file extension to Word. The output document is tested and verified using a pre-set script, and the corresponding processing method is obtained based on the verification results.

[0012] Optionally, in the Word document image processing system based on file unpacking operations described in this application, the step of acquiring the document data to be processed and the target image data, and preprocessing the document data to be processed to obtain the Word document data to be processed, specifically includes: Obtain the document data to be processed, and then unify the document data to be processed into a fixed Word version to obtain the Word document data to be processed. Acquire target image data, including new image data, old image data, or added image data.

[0013] Optionally, in the Word document image processing system based on file unpacking operations described in this application, the step of storing the Word document data to be processed in a specified storage path and changing the file extension to obtain a named document specifically includes: The Word document data to be processed is stored in a specified path and marked as the input document area; The pre-defined extension renaming program changes the file extension of the Word document data to a compressed file extension to obtain a named document.

[0014] Thirdly, this application also provides a readable storage medium storing a Word document image processing method program based on file unpacking operations. When the Word document image processing method program based on file unpacking operations is executed by a processor, it implements the steps of the Word document image processing method based on file unpacking operations as described in any of the above claims.

[0015] As described above, this application provides a Word document image processing method, system, and medium based on file unpacking operations. The method involves preprocessing the document data to obtain the Word document data, storing it in a specified storage path, changing the file extension to obtain a named document, decompressing the named document to a temporary directory to obtain a modification directory, obtaining target image data and confirmation data for image processing methods, processing it through a preset image processing program to obtain updated image data and modification relationship files, recompressing the modification directory and updating its extension, and then testing and verifying the output document. Thus, by treating the Word document data as a compressed file, it directly accesses and modifies its internal XML file structure, achieving rapid image replacement and insertion technology within the document.

[0016] Other features and advantages of this application will be set forth in the following description and will be apparent in part from the description or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description and the accompanying drawings. Attached Figure Description

[0017] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 A flowchart illustrating a Word document image processing method based on file unpacking operations provided in this application embodiment; Figure 2 A flowchart illustrating the method for obtaining named documents using a Word document image processing technique based on file unpacking operations, as provided in this application embodiment; Figure 3The flowchart illustrates the process of obtaining updated image data and modifying relational files using a Word document image processing method based on file unpacking operations, as provided in this application embodiment. Detailed Implementation

[0019] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0020] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0021] Please refer to Figure 1 , Figure 1 This is a flowchart of a Word document image processing method based on file unpacking operations according to some embodiments of this application. This Word document image processing method based on file unpacking operations is used in terminal devices, such as computers and mobile phones. The Word document image processing method based on file unpacking operations includes the following steps: S11. Obtain the document data to be processed and the target image data, and preprocess the document data to be processed to obtain the Word document data to be processed; S12. Store the Word document data to be processed in the specified storage path and change the file extension to obtain a named document; S13. Decompress the named document to a temporary directory using a preset namespace program, and obtain the modified directory; S14. Obtain confirmation data for the image processing method, and process the image data and modify the relationship file according to the confirmation data through a preset image processing program; S15. Compress the modified directory into an updated named document using a preset compression program, and then output it with the new Word document extension. S16. Test and verify the output document using a preset script program, and obtain the corresponding processing method based on the verification results.

[0022] It should be noted that when editing Word documents, there may be situations where images need to be replaced or added in batches. In such cases, when using the file unpacking method, the format of the Word documents must be standardized. Then, the file extensions of the standardized files should be changed to compressed file extensions. Next, the C# System IO Compression namespace should be used to decompress all files corresponding to the compressed file extensions and store them in a temporary directory. After decompression, each document will generate a media processing module and an XML editing module. Users can directly access or edit these modules. After editing, the files are recompressed and the format restored to obtain the output document. Then, a C# script is used to verify and test the output document. Finally, the modified directory is recompressed into a new named document using a preset compression program, with the extension changed to .docx. The preset compression program is: using System; using System.IO; using System.IO.Compression; class Program { static void Main() { string tempDir = " / temp_unzip / "; string outputDir = " / output_docs / "; foreach (string dirPath in Directory.GetDirectories(tempDir)) { string zipPath = Path.Combine(outputDir, Path.GetFileName(dirPath) +".zip"); ZipFile.CreateFromDirectory(dirPath, zipPath); string docxPath = Path.ChangeExtension(zipPath, ".docx"); File.Move(zipPath, docxPath); } } }

[0023] According to an embodiment of the present invention, the step of acquiring the document data to be processed and the target image data, and preprocessing the document data to be processed to obtain the Word document data to be processed, specifically includes: Obtain the document data to be processed, and then unify the document data to be processed into a fixed Word version to obtain the Word document data to be processed. Acquire target image data, including new image data, old image data, or added image data.

[0024] It should be noted that with the updates and version upgrades of office software, document formats have also changed, such as .doc, .docx, or .et. In order to facilitate the operation and processing of unpacked files, it is necessary to first unify the document data to be processed into a fixed Word version. In this embodiment, the fixed Word version is the .docx format. The unified document is marked as the Word document data to be processed. The target image data refers to the image data involved in the Word file operation. The new version image data is the new image data that will be replaced in the Word document, and the old version image data is the image that needs to be replaced. Adding image data refers to the image that needs to be added to the Word document.

[0025] Please refer to Figure 2 , Figure 2 This is a flowchart illustrating the process of obtaining a named document using a Word document image processing method based on file unpacking operations, as provided in this application embodiment. According to this embodiment, the step of storing the Word document data to be processed in a specified storage path and changing the file extension to obtain a named document specifically includes: S21. Store the Word document data to be processed in a specified path and mark it as the input document area; S22. After changing the file extension of the Word document data to a compressed file extension using the preset extension renaming program, a named document is obtained.

[0026] It should be noted that in this embodiment, the storage path of the Word document data to be processed is / input_docs / , and / input_docs / is marked as the input document area. The extension of the Word document data to be processed is changed to .zip using a preset extension renaming program, and then the changed file is recorded as the named document; wherein, the preset extension renaming program is: using System; using System.IO; class Program { static void Main() { string inputDir = " / input_docs / "; foreach (string filePath in Directory.GetFiles(inputDir, "*.docx")) { string newFilePath = Path.ChangeExtension(filePath, ".zip"); File.Move(filePath, newFilePath); } } }

[0027] According to an embodiment of the present invention, the step of decompressing the named document to a temporary directory and obtaining the modified directory through a preset namespace program specifically includes: The named document is decompressed to a temporary directory using a preset namespace program, and a modified directory is obtained, including a media processing module and an XML editing module.

[0028] It should be noted that, in this embodiment, the default namespace program refers to the C# System IO Compression namespace, which decompresses files with the .zip format to a temporary directory, such as / temp_unzip / . After decompression, the document modification directory is obtained, including the media processing module and the XML editing module. The media processing module refers to the image storage directory. The C# System IO Compression namespace program is: using System; using System.IO; using System.IO.Compression; class Program { static void Main() { string inputDir = " / input_docs / "; string tempDir = " / temp_unzip / "; foreach (string zipPath in Directory.GetFiles(inputDir, "*.zip")) { string extractPath = Path.Combine(tempDir, Path.GetFileNameWithoutExtension(zipPath)); ZipFile.ExtractToDirectory(zipPath, extractPath); } } }; The directory structure has been modified as follows: / temp_unzip / handbook1 / ├── word / │├── document.xml# Document content XML file │└── media / # Image storage directory │├── old_logo.png │└── image2.png ├── [Content_Types].xml └── ...Other supporting documents .

[0029] Please refer to Figure 3 , Figure 3 This is a flowchart illustrating a Word document image processing method based on file unpacking operations to obtain updated image data and modify relationship files, as described in some embodiments of this application. According to embodiments of the present invention, obtaining confirmation data for the image processing method, and processing the confirmed data using a preset image processing program to obtain updated image data and modify relationship files, specifically includes: Obtain confirmation data for the image processing method, including replacing image data or adding image data; If the confirmed data is replacement image data, then copy the new image data to the corresponding Word document media resource directory, overwriting the old image data; At the same time, search for the reference relationship data of the old version of the image in the XML editing module and replace it with the new version of the image data; If the confirmed data is new image data, then copy the new image data to the corresponding Word document media resource directory and name it "Update Image Data"; Add a preset XML fragment reference to update image data at the end of the XML editing module, and add a binding relationship to the relationship file to obtain the modified relationship file.

[0030] It should be noted that before editing the Word document, confirmation data for the image processing method must first be obtained. This requires confirmation of whether to replace or add an image, as these are different processing methods. Replacing an image corresponds to replacing the original image, and adding an image corresponds to adding a new image. In this embodiment, the new image data is denoted as new_logo.png. In the media processing module, replacing an image involves copying new_logo.png (the new image data) to the word / media / directory of each document, overwriting the original old_logo.png (the old image data). Adding an image involves copying certification.png (the added image data) to the word / media / directory and naming it image3.png. In the XML editing module, when adding a new image, the following snippet is added to the end of the document: <w:drawing> <wp:inline> <a:graphic> <a:graphicdata uri="http: / / schemas.openxmlformats.org / drawingml / 2006 / picture"> <pic:pic> <pic:blipfill> <a:blip r:embed="rId4" / > <!-- Associated media / image3.png --> < / pic:blipfill> < / pic:pic> < / a:graphicdata> < / a:graphic> < / wp:inline> < / w:drawing> Modify the relationship file: Add a new line in word / _rels / document.xml.rels to bind rId4 to media / image3.png: <relationship Id="rId4" Type="http: / / schemas.openxmlformats.org / officeDocument / 2006 / relationships / image" Target="media / image3.png" / > .

[0031] According to an embodiment of the present invention, the step of testing and verifying the output document through a preset script program and obtaining the corresponding processing method based on the verification result specifically includes: The preset script program checks the media processing module of the output document to confirm whether it contains new or newly added image data. If it is present, open a sample and confirm the image display status; If it is not contained, a warning will be issued.

[0032] It should be noted that, to ensure the success of the operation, the modified file needs to be tested and verified. In this embodiment, the preset script program is: using System; using System.IO; class Program { static void Main() { string outputDir = " / output_docs / "; foreach (string docxPath in Directory.GetFiles(outputDir, "*.docx")) { string tempExtractPath = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(docxPath)); ZipFile.ExtractToDirectory(docxPath, tempExtractPath); string mediaDir = Path.Combine(tempExtractPath, "word", "media"); if (File.Exists(Path.Combine(mediaDir, "new_logo.png"))&&File.Exists(Path.Combine(mediaDir, "image3.png"))) { Console.WriteLine($"Verification successful: {docxPath}"); } else { Console.WriteLine($"Validation failed: {docxPath}"); } Directory.Delete(tempExtractPath, true); } } } If it exists, the temporary directory / temp_unzip / will be cleaned up to free up storage space.

[0033] This invention also discloses a Word document image processing system based on file unpacking operations, including a memory and a processor. The memory stores a Word document image processing method program based on file unpacking operations. When the processor executes the Word document image processing method program based on file unpacking operations, it performs the following steps: Acquire the document data to be processed and the target image data, and preprocess the document data to be processed to obtain the Word document data to be processed; The Word document data to be processed is stored in a specified storage path and the file extension is changed to obtain a named document; The named document is decompressed to a temporary directory using a preset namespace program, and the modified directory is obtained. Obtain confirmation data for the image processing method, and process the image using a preset image processing program based on the confirmation data to obtain updated image data and modified relationship files; The modified directory is recompressed into an updated named document using a preset compression program, and then output after updating the file extension to Word. The output document is tested and verified using a pre-set script, and the corresponding processing method is obtained based on the verification results.

[0034] It should be noted that when editing Word documents, there may be situations where images need to be replaced or added in batches. In such cases, when using the file unpacking method, the format of the Word documents must be standardized. Then, the file extensions of the standardized files should be changed to compressed file extensions. Next, the C# System IO Compression namespace should be used to decompress all files corresponding to the compressed file extensions and store them in a temporary directory. After decompression, each document will generate a media processing module and an XML editing module. Users can directly access or edit these modules. After editing, the files are recompressed and the format restored to obtain the output document. Then, a C# script is used to verify and test the output document. Finally, the modified directory is recompressed into a new named document using a preset compression program, with the extension changed to .docx. The preset compression program is: using System; using System.IO; using System.IO.Compression; class Program { static void Main() { string tempDir = " / temp_unzip / "; string outputDir = " / output_docs / "; foreach (string dirPath in Directory.GetDirectories(tempDir)) { string zipPath = Path.Combine(outputDir, Path.GetFileName(dirPath) +".zip"); ZipFile.CreateFromDirectory(dirPath, zipPath); string docxPath = Path.ChangeExtension(zipPath, ".docx"); File.Move(zipPath, docxPath); } } }

[0035] According to an embodiment of the present invention, the step of acquiring the document data to be processed and the target image data, and preprocessing the document data to be processed to obtain the Word document data to be processed, specifically includes: Obtain the document data to be processed, and then unify the document data to be processed into a fixed Word version to obtain the Word document data to be processed. Acquire target image data, including new image data, old image data, or added image data.

[0036] It should be noted that with the updates and version upgrades of office software, document formats have also changed, such as .doc, .docx, or .et. In order to facilitate the operation and processing of unpacked files, it is necessary to first unify the document data to be processed into a fixed Word version. In this embodiment, the fixed Word version is the .docx format. The unified document is marked as the Word document data to be processed. The target image data refers to the image data involved in the Word file operation. The new version image data is the new image data that will be replaced in the Word document, and the old version image data is the image that needs to be replaced. Adding image data refers to the image that needs to be added to the Word document.

[0037] According to an embodiment of the present invention, the step of storing the Word document data to be processed in a specified storage path and changing the file extension to obtain a named document specifically includes: The Word document data to be processed is stored in a specified path and marked as the input document area; The pre-defined extension renaming program changes the file extension of the Word document data to a compressed file extension to obtain a named document.

[0038] It should be noted that in this embodiment, the storage path of the Word document data to be processed is / input_docs / , and / input_docs / is marked as the input document area. The extension of the Word document data to be processed is changed to .zip using a preset extension renaming program, and then the changed file is recorded as the named document. The preset extension renaming program is... using System; using System.IO; class Program { static void Main() { string inputDir = " / input_docs / "; foreach (string filePath in Directory.GetFiles(inputDir, "*.docx")) { string newFilePath = Path.ChangeExtension(filePath, ".zip"); File.Move(filePath, newFilePath); } } } According to an embodiment of the present invention, the step of decompressing the named document to a temporary directory and obtaining the modified directory through a preset namespace program specifically includes: The named document is decompressed to a temporary directory using a preset namespace program, and a modified directory is obtained, including a media processing module and an XML editing module.

[0039] It should be noted that, in this embodiment, the default namespace program refers to the C# System IO Compression namespace, which decompresses files with the .zip format to a temporary directory, such as / temp_unzip / . After decompression, the document modification directory is obtained, including the media processing module and the XML editing module. The media processing module refers to the image storage directory. The C# System IO Compression namespace program is: using System; using System.IO; using System.IO.Compression; class Program { static void Main() { string inputDir = " / input_docs / "; string tempDir = " / temp_unzip / "; foreach (string zipPath in Directory.GetFiles(inputDir, "*.zip")) { string extractPath = Path.Combine(tempDir, Path.GetFileNameWithoutExtension(zipPath)); ZipFile.ExtractToDirectory(zipPath, extractPath); } } }; The directory structure has been modified as follows: / temp_unzip / handbook1 / ├── word / │├── document.xml# Document content XML file │└── media / # Image storage directory │├── old_logo.png │└── image2.png ├── [Content_Types].xml └── ...Other supporting documents .

[0040] According to an embodiment of the present invention, obtaining confirmation data of the image processing method, and processing the confirmation data through a preset image processing program to obtain updated image data and modified relationship files, specifically includes: Obtain confirmation data for the image processing method, including replacing image data or adding image data; If the confirmed data is replacement image data, then copy the new image data to the corresponding Word document media resource directory, overwriting the old image data; At the same time, search for the reference relationship data of the old version of the image in the XML editing module and replace it with the new version of the image data; If the confirmed data is new image data, then copy the new image data to the corresponding Word document media resource directory and name it "Update Image Data"; Add a preset XML fragment reference to update image data at the end of the XML editing module, and add a binding relationship to the relationship file to obtain the modified relationship file.

[0041] It should be noted that before editing the Word document, confirmation data for the image processing method must first be obtained. This requires confirmation of whether to replace or add an image, as these are different processing methods. Replacing an image corresponds to replacing the original image, and adding an image corresponds to adding a new image. In this embodiment, the new image data is denoted as new_logo.png. In the media processing module, replacing an image involves copying new_logo.png (the new image data) to the word / media / directory of each document, overwriting the original old_logo.png (the old image data). Adding an image involves copying certification.png (the added image data) to the word / media / directory and naming it image3.png. In the XML editing module, when adding a new image, the following snippet is added to the end of the document: <w:drawing> <wp:inline> <a:graphic> <a:graphicdata uri="http: / / schemas.openxmlformats.org / drawingml / 2006 / picture"> <pic:pic> <pic:blipfill> <a:blip r:embed="rId4" / > <!-- Associated with media / image3.png --> < / pic:blipfill> < / pic:pic> < / a:graphicdata> < / a:graphic> < / wp:inline> < / w:drawing> Modify the relationship file: Add a new line in word / _rels / document.xml.rels to bind rId4 to media / image3.png: <relationship Id="rId4" Type="http: / / schemas.openxmlformats.org / officeDocument / 2006 / relationships / image" Target="media / image3.png" / > .

[0042] According to an embodiment of the present invention, the step of testing and verifying the output document through a preset script program and obtaining the corresponding processing method based on the verification result specifically includes: The preset script program checks the media processing module of the output document to confirm whether it contains new or newly added image data. If it is present, open a sample and confirm the image display status; If it is not contained, a warning will be issued.

[0043] It should be noted that, to ensure the success of the operation, the modified file needs to be tested and verified. In this embodiment, the preset script program is: using System; using System.IO; class Program { static void Main() { string outputDir = " / output_docs / "; foreach (string docxPath in Directory.GetFiles(outputDir, "*.docx")) { string tempExtractPath = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(docxPath)); ZipFile.ExtractToDirectory(docxPath, tempExtractPath); string mediaDir = Path.Combine(tempExtractPath, "word", "media"); if (File.Exists(Path.Combine(mediaDir, "new_logo.png"))&&File.Exists(Path.Combine(mediaDir, "image3.png"))) { Console.WriteLine($"Verification successful: {docxPath}"); } else { Console.WriteLine($"Validation failed: {docxPath}"); } Directory.Delete(tempExtractPath, true); } } } If it exists, the temporary directory / temp_unzip / will be cleaned up to free up storage space.

[0044] A third aspect of the present invention provides a readable storage medium comprising a Word document image processing method program based on file unpacking operations, wherein when the Word document image processing method program based on file unpacking operations is executed by a processor, the steps of the Word document image processing method based on file unpacking operations as described in any of the preceding claims are implemented.

[0045] This invention discloses a Word document image processing method, system, and medium based on file unpacking operations. The method involves preprocessing the Word document data to be processed, storing it in a specified storage path, changing the file extension to obtain a named document, decompressing the named document to a temporary directory to obtain a modification directory, obtaining target image data and confirmation data for the image processing method, processing it through a preset image processing program to obtain updated image data and modification relationship files, recompressing the modification directory and updating its extension, and then testing and verifying the output document. Thus, by treating the Word document data as a compressed file, it directly accesses and modifies its internal XML file structure, enabling rapid image replacement and insertion technology within the document.

[0046] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.

[0047] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.

[0048] In addition, in the various embodiments of the present invention, each functional unit can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.

[0049] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0050] Alternatively, if the integrated units of this invention are implemented as software functional modules and sold or used as independent products, they can also be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this invention, or the parts that contribute to the prior art, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.

Claims

1. A Word document image processing method based on file unpacking operations, characterized in that, include: Acquire the document data to be processed and the target image data, and preprocess the document data to be processed to obtain the Word document data to be processed; The Word document data to be processed is stored in a specified storage path and the file extension is changed to obtain a named document; The named document is decompressed to a temporary directory using a preset namespace program, and the modified directory is obtained. Obtain confirmation data for the image processing method, and process the image using a preset image processing program based on the confirmation data to obtain updated image data and modified relationship files; The modified directory is recompressed into an updated named document using a preset compression program, and then output after updating the file extension to Word. The output document is tested and verified using a pre-set script, and the corresponding processing method is obtained based on the verification results.

2. The Word document image processing method based on file unpacking operation according to claim 1, characterized in that, The process of acquiring the document data to be processed and the target image data, and preprocessing the document data to obtain the Word document data to be processed, specifically includes: Obtain the document data to be processed, and then unify the document data to be processed into a fixed Word version to obtain the Word document data to be processed. Acquire target image data, including new image data, old image data, or added image data.

3. The Word document image processing method based on file unpacking operation according to claim 2, characterized in that, The step of storing the Word document data to be processed in a specified storage path and changing the file extension to obtain a named document specifically includes: The Word document data to be processed is stored in a specified path and marked as the input document area; The pre-defined extension renaming program changes the file extension of the Word document data to a compressed file extension to obtain a named document.

4. The Word document image processing method based on file unpacking operation according to claim 3, characterized in that, The step of decompressing the named document to a temporary directory and obtaining the modified directory through a preset namespace program specifically includes: The named document is decompressed to a temporary directory using a preset namespace program, and a modified directory is obtained, including a media processing module and an XML editing module.

5. The Word document image processing method based on file unpacking operation according to claim 4, characterized in that, The process of obtaining confirmation data for the image processing method, and then processing the confirmation data using a preset image processing program to obtain updated image data and modified relationship files, specifically includes: Obtain confirmation data for the image processing method, including replacing image data or adding image data; If the confirmed data is replacement image data, then copy the new image data to the corresponding Word document media resource directory, overwriting the old image data; At the same time, search for the reference relationship data of the old version of the image in the XML editing module and replace it with the new version of the image data; If the confirmed data is new image data, then copy the new image data to the corresponding Word document media resource directory and name it "Update Image Data"; Add a preset XML fragment reference to update image data at the end of the XML editing module, and add a binding relationship to the relationship file to obtain the modified relationship file.

6. The Word document image processing method based on file unpacking operation according to claim 5, characterized in that, The step of testing and verifying the output document through a preset script program, and obtaining the corresponding processing method based on the verification results, specifically includes: The preset script program checks the media processing module of the output document to confirm whether it contains new or newly added image data. If it is present, open a sample and confirm the image display status; If it is not contained, a warning will be issued.

7. A Word document image processing system based on file unpacking operations, characterized in that, The system includes a memory and a processor. The memory includes a Word document image processing method program based on file unpacking operations. When executed by the processor, the Word document image processing method program based on file unpacking operations performs the following steps: Acquire the document data to be processed and the target image data, and preprocess the document data to be processed to obtain the Word document data to be processed; The Word document data to be processed is stored in a specified storage path and the file extension is changed to obtain a named document; The named document is decompressed to a temporary directory using a preset namespace program, and the modified directory is obtained. Obtain confirmation data for the image processing method; based on the confirmation data, process the image using a preset image processing program to obtain updated image data and obtain the modified relationship file. The modified directory is recompressed into an updated named document using a preset compression program, and then output after updating the file extension to Word. The output document is tested and verified using a pre-set script, and the corresponding processing method is obtained based on the verification results.

8. The Word document image processing system based on file unpacking operation according to claim 7, characterized in that, The process of acquiring the document data to be processed and the target image data, and preprocessing the document data to obtain the Word document data to be processed, specifically includes: Obtain the document data to be processed, and then unify the document data to be processed into a fixed Word version to obtain the Word document data to be processed. Acquire target image data, including new image data, old image data, or added image data.

9. The Word document image processing system based on file unpacking operation according to claim 8, characterized in that, The step of storing the Word document data to be processed in a specified storage path and changing the file extension to obtain a named document specifically includes: The Word document data to be processed is stored in a specified path and marked as the input document area; The pre-defined extension renaming program changes the file extension of the Word document data to a compressed file extension to obtain a named document.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a Word document image processing method program based on file unpacking operations. When the Word document image processing method program based on file unpacking operations is executed by a processor, it implements the steps of the Word document image processing method based on file unpacking operations as described in any one of claims 1 to 6.