Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 23 Next »

← Return to the list of hooks

If you have a problem understanding how the hook works, check: Hook's mechanism

Basic information

Available from version: 1.0.0

Description

Hook places a watermark on the document as it is displayed. This hook is implemented based on the definition of the ReadFileHookAdapter system hook, which allows to change the binary stream of the displayed document from archive or in preview in the process. Configuration of the watermark insert hook is defined in JSON format as a list and is managed by the PCM (Plugin Configuration Manager). A watermark is placed on every page of the document and accepts only PDF format.

JSON parameters
   - documentClassId
   - watermark
       - type
       - text
	   - alignment
       - anchor 
	   - positionX%
       - positionY%
       - opacity
       - watermarkBarcode
            - format
            - codeWidth
            - codeHeight
       - watermarkText
            - size
			- fontType
			- color
            - encoding
            - clockwiseAngle
   - permissions
       - groups
Configuration parameters

Parameter name in JSON configuration

From version

Description

Paremeter type

Comments and restrictions

documentClassId*

1.0.0

The document class id indicates for which documents the watermark insertion parameters are to be considered.

Integer

 

type*

(watermark)

 

1.0.0

Specifies what type of watermark is.

Text
ValueMeaning
BARCODEEncodes the value of the text parameter into a barcode with the specified format defined in the format parameter. The watermark on the document is a barcode.
TEXTThe value of the text parameter is applied to the document as an explicit, unencoded watermark.

text*

(watermark)

1.0.0

Takes the text value that is used to create the watermark. In order to use document index values, the index id should be enclosed in curly braces {}. It is possible to use more than one index value in a parameter. Each subsequent index must be followed by curly braces.

Example.

Case number: "{8}, Registration Date {9}"

Watermark text ->

Case number: 433589, Registration Date: 13-02-2021

Text

Any typed index ids in the text string must exist in the document class specified by the documentClassId parameter. If the document being viewed does not contain an index value (it is empty) whose id is given in curly braces in this parameter, the id will be replaced with the empty string "".

alignment*

(watermark)

1.0.0Specifies relative to which of the four corners of the document page the position of the watermark will be calculated based on the positionX% and positionY% parameters.Text

Pay attention to the corresponding values of the positionX% and positionY% parameters, because depending on the value of the alignment, anchor parameter, and the size of the watermark, the watermark may extend beyond the document page, i.e. be partially or completely invisible.

ValueMeaning
TOP_LEFT

The position of the watermark in relation to the top left corner.

TOP_RIGHT

The position of the watermark in relation to the top right corner.

BOTTOM_LEFT

The position of the watermark in relation to the bottom left corner.

BOTTOM_RIGHT

The position of the watermark in relation to the bottom right corner.

anchor*

(watermark)

1.0.0Specifies the position of the watermark in relation to the corresponding corner of the watermark.Text
ValueMeaning
BOTTOM_LEFT

The position of the watermark in relation to the lower left corner of the watermark.

positionX%*

(watermark)

1.0.0 Indicates the X (horizontal) position of the watermark in percent relative to the document page dimensions. The position is set based on the selected page corner in the alignment parameter. Integer Value between 0 and 100.

positionY%*

(watermark)

1.0.0 Indicates the Y (vertical) position of the watermark in percent relative to the document page dimensions. The position is set based on the selected page corner in the alignment parameter. Integer Value between 0 and 100.

opacity*

(watermark)

1.0.0 Specifies the transparency of the inserted watermark on the pages of the document. Float Value between 0.0 and 1.0.

format*

(watermark.watermarkBarcode)

1.0.0Specifies standard for one-dimensional barcodes (writing information on one line, in the form of dashes). Text
ValueMeaning
CODE_39

Also known as "USS Code 39", "Code 3/9", "Code 3 of 9", "USD-3", "Alpha39") - fixed-width alphanumeric single character bar code.

CODE_93

Code 93 was designed as an improvement to the Code 39 encoding. Like its original in the basic version, it is able to store 43 alphanumeric characters. However, compared to its predecessor, it has 4 additional control characters.

CODE_128

High-resolution alphanumeric one-dimensional barcode. It was designed to encode 128 ASCII characters

codeWidth*

(watermark.watermarkBarcode)

1.0.0Defines the width of the barcode in pixels.IntegerSpecifies the minimum width of the barcode. In case the value to be encoded from the text parameter turns out to be too long, the width will be increased.

codeHeight*

(watermark.watermarkBarcode)

1.0.0Defines the height of the barcode in pixels.Integer 

size*

(watermark.watermarkText)

1.0.0Text size.Float 

fontType

(watermark.watermarkText)

1.0.0Text font type.Text

The parameter is optional. If it is not defined, the default font will be HELVETICA.

