Text document processing method and device, storage medium, and electronic device
By adding gradient or irregular color document watermarks to the document, the problem that document watermarks are easily removed in the prior art is solved, and the security of the document is improved.
Patent Information
- Application Number
- CN202211649071.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-21
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2042-12-21
AI Technical Summary
In the prior art, document watermarks are easily removed, resulting in lower document security.
By obtaining text documents in image format, determine the document watermark to be added, including the watermark content and watermark direction, and add a document watermark at the target position of the document, so that the color of the document watermark is gradient or irregular, which is difficult to clear.
It effectively improves the security of documents, makes it difficult to clear the document watermark, and avoids knowledge leakage.
Smart Images

Figure CN116109465B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of knowledge management, and in particular to a text document processing method and device, a storage medium, and an electronic device. Background Art
[0002] In the process of building and operating the knowledge management platform, how to balance the strength of intellectual property protection and the convenience of knowledge acquisition has become a difficult problem that is difficult to solve perfectly. If the method of grouping users and setting corresponding permissions is adopted, this method is more suitable for small enterprises, but for large enterprises it will generate a lot of workload and will seriously affect the convenience of knowledge acquisition; if users are not grouped and the corresponding permissions are not set, it may lead to corporate knowledge leakage.
[0003] Therefore, relevant technical personnel usually use digital watermark technology to mark documents on the knowledge management platform to prevent corporate knowledge leakage, and save them in the form of scanned copies. The file types can be divided into PDF (Portable Document Format) and images. Among them, for PDF documents, users can easily remove the watermark in the document on the corresponding software; for image documents, users can obtain the RGB value of the watermark image through the image, and modify it to the background color of the document, so as to easily remove the watermark information, making it easy to leak important files in corporate knowledge.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present application provide a text document processing method and device, a storage medium, and an electronic device to at least solve the technical problem that the document watermark generated by the related technology is easy to remove, resulting in low document security.
[0006] According to one aspect of an embodiment of the present application, a text document processing method is provided, including: obtaining a first text document in image format; determining a document watermark to be added, wherein the document watermark information includes: watermark content and watermark direction; adding a document watermark at a target position of each page of the image file in the first text document to obtain a target text document, wherein the target color of each pixel corresponding to the document watermark is any color within a first target color range.
[0007] Optionally, obtaining a first text document in image format includes: obtaining a text document to be processed, and determining the document type of the text document to be processed, wherein the document type includes: image format and PDF format; when the document type of the text document to be processed is PDF format, converting the text document to be processed into a first text document in image format; when the document type of the text document to be processed is image format, determining that the text document to be processed is the first text document.
[0008] Optionally, determining the document watermark to be added includes: setting the watermark content and watermark direction of each page of the image file in the first text document according to a preset watermark rule.
[0009] Optionally, a document watermark is added at a target position of each page of the image file in the first text document to obtain a target text document, including: for each page of the image file in the first text document, each pixel at the target position is scanned in turn, and a target color of the pixel is determined; when the target color is white, the target color of the pixel is adjusted to any color within the first target color range to obtain a document watermark, and the document watermark is added at the target position to obtain a target text document; when the target color is black, the target color of the pixel is maintained to obtain a document watermark, and the document watermark is added at the target position to obtain a target text document.
[0010] Optionally, when the target color is white, determining to adjust the target color of the pixel to any color within a first target color range to obtain a document watermark, and adding the document watermark at the target position to obtain a target text document includes: when the RGB value of the pixel is equal to a first value, determining the target color to be white; adjusting the target color of each pixel at the target position to any color within the first target color range to obtain a document watermark, and adding the document watermark at the target position to obtain a target text document; or, setting the target color of each pixel at the target position to a color within the first target color range in turn to obtain a document watermark, and adding the document watermark at the target position to obtain a target text document.
[0011] Optionally, when the target color is black, the target color of the pixel is maintained to obtain a document watermark, and the document watermark is added at the target position to obtain a target text document, including: when the RGB value of the pixel is equal to a second value, determining that the target color is black; maintaining the target color of the pixel to obtain a document watermark, and adding the document watermark at the target position to obtain a target text document.
[0012] Optionally, when the target color is black, the target color of each pixel corresponding to the document information content at the target position is adjusted to any color within the second target color range to obtain the target text document; or, the target color of each pixel corresponding to the document information content at the target position is set to a color within the second target color range in sequence to obtain the target text document.
[0013] According to another aspect of an embodiment of the present application, a text document processing device is also provided, including: an acquisition module, used to acquire a first text document in image format; a determination module, used to determine a document watermark to be added, wherein the document watermark information includes: watermark content and watermark position; a generation module, used to add a document watermark at a target position of each page of the image file in the first text document to obtain a target text document, wherein the target color of each pixel corresponding to the document watermark is any color within a first target color range.
[0014] According to another aspect of an embodiment of the present application, a non-volatile storage medium is further provided, the non-volatile storage medium including a stored program, wherein the device where the non-volatile storage medium is located executes the above-mentioned text document processing method by running the program.
[0015] According to another aspect of an embodiment of the present application, an electronic device is further provided, the electronic device comprising: a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to execute the above-mentioned text document processing method through the computer program.
[0016] In the embodiment of the present application, a first text document in image format is obtained; a document watermark to be added is determined, wherein the document watermark information includes: watermark content and watermark direction; a document watermark is added at a target position of each page of the image file in the first text document to obtain a target text document, wherein the target color of each pixel corresponding to the document watermark is any color within the first target color range. Thus, the document watermark is set to a gradient color or an irregular color, making it difficult to remove the document watermark, thereby solving the technical problem that the document watermark generated by the related technology is easy to remove, resulting in low document security. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0018] Figure 1 is a schematic diagram of an optional text watermark in the related art;
[0019] Figure 2is a flowchart of an optional text document processing method according to an embodiment of the present application;
[0020] Figure 3 It is a structural schematic diagram of an optional text document processing device according to an embodiment of the present application. DETAILED DESCRIPTION
[0021] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0022] It should be noted that the terms "first", "second", etc. in the specification, claims and drawings of the present application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0023] In order to better understand the embodiments of the present application, some nouns or terms that appear in the description of the embodiments of the present application are first translated and explained as follows:
[0024] RGB value: RGB refers to the three primary optical colors, namely red, green and blue, and the RGB value specifically reflects the brightness (i.e., intensity value), which is usually represented by integers from 0 to 255, where 255 corresponds to the maximum brightness and 0 corresponds to the minimum brightness. Therefore, R, G, and B each have 256 levels of brightness.
[0025] Example 1
[0026] Enterprises or organizations need to protect confidential documents with high commercial value, such as business contracts, agreement documents, and internal personnel qualification documents, to avoid malicious leakage of the enterprise or organization's knowledge management platform.
[0027] Currently, the commonly used method is to mark documents with data watermark technology to distinguish between document users and those responsible for illegal distribution, so as to hold those responsible for illegal distribution accountable afterwards. However, since such watermarked documents are usually saved in the form of scanned copies, their file types are usually divided into two categories, PDF format and image format.
[0028] For documents in PDF format, you can use PDF readers, such as Acrobat Reader and Foxit Reader, to add watermarks to PDF documents, but users can also use the same software, or advanced versions of the same brand, to remove document watermarks from PDF documents. Alternatively, insert a large number of text boxes into the PDF document, enter the watermark text information in the text boxes, and save it, but this method only works for Acrobat Reader and Foxit Reader without editing permissions. Otherwise, relevant personnel with editing permissions can still easily remove watermarks through these PDF reader software. For documents in image format, you can use image editing software to create a watermark. Figure 1 The watermark image shown. However, since the watermark color and the document background color are clearly distinguished, the user can obtain the RGB value of the watermark image through the image file and modify it to the document background color, thereby easily removing the watermark information.
[0029] Therefore, the document watermark generated by the related technology is easy to remove, resulting in low document security.
[0030] In order to solve the above problems, an embodiment of the present application provides a text document processing method, which makes it difficult to remove the document watermark by setting the document watermark to a gradient color or an irregular color.
[0031] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0032] Figure 2 is a flowchart of an optional text document processing method according to an embodiment of the present application, such as Figure 2 As shown, the method at least includes steps S202-S206, wherein:
[0033] Step S202: Acquire a first text document in image format.
[0034] In the technical solution provided in the above step S202 of the present invention, the first text document in image format can be a scanned copy of a text document such as a commercial contract, company qualifications, agreement contract, etc., wherein the image format can be but is not limited to JPG image or PNG image, etc., and no specific limitation is made here.
[0035] Step S204: determine the document watermark to be added, wherein the document watermark information includes: watermark content and watermark position.
[0036] In the technical solution provided in the above step S204 of the present invention, the document watermark to be added is used to write the ownership information or the downloader's information into the document without affecting the reading of the document, so as to protect the copyright of the document and avoid the leakage of the document due to secondary forwarding. In addition, the watermark position is preferably set at a key position in the document content information, such as signature, amount, time, etc., so as to ensure the protection of key information.
[0037] Step S206, adding a document watermark at a target position of each page of the image file in the first text document to obtain a target text document, wherein the color of each pixel corresponding to the document watermark is any color within the first target color range.
[0038] In the technical solution provided in the above step S206 of the present invention, the color of each pixel corresponding to the document watermark can be set to any color within the first target color range, wherein the first target color needs to be distinguished from the document background (i.e., white), thereby preventing the user from obtaining the RGB value of the watermark image from the image file and modifying the RGB value to the document background color, which causes the user to easily remove the document watermark.
[0039] In the embodiment of the present application, a first text document in image format is obtained; a document watermark to be added is determined, wherein the document watermark information includes: watermark content and watermark direction; a document watermark is added at a target position of each page of the image file in the first text document to obtain a target text document, wherein the color of each pixel corresponding to the document watermark is any color within the first target color range. Thus, the document watermark is set to a gradient color or an irregular color, making it difficult to remove the document watermark, thereby solving the technical problem that the document watermark generated by the related technology is easy to remove, resulting in low document security.
[0040] The specific implementation steps of this embodiment are described in detail below.
[0041] As an optional implementation, in the technical solution provided in the above step S202 of the present invention, the method includes: obtaining a text document to be processed, and determining the document type of the text document to be processed, wherein the document type includes: image format and PDF format; when the document type of the text document to be processed is PDF format, converting the text document to be processed into a first text document in image format; when the document type of the text document to be processed is image format, determining that the text document to be processed is a first text document.
[0042] In this embodiment, since the text document is usually saved as a scanned copy in PDF format or a scanned copy in image format after adding a document watermark, when processing the text document, a software package such as Python's PyMuPDF package can be used to convert the PDF format text document into an image format text document first, so as to facilitate the subsequent adding of a document watermark to the image format text document.
[0043] For example, when a user sends a download request for text document one to the enterprise's knowledge management platform, the knowledge management platform can identify the text document information in text document one and determine whether text document one is in PDF format or image format. If text document one is in PDF format, Python's PyMuPDF package is used to convert each page of text document one into an image file, thereby obtaining text document one in image format.
[0044] As an optional implementation, in the technical solution provided in the above step S204 of the present invention, the method includes: determining the document watermark to be added, including: setting the watermark content and watermark direction of each page of the image file in the first text document according to a preset watermark rule.
[0045] In this embodiment, the watermark rule can be used to set the location and content of the document watermark within each page of the image file, and the watermark content can be set to copyright ownership information or downloader information according to actual needs. For example, when a user needs to download the text document, in order to distinguish the user of the text document and the person responsible for illegally distributing the text document, the watermark content of the text document can be set to the downloader's name and other related attribute information; when an individual text document needs to be uploaded to a public platform such as a web page, in order to prevent it from being stolen by others, the watermark content of the text document can be set to the owner's name and other related attribute information.
[0046] For example, when a user sends a download request for a text document to the enterprise's knowledge management platform, information that uniquely identifies the document downloader can be obtained. The information contains information that can uniquely identify the document downloader, such as the name, ID, mobile phone number, download time, etc. The knowledge management platform can use this information to generate a corresponding document watermark, such as: Zhang San 001587 15313033316 2022-05-26 00:12:25, to mark the document downloader, so that when an accident such as a document leak occurs, the person responsible for the illegal distribution can be held accountable afterwards.
[0047] As an optional implementation, in the technical solution provided in the above step S206 of the present invention, the method includes: for each page of the image file in the first text document, scanning each pixel at the target position in turn, and determining the color of the pixel; when the target color is white, determining to adjust the target color of the pixel to any color within the first target color range to obtain a document watermark, and adding the document watermark at the target position to obtain a target text document; when the target color is black, maintaining the target color of the pixel to obtain a document watermark, and adding the document watermark at the target position to obtain a target text document.
[0048] In this embodiment, in order to prevent the user from easily removing the document watermark processed at the target position, the color of each pixel is scanned in sequence. When the color of the pixel is white, that is, the RGB value is RGB (255, 255, 255), it means that the pixel corresponds to the document background. At this time, it is determined to adjust the target color of the pixel to any color within the first target color range to obtain the document watermark, and add the document watermark at the target position to obtain the target text document; when the color of the pixel is black, that is, the RGB value is RGB (0, 0, 0), it means that the pixel corresponds to the document content information. At this time, in order to prevent the document watermark from covering the document content information and affecting the user's viewing, the color of the document watermark is not changed, and the document watermark of the target color continues to be added at this position to obtain the target text document.
[0049] As an optional implementation, in the technical solution provided in the above step S206 of the present invention, the method also includes: when the RGB value of the pixel point is equal to the first value, determining that the target color is white; adjusting the target color of each pixel point at the target position to any color within the first target color range to obtain a document watermark, and adding the document watermark at the target position to obtain a target text document; or, setting the target color of each pixel point at the target position to a color within the first target color range in turn to obtain a document watermark, and adding the document watermark at the target position to obtain a target text document.
[0050] In this embodiment, when the RGB value of the pixel is equal to RGB (255, 255, 255), the target color is determined to be white, and the target color of each pixel at the target position is randomly set to any color within the first target color range, or the target color of each pixel at the target position is sequentially set to a color within the first target color range, so that the document watermark color is irregularly set and gradually set, so that the document watermark is no longer single, and it is prevented that others can easily remove the document watermark by setting the RGB value of the watermark to the RGB value of the document background color. Among them, the first target color range can be any color from RGB (90, 90, 90) to RGB (255, 255, 255).
[0051] For example, you can Figure 2 The color of the document watermark "Confidential" in the image file shown is set to any color within the first target color range corresponding to RGB (90, 90, 90) to RGB (255, 255, 255), making it difficult for the watermark removal software to distinguish between the document information content and the document watermark information. You can also cyclically use each color within the first target color range corresponding to RGB (90, 90, 90) to RGB (255, 255, 255) to set the color of the document watermark "Confidential" in the image file.
[0052] As an optional implementation, in the technical solution provided in the above step S206 of the present invention, the method also includes: when the RGB value of the pixel point is equal to the second value, determining that the target color is black; maintaining the target color of the pixel point to obtain a document watermark, and adding the document watermark at the target position to obtain a target text document.
[0053] In this embodiment, when the RGB value of a pixel is equal to RGB (0, 0, 0), the target color is determined to be black. This indicates that the pixel is a pixel corresponding to the document information content. In order to avoid watermarks of different colors from obscuring the document information content, the target color of the pixel is maintained to obtain a document watermark.
[0054] Furthermore, in order to prevent users from distinguishing between the document content and the document background color of the same black background, the embodiments of the present application also adjust the target color of each pixel corresponding to the document information content at the target position to any color within the second target color range when the target color is black, to obtain the target text document; or, set the target color of each pixel corresponding to the document information content at the target position to a color within the second target color range in turn, to obtain the target text document.
[0055] For example, for the original document content information, the target color of each pixel corresponding to the document information content at the target position can be adjusted to any gray within the second target color range corresponding to RGB (10, 10, 10) to RGB (110, 110, 110), or each color within the second target color range corresponding to RGB (10, 10, 10) to RGB (110, 110, 110) can be cyclically used to set the color of the document information content in the image file.
[0056] In an embodiment of the present application, by setting the color of a document watermark added to a text document to any color within a first target color range, or by setting the color of a document watermark added to a text document to colors within the first target color range in sequence, an irregular distribution or a gradient distribution of the document watermark color is achieved, thereby making it possible to distinguish between the document background color and the document watermark color; in addition, by setting the color of the document information content in the text document to any color within a second target color range, or by setting the color of the document information content in the text document to colors within the second target color range in sequence, an irregular distribution or a gradient distribution of the document information content color is achieved, thereby making it possible to distinguish between the document background color and the document information content color, thereby solving the technical problem that the document watermark generated by the related technology is easy to remove, resulting in low document security.
[0057] Example 2
[0058] According to an embodiment of the present application, a text document processing device for implementing the above-mentioned text document processing method is also provided. Figure 3 is a schematic diagram of the structure of an optional text document processing device according to an embodiment of the present application, such as Figure 3 As shown, the text document processing device at least includes an acquisition module 31, a determination module 32 and a generation module 33, wherein:
[0059] The acquisition module 31 is used to acquire a first text document in image format.
[0060] As an optional implementation, the acquisition module 31 can acquire the first text document in image format in the following manner: acquire the text document to be processed, and determine the document type of the text document to be processed, where the document type includes: image format and PDF format; when the document type of the text document to be processed is PDF format, convert the text document to be processed into a first text document in image format; when the document type of the text document to be processed is image format, determine that the text document to be processed is the first text document.
[0061] Since text documents are usually saved as scanned copies in PDF format or image format after adding document watermarks, when processing text documents, you can use Python's PyMuPDF package and other software packages to convert PDF format text documents into image format text documents first, so as to facilitate the subsequent addition of document watermarks to image format text documents.
[0062] For example, when a user sends a download request for text document one to the enterprise's knowledge management platform, the knowledge management platform can identify the text document information in text document one and determine whether text document one is in PDF format or image format. If text document one is in PDF format, Python's PyMuPDF package is used to convert each page of text document one into an image file, thereby obtaining text document one in image format.
[0063] The determination module 32 is used to determine the document watermark to be added, wherein the document watermark information includes: watermark content and watermark position.
[0064] As an optional implementation, the determination module 32 may determine the document watermark to be added in the following manner: Determining the document watermark to be added includes: setting the watermark content and watermark direction of each page of the image file in the first text document according to a preset watermark rule.
[0065] The watermark rules can set the location and content of the document watermark within each page of the image file. The watermark content can be set to copyright ownership information or downloader information according to actual needs. For example, when a user needs to download the text document, in order to distinguish the user of the text document and the person responsible for illegally distributing the text document, the watermark content of the text document can be set to the downloader's name and other related attribute information; when an individual text document needs to be uploaded to a public platform such as a web page, in order to prevent it from being stolen by others, the watermark content of the text document can be set to the owner's name and other related attribute information.
[0066] For example, when a user sends a download request for a text document to the enterprise's knowledge management platform, information that uniquely identifies the document downloader can be obtained. The information contains information that can uniquely identify the document downloader, such as the name, ID, mobile phone number, download time, etc. The knowledge management platform can use this information to generate a corresponding document watermark, such as: Zhang San 001587 15313033316 2022-05-26 00:12:25, to mark the document downloader, so that when an accident such as a document leak occurs, the person responsible for the illegal distribution can be held accountable afterwards.
[0067] The generating module 33 is used to add a document watermark at a target position of each page of the image file in the first text document to obtain a target text document, wherein the target color of each pixel point corresponding to the document watermark is any color within the first target color range.
[0068] As an optional implementation, the generation module 33 can obtain the target text document in the following manner: for each page of the image file in the first text document, scan each pixel at the target position in turn and determine the color of the pixel; when the target color is white, determine to adjust the target color of the pixel to any color within the first target color range to obtain a document watermark, and add the document watermark at the target position to obtain the target text document; when the target color is black, maintain the target color of the pixel to obtain a document watermark, and add the document watermark at the target position to obtain the target text document.
[0069] In order to prevent users from easily removing the document watermark processed at the target position, choose to scan the color of each pixel in turn. When the color of the pixel is white, that is, the RGB value is RGB (255, 255, 255), it means that the pixel corresponds to the document background. At this time, it is determined to adjust the target color of the pixel to any color within the first target color range to obtain the document watermark, and add the document watermark at the target position to obtain the target text document; when the color of the pixel is black, that is, the RGB value is RGB (0, 0, 0), it means that the pixel corresponds to the document content information. At this time, in order to prevent the document watermark from covering the document content information and affecting the user's viewing, the color of the document watermark is not changed, and the document watermark of the target color continues to be added at this position to obtain the target text document.
[0070] Optionally, when the RGB value of the pixel point is equal to the first value, the target color is determined to be white; the target color of each pixel point at the target position is adjusted to any color within the first target color range to obtain a document watermark, and the document watermark is added at the target position to obtain a target text document; or, the target color of each pixel point at the target position is set to a color within the first target color range in turn to obtain a document watermark, and the document watermark is added at the target position to obtain a target text document.
[0071] In this embodiment, when the RGB value of the pixel is equal to RGB (255, 255, 255), the target color is determined to be white, and the target color of each pixel at the target position is randomly set to any color within the first target color range, or the target color of each pixel at the target position is sequentially set to a color within the first target color range, so that the document watermark color is irregularly set and gradually set, so that the document watermark is no longer single, and it is prevented that others can easily remove the document watermark by setting the RGB value of the watermark to the RGB value of the document background color. Among them, the first target color range can be any color from RGB (90, 90, 90) to RGB (255, 255, 255).
[0072] Optionally, when the RGB value of the pixel is equal to the second value, the target color is determined to be black; the target color of the pixel is maintained to obtain a document watermark, and the document watermark is added at the target position to obtain a target text document.
[0073] In this embodiment, when the RGB value of a pixel is equal to RGB (0, 0, 0), the target color is determined to be black. This indicates that the pixel is a pixel corresponding to the document information content. In order to avoid watermarks of different colors from obscuring the document information content, the target color of the pixel is maintained to obtain a document watermark.
[0074] Furthermore, in order to prevent users from distinguishing between the document content and the document background color of the same black background, the embodiments of the present application also adjust the target color of each pixel corresponding to the document information content at the target position to any color within the second target color range when the target color is black, to obtain the target text document; or, set the target color of each pixel corresponding to the document information content at the target position to a color within the second target color range in turn, to obtain the target text document.
[0075] For example, for the original document content information, the target color of each pixel corresponding to the document information content at the target position can be adjusted to any gray within the second target color range corresponding to RGB (10, 10, 10) to RGB (110, 110, 110), or each color within the second target color range corresponding to RGB (10, 10, 10) to RGB (110, 110, 110) can be cyclically used to set the color of the document information content in the image file.
[0076] It should be noted that each module in the text document processing device in the embodiment of the present application corresponds one-to-one to each implementation step of the text document processing method in Example 1. Since a detailed description has been given in Example 1, some details not reflected in this embodiment can be referred to Example 1 and will not be repeated here.
[0077] Example 3
[0078] According to an embodiment of the present application, a non-volatile storage medium is also provided, which includes a stored program, wherein the device where the non-volatile storage medium is located executes the text document processing method in Example 1 by running the program.
[0079] Specifically, the device where the non-volatile storage medium is located implements the following steps by running the program: obtaining a first text document in image format; determining a document watermark to be added, wherein the document watermark information includes: watermark content and watermark direction; adding a document watermark at a target position of each page of the image file in the first text document to obtain a target text document, wherein the target color of each pixel corresponding to the document watermark is any color within a first target color range.
[0080] Optionally, when the target color is white, determining to adjust the target color of the pixel to any color within a first target color range to obtain a document watermark, and adding the document watermark at the target position to obtain a target text document includes: when the RGB value of the pixel is equal to a first value, determining the target color to be white; adjusting the target color of each pixel at the target position to any color within the first target color range to obtain a document watermark, and adding the document watermark at the target position to obtain a target text document; or, setting the target color of each pixel at the target position to a color within the first target color range in turn to obtain a document watermark, and adding the document watermark at the target position to obtain a target text document.
[0081] Optionally, when the target color is black, the target color of each pixel corresponding to the document information content at the target position is adjusted to any color within the second target color range to obtain the target text document; or, the target color of each pixel corresponding to the document information content at the target position is set to a color within the second target color range in sequence to obtain the target text document.
[0082] According to an embodiment of the present application, a processor is also provided, which is used to run a program, wherein the text document processing method in Example 1 is executed when the program is running.
[0083] Specifically, when the program is running, the following steps are executed: obtaining a first text document in image format; determining a document watermark to be added, wherein the document watermark information includes: watermark content and watermark direction; adding a document watermark at a target position of each page of the image file in the first text document to obtain a target text document, wherein the target color of each pixel corresponding to the document watermark is any color within the first target color range.
[0084] Optionally, when the target color is white, determining to adjust the target color of the pixel to any color within a first target color range to obtain a document watermark, and adding the document watermark at the target position to obtain a target text document includes: when the RGB value of the pixel is equal to a first value, determining the target color to be white; adjusting the target color of each pixel at the target position to any color within the first target color range to obtain a document watermark, and adding the document watermark at the target position to obtain a target text document; or, setting the target color of each pixel at the target position to a color within the first target color range in turn to obtain a document watermark, and adding the document watermark at the target position to obtain a target text document.
[0085] Optionally, when the target color is black, the target color of each pixel corresponding to the document information content at the target position is adjusted to any color within the second target color range to obtain the target text document; or, the target color of each pixel corresponding to the document information content at the target position is set to a color within the second target color range in sequence to obtain the target text document.
[0086] According to an embodiment of the present application, an electronic device is also provided, which includes: a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to execute the text document processing method in Example 1 through the computer program.
[0087] Specifically, the processor is configured to execute the following steps through a computer program: obtaining a first text document in image format; determining a document watermark to be added, wherein the document watermark information includes: watermark content and watermark direction; adding a document watermark at a target position of each page of the image file in the first text document to obtain a target text document, wherein the target color of each pixel corresponding to the document watermark is any color within a first target color range.
[0088] Optionally, when the target color is white, determining to adjust the target color of the pixel to any color within a first target color range to obtain a document watermark, and adding the document watermark at the target position to obtain a target text document includes: when the RGB value of the pixel is equal to a first value, determining the target color to be white; adjusting the target color of each pixel at the target position to any color within the first target color range to obtain a document watermark, and adding the document watermark at the target position to obtain a target text document; or, setting the target color of each pixel at the target position to a color within the first target color range in turn to obtain a document watermark, and adding the document watermark at the target position to obtain a target text document.
[0089] Optionally, when the target color is black, the target color of each pixel corresponding to the document information content at the target position is adjusted to any color within the second target color range to obtain the target text document; or, the target color of each pixel corresponding to the document information content at the target position is set to a color within the second target color range in sequence to obtain the target text document.
[0090] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0091] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0092] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0093] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0094] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0095] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc. Various media that can store program codes.
[0096] The above are only preferred implementations of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A text document processing method, characterized in that: include: Obtaining a first text document in image format; Determine the document watermark to be added, wherein the document watermark information includes: watermark content and watermark direction; Adding a document watermark at a target position of each page of the image file in the first text document to obtain a target text document includes: for each page of the image file in the first text document, sequentially scanning each pixel at the target position and determining a target color of the pixel, wherein the target color of each pixel corresponding to the document watermark is any color within a first target color range; when the target color is white, determining to adjust the target color of the pixel to any color within the first target color range to obtain the document watermark, and adding the document watermark at the target position to obtain the target text document; when the target color is black, maintaining the target color of the pixel to obtain the document watermark, and adding the document watermark at the target position to obtain the target text document.
2. The method according to claim 1, characterized in that Get the first text document in image format, including: Acquire a text document to be processed, and determine the document type of the text document to be processed, wherein the document type includes: image format and PDF format; When the document type of the text document to be processed is in the PDF format, converting the text document to be processed into a first text document in the image format; When the document type of the text document to be processed is in image format, it is determined that the text document to be processed is the first text document.
3. The method according to claim 1, characterized in that Determine the document watermark to be added, including: The watermark content and the watermark direction of each page of the image file in the first text document are set according to a preset watermark rule.
4. The method according to claim 1, characterized in that When the target color is white, determining to adjust the target color of the pixel point to any color within the first target color range to obtain the document watermark, and adding the document watermark at the target position to obtain the target text document, including: When the RGB value of the pixel is equal to a first value, determining that the target color is white; Adjusting the target color of each pixel at the target position to any color within the first target color range to obtain the document watermark, and adding the document watermark at the target position to obtain the target text document; Or, the target colors of the pixels at the target position are sequentially set to colors within the first target color range to obtain the document watermark, and the document watermark is added at the target position to obtain the target text document.
5. The method according to claim 1, characterized in that When the target color is black, the target color of the pixel is maintained to obtain the document watermark, and the document watermark is added at the target position to obtain the target text document, including: When the RGB value of the pixel is equal to a second value, determining that the target color is black; The target color of the pixel is maintained to obtain the document watermark, and the document watermark is added at the target position to obtain the target text document.
6. The method according to claim 1, characterized in that The method comprises: When the target color is black, the target color of each pixel corresponding to the document information content at the target position is adjusted to any color within the second target color range to obtain the target text document; Or, the target colors of the pixels corresponding to the document information content at the target position are sequentially set to colors within the second target color range to obtain the target text document.
7. A text document processing device, characterized in that: include: An acquisition module, used for acquiring a first text document in image format; A determination module, used to determine the document watermark to be added, wherein the document watermark information includes: watermark content and watermark position; A generation module, used for adding a document watermark at a target position of each page of the image file in the first text document to obtain a target text document, comprising: for each page of the image file in the first text document, scanning each pixel at the target position in turn, and determining a target color of the pixel, wherein the target color of each pixel corresponding to the document watermark is any color within a first target color range; when the target color is white, determining to adjust the target color of the pixel to any color within the first target color range to obtain the document watermark, and adding the document watermark at the target position to obtain the target text document; when the target color is black, maintaining the target color of the pixel to obtain the document watermark, and adding the document watermark at the target position to obtain the target text document.
8. A non-volatile storage medium, characterized in that: The non-volatile storage medium includes a stored program, wherein the device where the non-volatile storage medium is located executes the text document processing method according to any one of claims 1 to 6 by running the program.
9. An electronic device, characterized in that: include: A memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the text document processing method according to any one of claims 1 to 6 through the computer program.
Citation Information
Patent Citations
Watermark design method and device, equipment and storage medium
CN113971625A
Private collection picture set catalogue processing method and device and storage medium
CN114003873A