File dark watermark adding method and device, medium and program product
By modifying and processing different types of file formats, embedding watermark information in non-significant locations of the file, the problem of difficult to balance concealment and robustness when adding watermarks in the prior art is solved, and a file dark watermark addition method with high concealment, robustness and good compatibility is achieved.
Patent Information
- Application Number
- CN202510171185.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-17
- Publication Date
- 2025-05-27
AI Technical Summary
The prior art is difficult to achieve a balance between concealment and robustness when adding file watermarks, which may lead to tampering with the file content or the file format being corrupted, and poor compatibility.
By modifying the file format, such as modifying the suffix of the xlsx, pptx, and docx files of WPS software to be .zip, decompress and add watermark information at a specific location, and then recompress; for other file formats, such as PDF and text files, different technical means are used to add watermarks.
It realizes the high concealment and robustness of watermarks, ensuring that the watermark information can still be extracted and verified after file editing or format conversion, and is suitable for multiple file formats, with good cross-platform compatibility.
Smart Images

Figure CN120046203A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of watermark technology, and particularly to a method, device, medium and program product for adding a hidden watermark to a file. Background Art
[0002] In the digital information age, protecting the integrity of files and verifying the authenticity of files has become increasingly important. In the prior art, digital watermark technology has been widely used in the copyright protection of images and videos. However, for text documents and other types of files, traditional watermark technologies often face the problem of being difficult to achieve a balance between concealment and robustness. The prior art usually achieves watermark protection by inserting visible or semi-visible marks into files, which may lead to the tampering of file content or the destruction of file formats. In addition, existing file watermark technologies may have compatibility problems when applied across platforms, restricting their scope of application.
[0003] Therefore, there is an urgent need to invent a method for adding a hidden watermark to a file to solve the problems that the existing watermark addition methods may cause the tampering of file content or the destruction of file formats and poor compatibility. Summary of the Invention
[0004] In view of this, embodiments of the present invention provide a method, device, medium and program product for adding a hidden watermark to a file, which at least partially solves the problems existing in the prior art.
[0005] Other features and advantages of the present invention will become apparent through the following detailed description, or will be partially learned through the practice of the present invention.
[0006] To achieve the above object, embodiments of the present invention provide the following technical solutions:
[0007] According to a first aspect of an embodiment of the present invention, there is provided a method for adding a hidden watermark to a file, the method comprising:
[0008] Judging the file type of the file to which the watermark is to be added;
[0009] If the file to which the watermark is to be added is an xlsx file, a pptx file or a docx file of the WPS software, modifying the suffix of the file to which the watermark is to be added to.zip to obtain a first compressed file;
[0010] Performing decompression processing on the first compressed file to obtain a first decompressed file;
[0011] In the custom.xml file in the docProps folder in the first decompressed file <properties>New addition within the element <property>Element, set the <property>The value of the element is used as the content of the added text watermark;
[0012] Re-compress the first decompressed file after modification to obtain the hidden watermark file.
[0013] Furthermore, the first decompressed file further includes a _rels folder, a [Content_Types].xml file, and an xl folder;
[0014] The docProps folder further includes an app.xml file and a core.xml file.
[0015] Furthermore, if the file to which the watermark is to be added is a Microsoft Excel file, Microsoft PowerPoint, or Microsoft Word file, then change the suffix of the file to which the watermark is to be added to.zip to obtain a second compressed file;
[0016] Decompress the second compressed file to obtain a second decompressed file. The second decompressed file includes a _rels folder, a [Content_Types].xml file, an xl folder, and a docProps folder. The docProps folder includes an app.xml file and a core.xml file;
[0017] Create a custom.xml file in the docProps folder;
[0018] Add at the root path of the custom.xml file <xml>Element and <properties>Element; in <properties>New addition under the element <xmlns>Element <xmlns:vt>Element and <property>element, set the <property>The value of the element is used as the content of the added text watermark;
[0019] in the.rels file in the _rels folder directory <relationships>Add under the element <relationship>Element;
[0020] the <relationship>The Id attribute of the element is set to rId10;
[0021] Set the said <relationship>Set the Type attribute of the element to http: / / schemas.openxmlformats.org / officeDocument / 2006 / relationships / custom-properties;
[0022] Set the said <relationship>Set the Target attribute of the element to docProps / custom.xml;
[0023] In the <types>Add under the element <override>Element;
[0024] the <override>The PartName attribute of the element is set to / docProps / custom.xml;
[0025] Set the said <override>The ContentType attribute of the element is set to application / vnd.openxmlformats-officedocument.custom-properties+xml;
[0026] Re-compress the modified second decompressed file to obtain a dark watermark file.
[0027] Further, if the file to which the watermark is to be added is a PDF file, use a development tool to read the file to which the watermark is to be added, and use the development tool to add a page with a box type of / MediaBox to the file to which the watermark is to be added;
[0028] In the newly added page, add a custom text watermark by adding the TTFont function, and reference the preset.ttf file to obtain a dark watermark file.
[0029] Further, if watermark extraction is to be performed on a dark watermark file in PDF format, use a development tool to read the dark watermark file in PDF format in the form of a byte stream. The development tools include java, golang, and python.
[0030] Further, if the file to which the watermark is to be added is a text file, perform binary conversion processing on the first text watermark to be added to obtain a second text watermark in binary form;
[0031] Convert the binary character 0 in the second text watermark to the unicode zero-width character u200b, and convert the binary character 1 in the second text watermark to the unicode zero-width character u200c to obtain a third text watermark after conversion;
[0032] Add the entire third text watermark to the end of the text of the file to which the watermark is to be added to obtain a dark watermark file.
[0033] Further, if watermark extraction is to be performed on a dark watermark file in text format, use a development tool to read the dark watermark file and intercept the entire zero-width string composed of u200b characters and u200c characters;
[0034] Convert the u200b characters in the zero-width string to binary character 0, convert the u200c characters in the zero-width string to binary character 1, and then convert the converted binary string to a watermark text.
[0035] According to the second aspect of the embodiments of the present invention, there is provided a device, the device includes: a processor and a memory;
[0036] The memory is used to store one or more program instructions;
[0037] The processor is used to run one or more program instructions to execute the steps of a file invisible watermark adding method as described in any one of the above.
[0038] According to a third aspect of an embodiment of the present invention, there is provided a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of a file invisible watermark adding method as described in any one of the above are implemented.
[0039] According to a fourth aspect of an embodiment of the present invention, there is provided a computer program product, the computer program product includes a computing program stored on a non-transitory computer-readable storage medium, the computer program includes program instructions, and when the program instructions are executed by a computer, the computer is enabled to implement the steps of a file invisible watermark adding method as described in any one of the above.
[0040] A file invisible watermark adding method, device, medium and program product provided by an embodiment of the present invention have the following advantages: concealment, by embedding watermark information in non-significant positions of a file, high concealment of the watermark is achieved and the normal use of the file is not affected. Robustness, the watermark information has strong resistance to changes in file formats and contents, and even after file editing or format conversion, the watermark information can still be extracted and verified. Compatibility, the present invention is applicable to multiple formats such as xlsx / pptx / docx / pdf / text files, and has good cross-platform compatibility. Security, the generated watermark information is unique and difficult to tamper with, enhancing the security and authenticity verification ability of the file. Description of the Drawings
[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only exemplary, and for those of ordinary skill in the art, without creative efforts, other implementation drawings can also be obtained according to the provided drawings.
[0042] Figure 1 It is a schematic flowchart of a method for adding an invisible watermark to a WPS file provided by an embodiment of the present invention;
[0043] Figure 2 It is a schematic flowchart of a method for adding an invisible watermark to a Microsoft file provided by an embodiment of the present invention. Detailed Embodiments
[0044] To enable those skilled in the art to better understand the solution of the present invention, the following will clearly and completely describe the technical solution in the embodiments of the present invention in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0045] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned accompanying drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.
[0046] The embodiment of the present invention provides a method for adding a file invisible watermark, including:
[0047] First, determine the file type of the file to which the watermark is to be added.
[0048] If the file to which the watermark is to be added is an xlsx file, a pptx file, or a docx file of the WPS software, then refer to Figure 1 , Figure 1 The figure shows a flowchart of a method for adding an invisible watermark to a WPS file according to an embodiment of the present invention.
[0049] As Figure 1 shown, the method for adding an invisible watermark to a WPS file according to an embodiment of the present invention may include step S110, step S120, step S130, and step S140.
[0050] In step S110, modify the suffix of the file to which the watermark is to be added to.zip to obtain a first compressed file.
[0051] Then, in step S120, perform decompression processing on the first compressed file to obtain a first decompressed file, where the above-mentioned first decompressed file includes a _rels folder, a [Content_Types].xml file, an xl folder, and a docProps folder.
[0052] In step S130, in the custom.xml file in the docProps folder in the above first decompressed file <properties>New addition within the element <property>Element, set <property>The value of the element is used as the content of the added text watermark.
[0053] In addition, the above-mentioned docProps folder also includes the app.xml file and the core.xml file.
[0054] Finally, in step S140, the modified first decompressed file is recompressed using a compression tool to obtain the steganographic watermark file.
[0055] If the file to which the watermark is to be added is a Microsoft Excel file, Microsoft PowerPoint, or Microsoft Word file, then refer to Figure 2 , Figure 2 The figure shows a flowchart of a method for adding a steganographic watermark to a Microsoft file according to an embodiment of the present invention.
[0056] As Figure 2 shown, the method for adding a steganographic watermark to a Microsoft file according to an embodiment of the present invention may include step S210, step S220, step S230, step S240, step S250, step S260, step S270, step S280, and step S290.
[0057] First, in step S210, the suffix of the file to which the watermark is to be added is modified to.zip to obtain a second compressed file.
[0058] Next, in step S220, the second compressed file is decompressed to obtain a second decompressed file, where the above-mentioned second decompressed file includes a _rels folder, a [Content_Types].xml file, an xl folder, and a docProps folder, and the above-mentioned docProps folder includes an app.xml file and a core.xml file.
[0059] In step S230, a custom.xml file is created under the docProps folder.
[0060] In step S240, at the root path of the newly created custom.xml file, add <xml>Element and <properties>Element; in <properties>Add under the element <xmlns>Element <xmlns:vt>Element and <property>Element, set <property>The value of the element is used as the content of the added text watermark.
[0061] In step S250, in the.rels file in the _rels folder directory <relationships>Add under the element <relationship>Element.
[0062] Next, in step S260, <relationship>The Id attribute of the element is set to rId10; and <relationship>The Type attribute of the element is set to http: / / schemas.openxmlformats.org / officeDocument / 2006 / relationships / custom-properties; and <relationship>The Target attribute of the element is set to docProps / custom.xml.
[0063] In step S270, edit the [Content_Types].xml file. In the [Content_Types].xml file <types>Add under the element <override>Element.
[0064] In step S280, <override>The PartName property of the element is set to / docProps / custom.xml; <override>The ContentType property of the element is set to application / vnd.openxmlformats-officedocument.custom-properties+xml;
[0065] Finally, in step S290, the modified second decompressed file is recompressed using a compression tool to obtain the hidden watermark file.
[0066] If the file to which the watermark is to be added is a PDF file, a development tool is used to read the file to which the watermark is to be added. The languages of the development tool include Java / Golang / Python, etc.
[0067] Then, through the function for adding a page to the PDF file in the development tool, a page with the box type of / MediaBox is added to the file to which the watermark is to be added.
[0068] In the newly added page, the custom text watermark is added using the add TTFont function of the development language, and the preset.ttf file is referenced to obtain the hidden watermark file.
[0069] In addition, if the hidden watermark file in PDF format needs to have its watermark extracted, the development tool is used to read the PDF format hidden watermark file in the form of a byte stream.
[0070] If the file to which the watermark is to be added is a text file, the first text watermark to be added is subjected to binary conversion processing to obtain the second text watermark in binary form.
[0071] Then, the binary character 0 in the second text watermark is converted to the unicode zero-width character u200b, and the binary character 1 in the second text watermark is converted to the unicode zero-width character u200c to obtain the third text watermark after conversion.
[0072] Finally, the third text watermark is added to the end of the text of the file to which the watermark is to be added to obtain the hidden watermark file.
[0073] In addition, if the hidden watermark file in text format needs to have its watermark extracted, the development tool is used to read the hidden watermark file, and the entire zero-width string composed of u200b characters and u200c characters is intercepted; the u200b characters in the zero-width string are converted to binary character 0, the u200c characters in the zero-width string are converted to binary character 1, and then the converted binary string is converted to the watermark text to restore and extract the watermark.
[0074] In addition, an embodiment of the present invention further provides a device, which includes: a processor and a memory; the memory is used to store one or more program instructions; the processor is used to run one or more program instructions to execute the steps of a file invisible watermark adding method as described above.
[0075] In addition, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of a file invisible watermark adding method as described above are implemented.
[0076] In addition, an embodiment of the present invention further provides a computer program product, which includes computer program instructions, and when the computer program instructions are executed by a processor, the steps of a file invisible watermark adding method as described above are implemented.
[0077] The file invisible watermark adding method, device, medium and program product provided by the embodiments of the present invention have the following advantages: Concealment, by embedding watermark information in non-significant positions of the file, high concealment of the watermark is achieved without affecting the normal use of the file. Robustness, the watermark information has strong resistance to changes in file formats and contents, and even after file editing or format conversion, the watermark information can still be extracted and verified. Compatibility, the present invention is applicable to multiple formats such as xlsx / pptx / docx / pdf / text files, and has good cross-platform compatibility. Security, the generated watermark information is unique and difficult to tamper with, enhancing the security and authenticity verification ability of the file.
[0078] In an embodiment of the present invention, the processor may be an integrated circuit chip with signal processing capabilities. The processor may be a general-purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. The general-purpose processor may be a microprocessor, or the processor may also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present invention may be directly embodied as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module may be located in a mature storage medium in the art such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, register, etc. The processor reads the information in the storage medium and combines its hardware to complete the steps of the above method. The storage medium may be a memory, for example, it may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchlink dynamic random access memory (SLDRAM), and direct rambus random access memory (DRRAM).The storage media described in the embodiments of the present invention are intended to include, but are not limited to, these and any other suitable types of memories. Those skilled in the art should be able to realize that in one or more of the above examples, the functions described in the present invention can be implemented by a combination of hardware and software. When applying software, the corresponding functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium. The computer-readable medium includes computer storage media and communication media, where the communication media includes any medium that facilitates the transmission of a computer program from one place to another. The storage media can be any available medium accessible by a general-purpose or special-purpose computer. Although the present invention has been described in detail with general descriptions and specific embodiments above, modifications or improvements can be made to it based on the present invention, which is obvious to those skilled in the art. Therefore, these modifications or improvements made without departing from the spirit of the present invention all fall within the scope of the present invention claimed.
[0079] As described above, it is only the preferred embodiment of the present invention, and there is no limitation in any form to the present invention. Any simple modifications, equivalent changes or decorations made by those skilled in the art using the disclosed technical content all fall within the protection scope of the present invention.< / override> < / override> < / override> < / types> < / relationship> < / relationship> < / relationship> < / relationship> < / relationships> < / property> < / property> < / xmlns:vt> < / xmlns> < / properties> < / properties> < / xml> < / property> < / property> < / properties> < / override> < / override> < / override> < / types> < / relationship> < / relationship> < / relationship> < / relationship> < / relationships> < / property> < / property> < / xmlns:vt> < / xmlns> < / properties> < / properties> < / xml> < / property> < / property> < / properties>
Claims
1. A method for adding a dark watermark to a file, characterized in that: The method comprises: Determine the file type of the file to be watermarked; If the file to be watermarked is an xlsx file, a pptx file or a docx file of the WPS software, the suffix of the file to be watermarked is modified to .zip to obtain a first compressed file; Decompressing the first compressed file to obtain a first decompressed file; In the custom.xml file in the docProps folder in the first unzipped file <properties>Add to element <property>element, set the <property> The value of the element is used as the added text watermark content;< / property> < / property> < / properties> The modified first decompressed file is recompressed to obtain a dark watermark file.
2. A method for adding a dark watermark to a file according to claim 1, characterized in that: The first decompressed file also includes a _rels folder, a [Content_Types].xml file, and an xl folder; The docProps folder also includes an app.xml file and a core.xml file.
3. A method for adding a dark watermark to a file according to claim 1, characterized in that: If the file to be watermarked is a Microsoft Excel file, Microsoft PowerPoint or Microsoft Word file, the suffix of the file to be watermarked is modified to .zip to obtain a second compressed file; Decompressing the second compressed file to obtain a second decompressed file, wherein the second decompressed file includes a _rels folder, a [Content_Types].xml file, an xl folder, and a docProps folder, wherein the docProps folder includes an app.xml file and a core.xml file; Create a custom.xml file in the docProps folder; Add in the root path of the custom.xml file <xml>Elements and <properties>element; in <properties>Add under element <xmlns>element, <xmlns:vt>Elements and <property>element, set the <property> The value of the element is used as the added text watermark content;< / property> < / property> < / xmlns:vt> < / xmlns> < / properties> < / properties> < / xml> In the .rels file in the _rels folder directory <relationships>Add under element <relationship> element;< / relationship> < / relationships> The <relationship> The element's Id attribute is set to rId10;< / relationship> The <relationship> The Type attribute of the element is set to http: / / schemas.openxmlformats.org / officeDocument / 2006 / relationships / custom-properties;< / relationship> The <relationship> The Target attribute of the element is set to docProps / custom.xml;< / relationship> In the [Content_Types].xml file <types>Add under element <override> element;< / override> < / types> The <override> The PartName attribute of the element is set to / docProps / custom.xml;< / override> The <override> The ContentType attribute of the element is set to application / vnd.openxmlformats-officedocument.custom-properties+xml;< / override> The modified second decompressed file is recompressed to obtain a dark watermark file.
4. A method for adding a dark watermark to a file according to claim 1, characterized in that: If the file to be watermarked is a PDF file, the file to be watermarked is read by a development tool, and a page with a box type of / MediaBox is added to the file to be watermarked by the development tool; In the newly added page, add a custom text watermark by adding the TTFont function, reference the preset .ttf file, and get the dark watermark file.
5. A method for adding a dark watermark to a file according to claim 4, characterized in that: If watermark extraction is to be performed on a dark watermark file in PDF format, the dark watermark file in PDF format is read in the form of a byte stream using a development tool, wherein the development tool includes java, golang and python.
6. A method for adding a dark watermark to a file according to claim 1, characterized in that: If the watermark file to be added is a text file, binary conversion is performed on the first text watermark to be added to obtain a second text watermark in binary form; Convert the binary character 0 in the second text watermark into a unicode u200b zero-width character, and convert the binary character 1 in the second text watermark into a unicode u200c zero-width character, to obtain a converted third text watermark; The third text watermark is added as a whole to the end of the text of the file to be watermarked to obtain a dark watermark file.
7. A method for adding a dark watermark to a file according to claim 6, characterized in that: If watermark extraction is to be performed on a dark watermark file in text format, the dark watermark file is read using a development tool, and the entire zero-width string consisting of u200b characters and u200c characters is intercepted; The u200b character in the zero-width character string is converted into a binary character 0, the u200c character in the zero-width character string is converted into a binary character 1, and then the converted binary character string is converted into a watermark text.
8. A device for adding dark watermark to a file, characterized in that: The device comprises: a processor and a memory; The memory is used to store one or more program instructions; The processor is used to run one or more program instructions to execute the steps of a method for adding a dark watermark to a file as described in any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for adding a dark watermark to a file are implemented as described in any one of claims 1 to 7.
10. A computer program product, characterized in that The computer program product comprises computer program instructions, which, when executed by a processor, implement the steps of a method for adding a dark watermark to a file as claimed in any one of claims 1 to 7.
Citation Information
Cited By
Watermark processing method and device for electronic file, medium and product
CN121167689A