Search code examples
pdfalfrescowatermarktoolkitalfresco-webscripts

Alfresco PDF-Toolkit Javascript


i've recently installed Alfresco's PDF-Toolkit. My actual intension is to use it in a Javascript manner. This is because the value i need or want to watermark will be based on the Document's Property/Aspect.

i failed to find any tutorial or guide regarding this issue. if anyone can please give me a walkthrough, i'd really appreciate it.

my current script looks like this:

var watermark_action = actions.create("pdf-watermark");

watermark_action.parameters["destination-folder"] = ????;
watermark_action.parameters["watermark-type"] = "text";
watermark_action.parameters["watermark-text"] = aspect.ajie;
watermark_action.parameters["watermark-pages"] = "all";
watermark_action.parameters["watermark-depth"] = "over";
watermark_action.parameters["position"] = "center";

watermark_action.execute(document);

NOTE: i actually found one, the problem is that this one is an image watermark and what i want or need is a text watermark. also i need the script to save the watermarked copy to the same directory which i believe is not what the guide seems to do.

the last thing i need is the value for the destination-folder parameter. i really have no clue on how or what i'll place here just to save the pdf to the same folder. hoping to get some guide, tips, and tricks here. thanks


Solution

  • The code should look like this:

    var watermark_action = actions.create("pdf-watermark");
    
    watermark_action.parameters["inplace"] = true;
    watermark_action.parameters["destination-folder"] = document.parent;
    watermark_action.parameters["watermark-type"] = "text";
    watermark_action.parameters["watermark-text"] = "Lorem Ipsum";
    watermark_action.parameters["watermark-font"] = "Helvetica";
    watermark_action.parameters["watermark-size"] = "14";
    watermark_action.parameters["page"] = "all";
    watermark_action.parameters["watermark-depth"] = "over";
    
    watermark_action.parameters["position"] = "center";
    
    watermark_action.execute(document);
    

    You were missing watermark-font, watermark-size, and page.