Method and apparatus for adding watermarks to contracts
By automatically generating contract numbers and marking information in contract documents, and generating and encrypting the watermarked version of the contract text, the problem of easy contract tampering is solved, and the anti-tampering and security of contracts are achieved.
Patent Information
- Application Number
- CN202410448368.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-15
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2044-04-15
AI Technical Summary
In existing technologies, contract documents are easily tampered with and versions cannot be effectively distinguished, resulting in poor anti-tampering effects.
After the contract documents are reviewed, a contract number and marking information are automatically generated. A watermarked version of the contract text is generated through program design and encrypted. The watermark content is unique and cannot be counterfeited.
It improves the anti-tampering effect of contracts, ensures the security and uniqueness of contract documents, and allows users to see the watermarked version of the text when previewing online, while the downloaded text is watermark-free, thus preventing tampering.
Smart Images

Figure CN118940231B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of information security technology, specifically to a method and apparatus for adding watermarks to contracts. Background Technology
[0002] Contract tampering is a common risk in businesses, and contract information leaks can also cause significant impact or losses. To mitigate these risks, watermarks are typically added to the main text of the contract.
[0003] Watermarking is a means of digital protection. In current technology, most watermarks added to contracts use text or image watermarks. This method of adding watermarks to prevent tampering and information leakage is not very robust. After users download the contract from the application system to their local machine, they can modify the content of the watermarked version of the contract. They can add the same image or text watermark themselves, or create a separate contract text and obtain the watermark style through other means to add it. In this way, it is impossible to distinguish which is the original version and which is the current version. In other words, this method of adding watermarks only replaces text or images and does not actually achieve the effect of preventing tampering. Summary of the Invention
[0004] This invention provides a method and apparatus for adding watermarks to contracts to ensure the uniqueness and authenticity of the contracts.
[0005] Therefore, the present invention provides the following technical solution:
[0006] The method and apparatus for adding watermarks to contracts provided by this invention automatically generate a contract number and marking information after the contract document is reviewed; acquire the contract document and read its main text as a file stream, then write the file stream into a text object; then determine the watermark-related attributes, and insert the contract number and marking information into the text object according to the watermark-related attributes to generate a watermarked version of the contract text. By adding the contract number and marking information, and implementing image watermarking through program design, the watermark content is unique and cannot be counterfeited by other methods, thus improving the anti-tampering effect of the contract compared to existing image watermarking technologies.
[0007] Furthermore, the watermarked version of the contract text is encrypted to generate a watermarked contract file, which effectively restricts the editing of the text and ensures its security.
[0008] Furthermore, when a request to preview the contract online is received, the watermarked version of the contract text is displayed, which will not affect the reading of the contract.
[0009] Furthermore, upon receiving a request to download the contract, the watermark in the watermarked version of the contract file is removed, and the contract text after watermark removal is saved, effectively preventing the original contract text from being tampered with. Attached Figure Description
[0010] Figure 1 This is a flowchart of a method for adding watermarks to contracts provided in an embodiment of the present invention;
[0011] Figure 2 This is another flowchart of the method for adding watermarks to contracts provided in this embodiment of the invention;
[0012] Figure 3 This is an example of the contract text after adding a watermark using the solution of this invention;
[0013] Figure 4 This is a schematic diagram of a device for adding watermarks to contracts provided in an embodiment of the present invention;
[0014] Figure 5 This is a schematic diagram illustrating the process of processing a contract using the device for adding watermarks to a contract provided in an embodiment of the present invention. Detailed Implementation
[0015] To enable those skilled in the art to better understand the embodiments of the present invention, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings and implementation methods.
[0016] This invention provides a method and apparatus for adding watermarks to contracts. After the contract document is reviewed, a contract number and marking information are automatically generated; the contract document is obtained, and the main text of the contract document is read as a file stream and written into a text object; watermark-related attributes are determined; the contract number and marking information are inserted into the text object according to the watermark-related attributes to generate a watermarked version of the contract text, thereby achieving effective protection of the contract text.
[0017] like Figure 1 The diagram shown is a flowchart of a method for adding a watermark to a contract according to an embodiment of the present invention, including the following steps:
[0018] Step 101: After the contract documents are reviewed, the contract number and tag information are automatically generated.
[0019] The contract number can be automatically generated according to predetermined rules. For example, the following contract number generation rules can be used:
[0020] The contracting entity number + contract handling department number + year (two digits) + contract type code + serial number, such as: DQGW-ZH-23-ZL-001.
[0021] Of course, in practical applications, the numbering generation rules can be set according to the actual needs of the user, and this embodiment of the invention does not limit this.
[0022] Step 102: Obtain the contract document, read the text of the contract document as a file stream, and write the file stream into a text object.
[0023] Specifically, the body of the contract document is read as a file stream BufferedInputStream, and the file stream is written into a Document object.
[0024] The Document object is an object within an HTML file. It allows you to inspect, modify, or add content to an HTML document and handle events within that document. On a web page, the Document object can be referenced through the Document property of the Window object, or directly.
[0025] Step 103: Determine the watermark-related attributes.
[0026] For example, you can use the Seal.builder() utility class to set the watermark-related properties one by one.
[0027] The watermark-related attributes include any one or more of the following: size (300), color (Color.LIGHT_GRAY), border circle (e.g., set to line shape: dotted line, width: 140, height: 140), inner border circle (e.g., set to line shape: dotted line, width: 132, height: 132), inner circle (e.g., set to line shape: dotted line, width: 120, height: 120), main text (e.g., the main text content is the contract number, font size 30, spacing 30, interval 20), center text (e.g., the center text content is an empty string, font size 100), header (e.g., the header content is an empty string, font size 22, spacing 10.0, interval 68).
[0028] After setting, call Seal.draw(newFile) to generate a stamp from the watermark content and store it in the ZWSY.jpg file in the specified directory.
[0029] Step 104: Insert the contract number and the marking information into the text object according to the watermark-related attributes to generate the watermarked version of the contract text.
[0030] Specifically, you can call the Aspose technique and pass in the Document object newParagraph(doc) generated in step 103 above, along with the doc object and the watermark format set to image format newShape(doc,ShapeType.IMAGE).
[0031] Then, using the shape operation, set the following information in sequence:
[0032] 1) Watermark image location getImageData().setImage(image)
[0033] 2) Watermark tilt setRotation(0),
[0034] 3) Brightness setBrightness(0.5),
[0035] 4) Contrast setting (0.5)
[0036] 5) Watermark width setWidth(60),
[0037] 6) Watermark height setHeight(230),
[0038] 7) Relative horizontal position
[0039] setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE)、
[0040] 8) Relative vertical position
[0041] setRelativeVerticalPosition(RelativeVerticalPosition.PAGE),
[0042] 9) Vertical text alignment: setVerticalAlignment(VerticalAlignment.CENTER)
[0043] 10) Text horizontal alignment etHorizontalAlignment(HorizontalAlignment.CENTER).
[0044] Then, call watermarkPara.appendChild(shape) to insert the set watermark into the contract text.
[0045] The method for adding watermarks to contracts provided in this embodiment automatically generates a contract number and marking information after the contract document review is completed; it obtains the contract document, reads its main text as a file stream, and writes the file stream into a text object; then it determines the watermark-related attributes, and inserts the contract number and marking information into the text object according to the watermark-related attributes, generating a watermarked version of the contract text. By adding the contract number and marking information, the content of the watermark is enriched. Compared with the fixed image-based watermarking method in the prior art, the automatic generation through program design in this invention improves the anti-tampering effect of the contract.
[0046] like Figure 2 The diagram shown is another flowchart of a method for adding watermarks to contracts according to an embodiment of the present invention, including the following steps:
[0047] Step 201: After the contract documents are reviewed, the contract number and tag information are automatically generated.
[0048] Step 202: Obtain the contract document, read the body of the contract document as a file stream, and write the file stream into a text object.
[0049] Step 203: Determine the watermark-related attributes.
[0050] Step 204: Insert the contract number and the marking information into the text object according to the watermark-related attributes to generate the watermarked version of the contract text.
[0051] It should be noted that, in specific applications, the marking information can be a defined frame, such as a circular frame, a square frame, a diamond frame, etc. Furthermore, the defined frame can be represented by a solid line or a dashed line, and can have one or more layers. This embodiment of the invention does not limit these aspects.
[0052] When inserting the contract number and the tag information, their positions can be set arbitrarily. For example, the contract number can be placed inside or outside the setting box, etc. This embodiment of the invention does not limit this.
[0053] Step 205: Encrypt the watermarked contract text to generate a watermarked contract file.
[0054] For example, the text can be saved as a watermarked version using the corresponding indiDocx control. The saved file is encrypted by the indiDocx control, which restricts the editing of the text.
[0055] Figure 3 An example of a contract text with a watermark added using the present invention is shown.
[0056] The method for adding watermarks to contracts provided in this embodiment effectively restricts the editing of the main text and ensures the security of the main text by encrypting the main text of the watermarked contract.
[0057] Furthermore, to facilitate users' browsing of the contract text, in another non-limiting embodiment of the present invention, it may further include: upon receiving a request to preview the contract online, displaying the watermarked version of the contract text.
[0058] Furthermore, in order to meet the user's need to download the contract, in another non-limiting embodiment of the present invention, it may further include: when receiving a request to download the contract, removing the watermark from the watermarked version of the contract file, and saving the contract text after removing the watermark.
[0059] To prevent the watermarked text from being downloaded via the indiDocx control and then copied and pasted for modification, the watermarked text can be copied during download using API methods:
[0060] indiDocxAttachmentService.copyAttachmentPhysicalByGroupCode(contractInfoEntity.getContractText(),false).
[0061] After copying, the file watermark is removed by calling the Aspose API interface `sect.getHeadersFooters().getByHeaderFooterType(headerType).removeAllChildren()`. After removal, the contract text is saved by calling the contract text save API method.
[0062] As can be seen, by using the solution of this invention, users can only download the watermark-free version of the contract text, while the text opened in the online preview is the watermarked version. This not only facilitates users' reading and downloading of the contract, but also effectively ensures that the contract text will not be tampered with.
[0063] Accordingly, embodiments of the present invention also provide an apparatus for adding watermarks to contracts, such as... Figure 4 The diagram shown is a structural schematic of the device.
[0064] The device 400 for adding watermarks to contracts in this embodiment includes the following modules:
[0065] The information generation module 401 is used to automatically generate contract numbers and tag information after the contract documents have been reviewed.
[0066] The file reading module 402 is used to obtain the contract file, read the text of the contract file as a file stream, and write the file stream into a text object;
[0067] Watermark setting module 403 is used to determine watermark-related attributes;
[0068] The watermark insertion module 404 is used to insert the contract number and the marking information into the text object according to the watermark-related attributes, thereby generating a watermarked version of the contract text.
[0069] The watermark-related attributes and insertion methods can be referred to the description in the previous embodiments of the present invention, and will not be repeated here.
[0070] In another non-limiting embodiment, the device 400 for adding a watermark to the contract may further include: a storage module (not shown) for encrypting the watermarked contract text to generate a watermarked contract file.
[0071] By encrypting the main text of the watermarked contract, a watermarked contract file is generated, effectively restricting the editing of the main text and ensuring its security.
[0072] In another non-limiting embodiment, the device 400 for adding a watermark to the contract may further include: a preview module and / or a download module (not shown). Wherein:
[0073] The preview module is used to display the watermarked version of the contract text when an online preview request is received.
[0074] The download module is used to remove the watermark from the watermarked version of the contract file when it receives a request to download the contract; and save the contract text after the watermark is removed.
[0075] This better meets users' needs for previewing and downloading contracts, and effectively ensures that the main text of the contract will not be tampered with.
[0076] Reference Figure 5 , Figure 5 An example flow is shown for processing a contract using the watermarking apparatus provided in an embodiment of the present invention.
[0077] like Figure 5 As shown, after the contract approval is completed, the Aspose plugin automatically generates a contract number according to the rules and a dashed circle according to the background algorithm.
[0078] Read the main text of the contract, automatically insert the contract number and a dotted circle into the main text, and generate a watermarked version of the contract text.
[0079] Then, the watermarked version of the contract text is encrypted. Specifically, the contract text can be previewed using the application platform's text control and saved as a watermarked contract file.
[0080] When users need to view the contract, they can browse it using the application platform's text control, which displays a watermarked version of the contract.
[0081] When a user needs to download a contract, the application platform's text control is used for downloading. The downloaded contract text is the watermark-free version. Consequently, users can edit the text, but they cannot download the watermark, thus preventing tampering with the watermarked contract and ensuring its security.
[0082] It should be noted that the terms "comprising" and "having" and any variations thereof in the specification, claims and accompanying drawings of this invention are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such processes, methods, products or devices.
[0083] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on its differences from other embodiments. Furthermore, the system embodiments described above are merely illustrative. The modules and units described as separate components may or may not be physically separate; that is, they may be located on a single network unit or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0084] The embodiments of the present invention have been described in detail above. Specific implementation methods have been used to illustrate the present invention. The descriptions of the embodiments above are only for the purpose of helping to understand the methods and systems of the present invention, and are merely some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention, and the content of this specification should not be construed as a limitation of the present invention. Therefore, any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for adding watermarks to contracts, characterized in that, The method includes: After the contract documents are reviewed, a contract number and tagging information are automatically generated; The contract document is obtained, and the body of the contract document is read as a file stream. The file stream is written into a text object. The text object is used to check, modify, or add content to the HTML document, and the events inside the HTML document are handled. Determine the watermark-related attributes; According to the watermark-related attributes, the contract number and the marking information are inserted into the text object. The indiDocx control saves the text as a watermarked version file, generating a watermarked version of the contract text. The saved file is encrypted by the indiDocx control to restrict editing of the text. The method further includes: Upon receiving a request to preview the contract online, the watermarked version of the contract text is displayed; and Upon receiving a contract download request, the watermarked text is copied via API during the download process. After copying, the watermark is removed by calling the API interface, and the watermark-free contract text is saved.
2. The method according to claim 1, characterized in that, The marked information is a setting box.
3. The method according to claim 2, characterized in that, The setting frame is one or more circular rings.
4. The method according to claim 3, characterized in that The watermark-related attributes include any one or more of the following: watermark size, color, edge circle, inner edge circle, inner line circle, main text, center text, header; the main text includes the contract number, and any one or more of the following information: the font size, spacing, and interval of the contract number.
5. The method according to claim 4, characterized in that, The central character and / or the header is an empty string.
6. The method according to any one of claims 1 to 5, characterized in that, The method further includes: The watermarked contract text is encrypted to generate a watermarked contract file.
7. An apparatus for adding watermarks to contracts, characterized in that, The device includes: The information generation module is used to automatically generate contract numbers and tagging information after the contract documents have been reviewed. The file reading module is used to obtain the contract file, read the body of the contract file as a file stream, write the file stream into a text object, use the text object to check, modify or add content to the HTML document, and handle events within the HTML document. The watermark settings module is used to determine watermark-related attributes; The watermark insertion module is used to insert the contract number and the marking information into the text object according to the watermark-related attributes. The indiDocx control saves the main text as a watermarked version file, generating a watermarked version of the contract text. The saved file is encrypted by the indiDocx control to restrict the editing of the main text. The device further includes: a preview module and a download module; The preview module is used to display the watermarked version of the contract text when an online preview contract request is received; The download module is used to copy the watermarked text during download by means of an API method when a download contract request is received. After copying, the watermark is removed by calling the API interface, and the watermark-removed contract text is saved.
8. The apparatus according to claim 7, characterized in that, The device further includes: The storage module is used to encrypt the watermarked contract text and generate a watermarked contract file.
Citation Information
Patent Citations
Management method and device for electronic contracts, equipment and medium
CN110991991A