A method, system and storage medium for generating custom multi-watermark combination
Through the custom multi-watermark combination generation method, the problem of frequent secondary development of watermark changes in the existing technology is solved, flexible watermark configuration and management is realized, and software service costs of pharmaceutical companies are reduced.
Patent Information
- Application Number
- CN202210658685.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-12
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2042-06-12
AI Technical Summary
In existing pharmaceutical management software, watermarks are usually written in the code in a fixed manner, resulting in frequent secondary development of each watermark change or complex watermarks, which brings huge software service costs to pharmaceutical companies.
Provide a custom multi-watermark combination generation method, by obtaining input parameters and preset parameters of different watermark types, generate multiple watermark blocks of different types, and adjust the layout of the watermark template according to the content position of the page, and add it to the target document to generate a watermark document.
This method reduces the difficulty and workload of adding multi-type combination watermarks to documents, facilitates customers to adjust watermarks according to changes in demand, avoids frequent secondary development needs, and reduces software service costs.
Smart Images

Figure CN114943065B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information technology, and in particular to a method, system and storage medium for generating a custom multi-watermark combination. Background Art
[0002] At present, the research and development institutions of pharmaceutical companies often have a large number of documents when preparing and organizing drug application materials. In order to prevent the illegal spread of these documents in different application statuses and different business scenarios, different watermarks need to be added to these documents during operation. Moreover, with the changes in regulations, the documents need to be upgraded accordingly. At this time, there will be new requirements and changes for watermarks in the same business scenario. In the current pharmaceutical management software industry, watermarks are usually fixed in the code. Every time the watermark changes, or some complex watermarks require frequent secondary development, which brings huge software service costs to pharmaceutical companies, and also makes software providers face the development task of continuously adding or modifying watermarks, which brings many inconveniences to pharmaceutical companies and software providers. Summary of the invention
[0003] In view of the shortcomings of the prior art, the present invention provides a method for generating a custom multi-watermark combination, comprising the following steps:
[0004] S1, obtaining input parameters of each selected watermark type, and querying the watermark database according to the selected watermark type to obtain preset parameters of the corresponding type;
[0005] S2, generating a plurality of watermark blocks of different types according to input parameters and preset parameters of each type of watermark, and adding the watermark blocks of different types to the same substrate with a transparent background to form a watermark template;
[0006] S3, converting the document to be processed into a target document in PDF format, cyclically reading each page of the target document and adjusting the layout of different watermark blocks in the watermark template according to the page content position, and adding them to the corresponding page of the target document to generate a watermark document.
[0007] Preferably, the step S2 includes: obtaining configuration information of all watermarks under the template according to the configured watermark template, cycling through the configuration parameters of each watermark type, the watermark type including a first type watermark and a second type watermark; generating at least one first watermark block according to the input parameters and preset parameters corresponding to the first type watermark; generating at least one second watermark block containing a barcode or a QR code image according to the input parameters of the second type watermark.
[0008] Preferably, the step S2 also includes: respectively obtaining page distribution parameters and arrangement rule parameters in the first type watermark and the second type watermark, and after copying the first watermark block and the second watermark block by a corresponding number according to the respective page distribution parameters, adding and arranging them on the substrate in sequence according to the respective arrangement rule parameters to form a watermark template.
[0009] Preferably, the step S3 includes: obtaining the page size of the target document, adjusting the watermark template size to a preset multiple of the target document page, and at the same time equally enlarging the first watermark block and the second watermark block in the watermark template by the same multiple.
[0010] Preferably, step S2 also includes: obtaining page distribution parameters and arrangement rule parameters of the second type of watermark, calculating the second area position of each second watermark block arranged on the substrate; obtaining page distribution parameters and arrangement rule parameters of the first type of watermark, calculating the first initial area of each first watermark block arranged on the substrate, judging whether there is overlap between the first initial area and the second area, if there is overlap, calculating the overlap coefficient of the corresponding first watermark block with overlap, if the overlap coefficient is lower than a preset value, the position of the first initial area is not adjusted, otherwise the first initial area is moved in the direction of reducing overlap until it is out of overlap, the overlap coefficient is the proportion of the overlapping part of the first initial area and the second area in the area of the second area, if there is no overlap, adding the corresponding first watermark block and the second watermark block to the first initial area and the second area on the substrate.
[0011] The present invention also discloses a customized multi-watermark combination generation system, comprising: a watermark template configuration module, used to obtain the input parameters of each selected watermark type, and query the watermark database according to the selected watermark type to obtain the preset parameters of the corresponding type; a watermark template generation module, used to generate a plurality of different types of watermark blocks according to the input parameters and preset parameters of each type of watermark, and add the different types of watermark blocks to the same substrate with a transparent background to form a watermark template; a watermark adding module, used to convert the document to be processed into a target document in PDF format, cyclically read each page of the target document and adjust the layout of different watermark blocks in the watermark template according to the page content position, and add them to the corresponding page of the target document to generate a watermark document.
[0012] Preferably, the watermark template generation module includes: a configuration acquisition module, which is used to obtain the configuration information of all watermarks under the template according to the configured watermark template, and cycle through the configuration parameters of each watermark type, and the watermark type includes a first type watermark and a second type watermark; a first watermark generation module, which is used to generate at least one first watermark block according to the input parameters and preset parameters corresponding to the first type watermark; and a second watermark generation module, which is used to generate at least one second watermark block containing a barcode or a QR code image according to the input parameters of the second type watermark.
[0013] Preferably, the watermark template generation module is also configured to respectively obtain the page distribution parameters and layout rule parameters in the first type watermark and the second type watermark, and after copying the first watermark block and the second watermark block by a corresponding number according to the respective page distribution parameters, they are added and arranged on the substrate in sequence according to the respective layout rule parameters to form a watermark template.
[0014] The present invention also discloses a device for generating a custom multi-watermark combination, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any of the above methods when executing the computer program.
[0015] The present invention also discloses a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above methods are implemented.
[0016] The custom multi-watermark combination generation method, system and storage medium disclosed in the present invention obtain the input parameters of each selected watermark type, and query the watermark database according to the selected watermark type to obtain the preset parameters of the corresponding type; generate multiple different types of watermark blocks according to the input parameters and preset parameters of each type of watermark, and add the different types of watermark blocks to the same substrate with a transparent background to form a watermark template; convert the document to be processed into a target document in PDF format, read each page of the target document in a loop, adjust the layout of different watermark blocks in the watermark template according to the page content position, and add them to the corresponding page of the target document to generate a watermark document. The custom multi-watermark combination generation method is suitable for projects and products that need to add watermarks to documents. In the face of customers' complex watermarking scenarios and watermarking requirements, customized development is not required, and customers' various complex combination watermark addition requirements can be realized through configuration. The difficulty and workload of adding multiple types of combined watermarks to documents are reduced. It is convenient for customers to change watermark requirements due to changes in requirements or document changes, and there is no need to contact developers for secondary development. This solves the problem that the current watermark settings are fixed in the code, and each time the watermark changes or some complex watermarks require frequent secondary development, which brings huge software service costs to pharmaceutical companies.
[0017] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0019] Figure 1 The figure is a flowchart of a method for generating a custom multi-watermark combination disclosed in an embodiment.
[0020] Figure 2 A schematic diagram of a watermark template information storage field disclosed in an embodiment.
[0021] Figure 3 This is a schematic diagram of a specific flow of step S2 disclosed in an embodiment.
[0022] Figure 4 This is a schematic diagram of a specific flow chart of step S3 disclosed in an embodiment. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical solution and advantages of the embodiment of the present invention clearer, the technical solution of the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings of the embodiment of the present invention. Obviously, the described embodiment is a part of the embodiment of the present invention, not all of the embodiments. Based on the described embodiment of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0024] In the present invention, unless otherwise clearly specified and limited, the technical terms or scientific terms used herein shall have the common meanings understood by persons with ordinary skills in the field to which the present invention belongs. The words "first", "second" and similar words used in the patent application specification and claims of the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, words such as "one" or "an" do not indicate a quantity limitation, but indicate the existence of at least one.
[0025] The method for generating a custom multi-watermark combination disclosed in this embodiment provides a method for adding different watermarks to a large number of documents generated in the process of drug development and application in different business scenarios. It can enable different customers to create, modify, delete, configure, combine, preview and add watermarks to documents according to their own business scenarios and different requirements for watermarks. It solves the problem of frequent secondary development of products due to watermark changes and reduces the long-term investment cost of pharmaceutical companies in software. Figure 1 As shown, this embodiment discloses a method for generating a custom multi-watermark combination, which may specifically include the following steps:
[0026] Step S1, obtaining input parameters of each selected watermark type, and querying a watermark database according to the selected watermark type to obtain preset parameters of the corresponding type.
[0027] In specific settings, different watermark properties can be defined according to the watermark type. The watermark type can include a first watermark type, a second watermark type and a third watermark type, wherein the first watermark type can be a text watermark, the second watermark type can be a picture watermark, and the third watermark type can be a QR code / barcode watermark.
[0028] The properties of the first watermark type, i.e., the text watermark, may include but are not limited to the following. Watermark content: The watermark content can be entered manually to fix the watermark content. You can click the Constant tab to add a constant field. You can also click to add a custom variable field. Therefore, the text watermark content may be a combination of fixed content, constants, and variables. Font size: used to set the font size of the watermark text, in pixels px. Watermark font: The watermark font is used to define the watermark text style, for example, it can default to "Songti". Text color: The watermark color mainly defines the watermark text color, for example, it can default to black. Date format: The watermark format is mainly used for some watermarks that need to include time information, but different watermarks have different requirements for the date format, so the definition of the date format is provided.
[0029] The properties of the second watermark type, i.e., the image watermark, may include but are not limited to the following. Upload watermark image: Customize the watermark image to be added to the image type watermark by uploading an image document. Image height: Calculate the scale ratio of the uploaded image based on the actual height of the uploaded image and the set image height.
[0030] The third watermark type, i.e., the QR code / barcode watermark, has similar properties to the image watermark, except that it is not a fixed image. When used, the image must be dynamically generated based on user-defined information.
[0031] Others may also include common configuration properties of each watermark, for example, they may include but are not limited to the following parameters. Watermark arrangement number: Tiling mode, if set to 1-1, it means no tiling. If set to 2-3, it means tiling 3 rows and 2 columns, and 2*3=6 identical watermarks are displayed on one page. Watermark position: The watermark position can define the starting position of the watermark, and the options are: the upper left corner of the document page, the upper right corner of the document page, the lower left corner of the document page, the lower right corner of the document page, and the center of the document page. You can also define the horizontal offset distance x and the vertical offset distance y. If the starting position of the watermark is the upper left corner of the document page or the center of the document page, xy refers to the offset to the lower right; if the starting position of the watermark is the upper right corner of the document page, xy refers to the offset to the lower left; if the starting position of the watermark is the lower left corner of the document page, xy refers to the offset to the upper right corner; if the starting position of the watermark is the lower right corner of the document page, xy refers to the offset to the upper left corner; where x and y support negative numbers, they are offset in the opposite direction corresponding to the above description. Rotation angle: Rotation angle refers to the tilt of the watermark, which supports 0-360° rotation. The rotation is clockwise based on the center position of the watermark. Transparency: Setting transparency is to support the degree of coverage of the watermark on the document content in different scenarios. If the watermark is loaded on the watermark content, the transparency can be set to less than 100 / 100 as needed to prevent the document content from being covered. If the watermark is added to the blank space of the document, the transparency can be set to 100 / 100 to add the watermark in an opaque way.
[0032] In the specific operation, by filling in the template variables, after determining the watermark template to be used, the custom parameters configured in the template, i.e. variables, will be obtained. According to the custom parameters, an input box is generated, and the user fills in the relevant variables and passes them to the next module to generate a watermark image.
[0033] Step S2, generating a plurality of different types of watermark blocks according to the input parameters and preset parameters of each type of watermark, and adding the different types of watermark blocks to the same substrate with a transparent background to form a watermark template. The watermark block refers to a file element containing the corresponding watermark content, which can be a png picture with a transparent background containing the corresponding watermark content such as text, picture or QR code, or a file in other formats, which can be added to the substrate and combined to form a watermark template.
[0034] Saving watermark templates is mainly to store the configured watermark template information. You can choose any relational or non-relational database, such as MySQL, SqlServer, Oracle, MongoDB, Elasticsearch, etc. to persist table structured data. The storage includes fields such as Figure 2 Template information fields.
[0035] In this embodiment, as shown in the attached Figure 3As shown, the step S2 may also include:
[0036] Step S21, according to the configured watermark template, obtain configuration information of all watermarks under the template, and cycle through configuration parameters of each watermark type, wherein the watermark type includes a first type watermark and a second type watermark.
[0037] Step S22, generating at least one first watermark block according to input parameters and preset parameters corresponding to the first type of watermark, wherein the first watermark block is configured as a watermark image containing input text generated according to the input parameters of the first type of watermark.
[0038] Step S23, generating at least one second watermark block including a barcode or a QR code image according to the input parameters of the second type watermark, wherein the second watermark block is configured as a watermark image including a barcode or a QR code generated according to the input parameters of the second type watermark.
[0039] The step S2 also includes: step S24, respectively obtaining the page distribution parameters and arrangement rule parameters in the first type watermark and the second type watermark, and after copying the first watermark block and the second watermark block by a corresponding number according to the respective page distribution parameters, adding and arranging them on the substrate in sequence according to the respective arrangement rule parameters to form a watermark template.
[0040] In a preferred embodiment, the step S2 further comprises:
[0041] Step S101 , obtaining page distribution parameters and arrangement rule parameters of the second type of watermark, and calculating the second area position of each second watermark block arranged on the substrate.
[0042] Step S102, obtain the page distribution parameters and arrangement rule parameters of the first type of watermark, calculate the first initial area where each first watermark block is arranged on the substrate, determine whether there is overlap between the first initial area and the second area, if there is overlap, calculate the overlap coefficient of the corresponding first watermark block with overlap, if the overlap coefficient is lower than a preset value, do not adjust the position of the first initial area, otherwise move the first initial area in the direction of reducing the overlap until it is out of overlap, the overlap coefficient is the proportion of the overlapping part of the first initial area and the second area in the area of the second area, if there is no overlap, add the corresponding first watermark block and the second watermark block to the first initial area and the second area on the substrate.
[0043] Specifically, the layout position, number of layouts and arrangement rules of the two-dimensional code watermark on the substrate are calculated according to the page distribution parameters and layout rule parameters of the second type of watermark. For example, the page distribution parameter can be a 1*2 layout, that is, two two-dimensional codes are arranged on each page, and the layout rule parameter can be arranged only on the page, the footer area, or the entire page including the text. At the same time, the second area position occupied by the two generated second watermark blocks on the substrate can be finally confirmed according to the size parameter and position parameter of the second type of watermark.
[0044] Then, the first initial area position of the first watermark block generated by the first type of watermark on the substrate is obtained in the same way. Then, it is determined whether the first initial area overlaps with the second area, because if the two-dimensional code in the two-dimensional code watermark overlaps with the text in the text watermark, the text watermark may cover part of the two-dimensional code graphic, making it difficult to identify the two-dimensional code watermark. Therefore, when generating a combined watermark, it is necessary to determine in advance whether the two-dimensional code watermark overlaps with other watermarks. In this embodiment, it is also possible to determine whether the first watermark block needs to be adjusted by judging the overlap coefficient of the overlapping area of the first initial area and the second area. This overlap coefficient can be the ratio of the overlapping area to the corresponding second area, or the depth of the overlapping area entering the second area, etc., which can be set according to the specific situation. If the overlap coefficient is lower than the preset value, the position of the first initial area is not adjusted, otherwise the first initial area is moved in the direction of reducing overlap until it is out of overlap. If it does not overlap, the corresponding first watermark block and second watermark block are added to the first initial area and the second area on the substrate.
[0045] In some other preferred embodiments, step S2 may also include the following contents.
[0046] Step S201 : generating a first watermark block including a first type of watermark and a second watermark block including a second type of watermark according to different watermark parameters.
[0047] Step S202, obtaining the level parameters of the first watermark type and the second watermark type, giving priority to the second watermark type with a higher priority, and calculating the second area where the second watermark block is arranged on the watermark template according to the page distribution parameters and arrangement rule parameters of the second watermark type.
[0048] Step S203, obtain the page distribution parameters and arrangement rule parameters of the first watermark type with a lower priority, calculate the first initial area where the first watermark block is arranged on the watermark template, if the first initial area overlaps with the second area, adjust some variable parameters in the first watermark type to form a first watermark adjustment block, and add the first watermark adjustment block and the second watermark block to the same watermark template formed on the substrate with a transparent background after the overlapping area of the first watermark adjustment block and the second watermark block meets the overlap rule. The overlap rule can be the ratio of the overlap area to the corresponding second area as described in the above embodiment, or the depth of the overlap area entering the second area, etc., which can be set according to specific circumstances.
[0049] In this embodiment, a level parameter is added to each watermark type, and the adjustment priority of each watermark can be set in advance. For example, the watermark template has a first watermark type and a second watermark type. If the priority of the first watermark type is lower and the priority of the second watermark type is higher, then when their watermark areas overlap and need to be adjusted, the watermark with a higher priority can be kept unchanged, and the watermark block with a lower priority can be adjusted first. If there are multiple watermarks of different types, the watermark block with the highest priority can be kept unchanged, and other watermark blocks can be adjusted in order from low to high according to priority. By setting the priority of each watermark type to achieve hierarchical adjustment of the combined watermark, each type of watermark can be adjusted more reasonably according to the importance of each watermark type to avoid mutual influence.
[0050] In this embodiment, step S203 may further include:
[0051] Step S2031, obtaining page distribution parameters and arrangement rule parameters of a first watermark type with a lower priority, generating at least one first watermark block and calculating position parameters of a first initial area arranged on the watermark template.
[0052] Step S2032: if the first initial area overlaps with the second area, a first variable with adjustable properties in the first watermark type is obtained, and the first watermark block is correspondingly adjusted according to the properties of the first variable to form a first watermark adjustment block.
[0053] If the first initial area overlaps with the second area, multiple first variables with adjustable properties in the first watermark type are obtained. The modifiable levels of the multiple first variables are compared, the parameter properties of the first variable with the highest modifiable level are obtained, and the first watermark block is modified accordingly according to the parameter properties to form a first watermark adjustment block.
[0054] For example, the first variable is a watermark angle parameter, a watermark position parameter, and a watermark size parameter. If the watermark angle parameter has the highest modifiable level, the watermark angle parameter of the first watermark block is adjusted preferentially when the first initial area overlaps with the second area. Specifically, the parameter attribute of the watermark angle parameter is obtained. If the first watermark type is a text watermark, the minimum watermark area of the text watermark is obtained, and the minimum watermark area is rotated by a preset angle to obtain a first watermark adjustment block, and the first watermark adjustment block includes the position information of the minimum watermark area.
[0055] Step S2033, obtaining the overlapping area between the first watermark adjustment block and the second watermark block, calculating whether the overlapping area meets the preset overlapping rule, if so, adding the first watermark adjustment block and the second watermark block to the watermark template formed in the same substrate with a transparent background, if not, returning to the aforementioned step to adjust the first watermark adjustment block again until the overlapping area meets the preset overlapping rule.
[0056] In this embodiment, the parameters with adjustable properties in each watermark type are increased with an adjustable level, and the priority of the adjustment operation of each watermark can be set in advance. For example, if the first watermark type needs to be adjusted in the watermark template this time, the variable with the highest level of changeability can be obtained for modification and adjustment. If the requirement of the overlap of the two watermark blocks cannot be met after adjusting the variable with the highest level of changeability, the variable with the second highest level of changeability can be modified and adjusted. By setting the changeable level for each adjustable variable in the watermark type, different sequential adjustment actions of a certain watermark type in the combined watermark can be realized, and the watermark adjustment actions can be more reasonably customized to adjust the combined watermarks to avoid mutual influence.
[0057] In a specific embodiment, the watermark image is generated according to the attribute information of each watermark configuration under the configured watermark template. The system obtains the configuration information of all watermarks under the template according to the selected / configured template, and cycles through each watermark configuration information. If it is a text watermark or a QR code / barcode watermark, the system will parse the watermark content and user-entered variables, global variables, and fixed content to generate the final watermark content. The QR code / barcode will be drawn according to the watermark content, generate a barcode / QR code image, and change the barcode / QR code watermark type to an image watermark type. Then the watermark image is generated according to the watermark configuration, which is mainly divided into the following steps:
[0058] Draw a transparent watermark template background through the java.awt.Graphics2D brush. According to the clarity (for example, the clarity is n), the length and width of the template background needs to be n times the document page to which the watermark is to be added. The larger the n value, the larger the background pixels, and the higher the clarity of the watermark template image generated. When all watermarks under the template are generated, the length and width of the image, the text size, the offset distance, etc. must also be enlarged n times. Then, according to the tiling configuration, the template background is sliced. For example, if the tiling method is 2*3, that is, 2 watermarks will be tiled in each row, and 3 watermarks need to be tiled in each column, then it needs to be divided into 6 slices. The width of each slice is half of the width of the template background, and the height of each slice is one-third of the height of the template background. Then record the coordinates of the upper left corner position of each slice, as well as the width and height of each slice.
[0059] If it is a text watermark, the system needs to create a java.awt.Font object according to the font style, font color, and font size configured in the watermark. The font size needs to be enlarged according to the clarity. The font enlargement ratio is n*3 / 4 if the clarity is n*3 / 4. Then create a java.awt.FontMetrics object based on java.awt.Graphics2D and java.awt.Font. Then create a java.awt.Dimension object based on java.awt.FontMetrics and the watermark content, and then obtain the height and width of the text watermark based on the java.awt.Dimension object. Among them, java.awt.Font is used to define font information, such as font size, font type, and font line. java.awt.Graphics2D is used to define the brush, which can define the drawing range, that is, the length and width of the watermark background image, whether it is transparent, the brush color, and other information. The java.awt.FontMetrics font measurement properties can obtain the font measurement information by specifying the brush properties and font properties. java.awt.Dimension font size information can define the font text content. Combined with the font measurement properties, it can obtain the length and width of the specified font text content.
[0060] If it is an image watermark, the system will first obtain the image object, and enlarge the image length and width by n times according to the definition n. If the image watermark is configured with a height, it will be scaled according to the ratio of the actual image height to the configured height, and then the height and width of the watermark image will be obtained.
[0061] Then loop through the tiled slices and the coordinates of the upper left corner of each slice. Combine the offset start position, offset distance, and the height and width of the text / image watermark to generate the upper left corner coordinate object java.awt.Rectangle of the watermark on each slice. It should be noted that the offset start position is different and the offset direction is also different. Then, according to java.awt.Rectangle, get the coordinates of the upper left corner of the watermark on each slice, and then combine the width and height of the watermark to get the center coordinates of the watermark on each slice. Loop through the coordinates of the upper left corner of each watermark, and determine if the rotation angle rotate is configured. First, rotate the center coordinates of each watermark by rotate degrees, and then use a brush to draw the watermark image or watermark text on the background. It should be noted that when drawing the watermark of the next slice, first rotate it back in the opposite direction with the center of the previous watermark as the center, and then rotate it with the center of the watermark of the current slice. The upper left corner here is the upper left corner of each tile of the watermark. Then, according to the coordinates of the upper left corner of each tile, the offset position, the length and width of the watermark, the center of the watermark is located, and the watermark center is rotated as the center of the circle. Finally, the combined watermarks generate a template watermark image, that is, the above steps are repeated, and all watermarks under the template are painted on the same watermark template background, and finally a watermark template image is generated.
[0062] Step S3, converting the document to be processed into a target document in PDF format, cyclically reading each page of the target document and adjusting the layout of different watermark blocks in the watermark template according to the page content position, and adding them to the corresponding page of the target document to generate a watermark document.
[0063] As attached Figure 4 As shown, the step S3 includes: obtaining the page size of the target document, adjusting the watermark template size to a preset multiple of the target document page, and at the same time equally enlarging the first watermark block and the second watermark block in the watermark template by the same multiple.
[0064] In this embodiment, the step further includes:
[0065] Step S31, identifying each page of the target document to be watermarked, obtaining the area where the text content is located in each page; marking the target document pages into multiple page types according to the layout of the text content in each page, and identifying the largest text area in the first page type as the text page. The largest text area is the rectangular area where the text is located.
[0066] At the same time, the pages with the same maximum text area in the target document pages can be marked as the first page type, and the other pages can be marked as the second page type, wherein the maximum text area is a rectangular area. In a document, the pages with the largest text area are often text pages, so these text pages are marked as the first page type, and the other pages are marked as the second page type, and these second page types can be other pages such as directory pages, index pages, and content separator pages.
[0067] Step S32, determine whether there is at least one second watermark block in the initial watermark template, if so, calculate the second area where the second watermark block is arranged on the initial watermark template according to the page distribution parameters and arrangement rule parameters of the second watermark type; the second watermark block is configured as a watermark image containing a barcode or a QR code generated according to the input parameters of the second type of watermark. If there is only the first watermark block in the initial watermark template, generate the first area where the first watermark block is arranged on the initial watermark template according to the page distribution parameters and arrangement rule of the first watermark type, and add the initial watermark template to each target page marked as the first page type.
[0068] Step S33: if the second area overlaps with the maximum text area or the overlapped area does not meet the set overlap rule, some variable parameters in the second watermark type are adjusted to form a second watermark adjustment block, the second watermark block is replaced with the second watermark adjustment block in the initial watermark template to form a first watermark template corresponding to the first page type, and the first watermark template is added to each target page marked as the first page type. The second watermark block is added to the initial watermark template to form a second watermark template corresponding to the second page type, and the second watermark template is added to each target page marked as the second page type.
[0069] In this embodiment, the step S33 may also include the following contents: if the second area overlaps with the maximum text area or the overlapped area does not meet the set overlap rule, then determine whether the number of lines in the watermark layout parameter in the second watermark type is greater than 2, and if it is greater than 2 lines, modify the number of lines of the layout parameter to 2. Modify the watermark position parameter in the second watermark type, and modify the two second watermark blocks located at the upper and lower parts respectively so that the corresponding second areas move upward and downward to form two second watermark adjustment blocks. The second area corresponding to the second watermark adjustment block does not overlap with the maximum text area or the overlapped area meets the set overlap rule. In the initial watermark template, the second watermark block is replaced with the second watermark adjustment block to form a first watermark template corresponding to the first page type, and the first watermark template is added to each target page marked as the first page type. Specifically, the area where the generated two-dimensional code watermark belonging to the second watermark type is located is on the page body, which will cause the two-dimensional code part pattern to overlap with the body text, so that the body text destroys the two-dimensional code pattern, which may cause the two-dimensional code recognition efficiency to decrease. Therefore, the position of the QR code watermark needs to be adjusted. It can be moved up or down to the header or footer area of the page to avoid interference of the main text content with the QR code watermark.
[0070] In this embodiment, watermark templates are selected / configured. Watermark templates used in different locations can be configured and bound according to different business needs. When in use, the corresponding watermark template can be brought out for use according to the configuration binding information; some can bring out all authorized watermark templates more flexibly, and the watermark template to be used can be selected by the user. Different locations refer to different functional points in the system. The bound watermark template is obtained according to certain rules of the business system (configuration binding information). This is a flexible way to use the usage scenario. Convert the document to be processed to PDF. In some embodiments, jaclob can also be used to realize word to PDF conversion. The template watermark is added to PDF through itextpdf to finally generate a new document.
[0071] Specifically, for example, a watermark requirement requires a text watermark to be added to the upper left corner of the file, 2*2 image watermarks to be tiled on the file content, and a QR code watermark to be added to the lower right corner of the file. This is equivalent to a watermark template with three watermarks configured. The first watermark type is text, and the position is defined in the upper left corner. The system uses the font configuration information to first draw this text watermark in the upper left corner of the transparent template. The second watermark is an image watermark. Because it needs to be tiled, it will first be sliced and positioned, and then this image will be repeatedly drawn with 4 image watermarks at 2*2 positions based on the transparent template that has already drawn the text watermark. The third watermark is a QR code watermark. The configured QR code content will be parsed first, and then a QR code image will be generated. Then, based on the transparent template that has already drawn the text watermark and image watermark, a QR code image watermark will be drawn. The final watermark template is a watermark image that combines text, images, and QR codes, and then scales and adds watermarks based on the length and width information of the PDF page.
[0072] The above embodiment is a method for adding custom watermarks to documents of types such as word, excel, ppt, txt, and image in batches. Then, multiple watermarks are combined to generate a watermark template, and the position information, content information, display style, etc. of each watermark constituting the template can be customized, and a watermark template preview function is provided. When using the watermark template, the template variable data is manually entered according to the variables defined by each watermark in the template, and the constant data is automatically added in the background, and the final content is parsed together with the fixed content to generate the final content. Each text watermark or QR code / barcode watermark is generated according to the content, and then each watermark in the template is processed according to the parameters such as the position tiling rules of each watermark, and then written into the same transparent background PNG picture to generate a template watermark picture. After that, the document to be watermarked is converted to PDF, and each page of PDF is read in a loop to add a watermark template picture to generate a new document and return it. The present invention is suitable for projects and products that need to add watermarks to documents. In the face of customers' complex watermarking scenarios and watermarking requirements, customized development is not required, and customers' various complex combined watermark adding requirements can be realized through configuration. The difficulty and workload of adding multiple types of combined watermarks to documents are reduced. It is convenient for customers to change watermark requirements due to changes in demand or document changes, and there is no need to contact developers for secondary development. It solves the problem that the current watermark settings are fixed in the code, and each watermark change or some complex watermarks require frequent secondary development, which brings huge software service costs to pharmaceutical companies.
[0073] In another embodiment, a customized multi-watermark combination generation system is also disclosed, including: a watermark template configuration module, used to obtain the input parameters of each selected watermark type, and query the watermark database according to the selected watermark type to obtain the preset parameters of the corresponding type; a watermark template generation module, used to generate multiple watermark blocks of different types according to the input parameters and preset parameters of each type of watermark, and add the different types of watermark blocks to the same substrate with a transparent background to form a watermark template; a watermark adding module, used to convert the document to be processed into a target document in PDF format, cyclically read each page of the target document and adjust the layout of different watermark blocks in the watermark template according to the page content position, and add them to the corresponding page of the target document to generate a watermark document.
[0074] In this embodiment, the watermark template generation module includes: a configuration acquisition module, which is used to obtain the configuration information of all watermarks under the template according to the configured watermark template, and cycle through the configuration parameters of each watermark type, and the watermark type includes a first type watermark and a second type watermark; a first watermark generation module, which is used to generate at least one first watermark block according to the input parameters and preset parameters corresponding to the first type watermark; a second watermark generation module, which is used to generate at least one second watermark block containing a barcode or a QR code image according to the input parameters of the second type watermark.
[0075] In this embodiment, the watermark template generation module is also configured to respectively obtain the page distribution parameters and layout rule parameters in the first type watermark and the second type watermark, and after copying the first watermark block and the second watermark block by a corresponding number according to the respective page distribution parameters, they are added and arranged on the substrate in sequence according to the respective layout rule parameters to form a watermark template.
[0076] The specific functions of the above-mentioned custom multi-watermark combination generation system correspond one-to-one to the custom multi-watermark combination generation method disclosed in the previous embodiment, so it will not be described in detail here. For details, please refer to the various embodiments of the custom multi-watermark combination generation method disclosed in the previous embodiment. It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other.
[0077] In other embodiments, a custom multi-watermark combination generating device is also provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the various steps of the custom multi-watermark combination generating method described in the above embodiments when executing the computer program.
[0078] The custom multi-watermark combination generating device may include, but not limited to, a processor and a memory. The server may include, but not limited to, a processor and a memory. Those skilled in the art may understand that the schematic diagram is only an example of a server and does not constitute a limitation on the server device. It may include more or fewer components than shown in the diagram, or combine certain components, or different components. For example, the server device may also include input and output devices, network access devices, buses, etc.
[0079] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the server device, and uses various interfaces and lines to connect various parts of the entire server device.
[0080] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the server device by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0081] If the custom multi-watermark combination generation method 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 present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0082] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
[0083] In conclusion, the above is only a preferred embodiment of the present invention, and all equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the patent of the present invention.
Claims
1. A method for generating a custom multi-watermark combination, characterized in that: The steps include: S1, obtaining input parameters of each selected watermark type, and querying the watermark database according to the selected watermark type to obtain preset parameters of the corresponding type; S2, generating a plurality of watermark blocks of different types according to input parameters and preset parameters of each type of watermark, and adding the watermark blocks of different types to the same substrate with a transparent background to form a watermark template; According to the configured watermark template, configuration information of all watermarks under the template is obtained, and configuration parameters of each watermark type are cycled, wherein the watermark type includes a first type watermark and a second type watermark; at least one first watermark block is generated according to input parameters and preset parameters corresponding to the first type watermark, wherein the first watermark block is configured as a watermark image containing input text generated according to the input parameters of the first type watermark; at least one second watermark block containing a barcode or a QR code image is generated according to the input parameters of the second type watermark, wherein the second watermark block is configured as a watermark image containing a barcode or a QR code generated according to the input parameters of the second type watermark; Obtaining page distribution parameters and arrangement rule parameters of the second type of watermark, and calculating the second area position of each second watermark block arranged on the substrate; obtaining page distribution parameters and arrangement rule parameters of the first type of watermark, calculating the first initial area of each first watermark block arranged on the substrate, judging whether the first initial area overlaps with the second area, and if so, calculating the overlap coefficient of the corresponding first watermark block with overlap, and if the overlap coefficient is lower than a preset value, not adjusting the position of the first initial area, otherwise moving the first initial area in a direction of reducing overlap until it is out of overlap, and the overlap coefficient is the proportion of the overlap portion of the first initial area and the second area in the area of the second area, and if there is no overlap, adding the corresponding first watermark block and the second watermark block to the first initial area and the second area on the substrate; S3, converting the document to be processed into a target document in PDF format, cyclically reading each page of the target document and adjusting the layout of different watermark blocks in the watermark template according to the page content position, and adding them to the corresponding page of the target document to generate a watermark document.
2. The method for generating a custom multi-watermark combination according to claim 1, characterized in that: The step S2 further comprises: The page distribution parameters and arrangement rule parameters of the first type watermark and the second type watermark are obtained respectively, and after the first watermark block and the second watermark block are copied by a corresponding number according to their respective page distribution parameters, they are added and arranged on the substrate in sequence according to their respective arrangement rule parameters to form a watermark template.
3. The method for generating a custom multi-watermark combination according to claim 2, characterized in that: The step S3 includes: obtaining the page size of the target document, adjusting the watermark template size to a preset multiple of the target document page, and at the same time equally enlarging the first watermark block and the second watermark block in the watermark template by the same multiple.
4. A custom multi-watermark combination generation system, characterized in that: include: The watermark template configuration module is used to obtain the input parameters of each selected watermark type, and query the watermark database according to the selected watermark type to obtain the preset parameters of the corresponding type; A watermark template generation module, used to generate a plurality of different types of watermark blocks according to input parameters and preset parameters of each type of watermark, and add the different types of watermark blocks to the same substrate with a transparent background to form a watermark template; According to the configured watermark template, the configuration information of all watermarks under the template is obtained, and the configuration parameters of each watermark type are cycled, wherein the watermark types include first-type watermarks and second-type watermarks; at least one first watermark block is generated according to the input parameters and preset parameters corresponding to the first-type watermark, wherein the first watermark block is configured as a watermark image containing input text generated according to the input parameters of the first-type watermark; at least one second watermark block containing a barcode or a QR code image is generated according to the input parameters of the second-type watermark, wherein the second watermark block is configured as a watermark image containing a barcode or a QR code generated according to the input parameters of the second-type watermark; the page distribution parameters and layout rule parameters of the second-type watermark are obtained, and the calculation Calculate the second area position of each second watermark block arranged on the substrate; obtain the page distribution parameter and arrangement rule parameter of the first type of watermark, calculate the first initial area of each first watermark block arranged on the substrate, determine whether the first initial area overlaps with the second area, if there is overlap, calculate the overlap coefficient of the corresponding first watermark block with overlap, if the overlap coefficient is lower than a preset value, do not adjust the position of the first initial area, otherwise move the first initial area in a direction to reduce the overlap until it is out of overlap, the overlap coefficient is the proportion of the overlap portion of the first initial area and the second area in the area of the second area, if there is no overlap, add the corresponding first watermark block and the second watermark block to the first initial area and the second area on the substrate; The watermark adding module is used to convert the document to be processed into a target document in PDF format, cyclically read each page of the target document and adjust the layout of different watermark blocks in the watermark template according to the page content position, and add them to the corresponding page of the target document to generate a watermark document.
5. The self-defined multi-watermark combination generation system according to claim 4, characterized in that: The watermark template generation module is also configured to respectively obtain the page distribution parameters and arrangement rule parameters in the first type watermark and the second type watermark, and after copying the first watermark block and the second watermark block by a corresponding number according to their respective page distribution parameters, add and arrange them on the substrate in sequence according to their respective arrangement rule parameters to form a watermark template.
6. A device for generating a custom multi-watermark combination, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 3 are implemented.
7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Watermark adding method and mobile terminal
CN107464206A
PDF-based watermark tiling method and device, computer equipment and storage medium
CN109558705A
Webpage watermark adding method and device
CN113672837A