ValueMeaning
COURIERCourier
COURIER_BOLDCourier Bold
COURIER_OBLIQUECourier Oblique
COURIER_BOLDOBLIQUECourier Bold Oblique
HELVETICAHelvetica
HELVETICA_BOLDHelvetica Bold
HELVETICA_OBLIQUEHelvetica Oblique
HELVETICA_BOLDOBLIQUEHelvetica Bold Oblique
SYMBOLSymbol
TIMES_ROMANTimes Roman
TIMES_BOLDTimes Bold
TIMES_ITALICTimes Italic
TIMES_BOLDITALICTimes Bold Italic
ZAPFDINGBATSZapf Dingbats

color

(watermark.watermarkText)

1.0.0Color of the text.Text

The parameter is optional. If not defined, the default color will be LIGHT_GRAY.

ValueMeaning
WHITEWhite
LIGHT_GRAYLight gray
GRAYGray
DARK_GRAYDark gray
BLACKBlack
REDRed
PINKPink
ORANGEOrange
YELLOWYellow
GREENGreen
MAGENTAMagenta
CYANCyan
BLUEBlue

encoding*

(watermark.watermarkText)

1.0.0Character encoding.Text
ValueMeaning
CP1250A code page for the representation of texts in Central European languages using the Latin alphabet, for example Albanian, Croatian, Czech, Polish, Romanian, Slovak, Slovenian, Hungarian.
CP1252A code page to represent texts in Western European languages.
CP1257A code page used to represent texts in Estonian, Lithuanian or Latvian. This set is largely compatible with ISO 8859-13, and is suitable for coding the Polish language.
MACROMANCharacter encoding mainly used in classic Mac OS to represent text. It encodes 256 characters, the first 128 of which are identical to ASCII and the remaining characters include math symbols, diacritics, and additional punctuation marks. It is suitable for English and several other Western languages.

clockwiseAngle*

(watermark.watermarkText)

1.0.0Watermark rotation.FloatThe value between 0.0 and 360.0.

groups

(permissions)

1.0.0Permissions defining for which users logged in to the system the hook will be run when trying to open a document.Array of text valuesOptional parameter, when is not filled, everyone can see the watermark.

Parameter*- field is required

Barcode formats
FormatDescription
Code_39

Barcode with variable-length alphanumeric characters to store 43 different characters. Each sign consists of 9 elements (light and dark bars), 3 of which are significantly wider. This format allows you to encode numbers, capital letters and characters (-, ., (Space), $, /, +,%, *).

CharValueCharValueCharValueCharValue
00B11M22X33
11C12N23Y34
22D13O24Z35
33E14P25-36
44F15Q26.37
55G16R27space38
66H17S28$39
77I18T29/40
88J19U30+41
99K20V31%42
A10L21W32  

 

Code_93

The barcode is an improvement of the CODE_39 format. Like its prototype, it stores 43 alphanumeric characters, but additionally has 4 control characters (($), (%), (/), (+)).
The code accepts only uppercase letters.

CharValueCharValueCharValueCharValue
00C12O24-36
11D13P25.37
22E14Q26space38
33F15R27$39
44G16S28/40
55H17T29+41
66I18U30%42
77J19V31($)43
88K20W32(%)44
99L21X33(/)45
A10M22Y34(+)46
B11N23Z35  


Code_128

Variable length, high density alphanumeric code. It can encode characters from the entire ASCII range. The coding uses a dash and a gap of four possible widths, which makes it a compact code. Code 128 can be scanned in either direction and there is no limit to the length of the code itself.


Configuration example

[
  {
   "documentClassId": 5,
   "watermark": {
        "type": "TEXT",
        "text": "Case number: {10}, Registration date: {11}",
		"alignment": "TOP_LEFT",
        "anchor": "BOTTOM_LEFT",
		"positionX%": 5,
        "positionY%": 5,
        "opacity": 0.7,
        "watermarkText":{
            "size": 15,
			"fontType": "HELVETICA",
			"color": "LIGHT_GRAY",
            "encoding": "CP1252",
            "rotation": 0
        }
    },
   "permissions": {
       "groups": ["Users", "Administrators"]  
    }
  },
  {
   "documentClassId": 5,
   "watermark": {
        "type": "BARCODE",
        "text": "{10}",
		"alignment": "TOP_LEFT",
        "anchor": "BOTTOM_LEFT",
        "positionX%": 80,
        "positionY%": 10,
        "opacity": 0.5,
        "watermarkBarcode":{
            "format": "CODE_128",       
            "codeWidth": 50,
            "codeHeight": 15
        }
    },
   "permissions": {
       "groups": ["Users", "Administrators"]  
    }
  }
]
Example of use

Example of use for the above JSON configuration.

Original document:

 After opening:

Change log

1.0.0

  • Hook adding

  • No labels