Description: Sample Groovy Script to embed a QR code (of 'Static' type) while downloading & printing the document (Supported in Asite Viewer-supported file formats only).
Click here to learn more.
Context: Document
Document Type: File
Remark: Accessible in 'Pre' task mode only.
Script:
def execute(){
DocumentVO document = documentService.getDocumentDetails();
boolean success = false;
boolean isNonPDF = !document.getFileName().endsWith(".pdf") && !document.getFileName().endsWith(".PDF");
if ((isNonPDF || QRCodeTypes.ISO.getId() == documentService.getWorkspaceQRCodeType(document))
&& documentService.isQRCodeEnabled(document, IGroovyConstant.FOLDER_LEVEL)) {
success = documentService.applyQRCode(document);
if (success) {
document.setExecutionStatus(Status.SUCCESS);
document.setResponseMessage("QR CODE EMBEDED SUCCESSFULLY");
} else {
document.setExecutionStatus(Status.FAILED);
document.setResponseMessage("QR CODE EMBED FAILED");
}
} else {
document.setExecutionStatus(Status.NOT_REQUIRED);
document.setResponseMessage("QR CODE NOT_REQUIRED");
}
document.setResponseStatus(false);
return document;
}