Skip to main content
All CollectionsSystem TasksWorking with Groovy ScriptsGroovy Script Library
Groovy Script - Insert Document Status for Files in PDF format
Groovy Script - Insert Document Status for Files in PDF format
Updated over 3 weeks ago

Description: Sample Groovy script to insert document status for files in PDF format when printed, viewed or downloaded based on the event defined in the related workflow trigger.

This script doesn't impact the actual file. The status is inserted and displayed on the file only based on the configured event.

Context: Document

Remark: Accessible in 'Pre' task mode and only when the event is configured as 'Print Document', 'View Document', or 'Download Documents'.

Script:

def execute(){

EmbedAttributeConfigEntity embedAttributeConfigEntity = new EmbedAttributeConfigEntity();

embedAttributeConfigEntity.setApplyOnAllPage(false);

embedAttributeConfigEntity.setDisplacementTop(0);

embedAttributeConfigEntity.setDisplacementBottom(0);

embedAttributeConfigEntity.setDisplacementRight(0);

embedAttributeConfigEntity.setDisplacementLeft(0);

embedAttributeConfigEntity.setAttributePosition(Location.TOP_LEFT);

embedAttributeConfigEntity.setMeasureIn(MeasureIn.PIXEL);

embedAttributeConfigEntity.setAttributeLblPrefix("View Doc Status : ");

embedAttributeConfigEntity.setFontSize(20);

embedAttributeConfigEntity.setColor("#cc0099");

embedAttributeConfigEntity.setFont(EntityFontType.TIMES_ROMAN);

embedAttributeConfigEntity.setBold(true);

embedAttributeConfigEntity.setItalic(true);

Map<SystemAttributeBanner, EmbedAttributeConfigEntity> sysAttributes = new HashMap<SystemAttributeBanner, EmbedAttributeConfigEntity>();

sysAttributes.put(SystemAttributeBanner.STATUS, embedAttributeConfigEntity);

return documentService.embedAttributesInFile(sysAttributes);

}



Did this answer your question?