1

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

TheQuestioner
  • 702
  • 10
  • 28
  • 1
    try to use "document.parent" if you run this script on particular document then "document.parent" will refer to folder under which it resides. – mitpatoliya Aug 18 '16 at 10:40
  • i tried this as `watermark_action.parameters["destination-folder"] = document.parent;` but i'm getting a `Could not run rules` error when i'm running the rule on a Folder Level :( – TheQuestioner Aug 18 '16 at 11:03
  • here is what my `Folder Rules` looks like -> http://i.imgur.com/RnNuJOK.png – TheQuestioner Aug 18 '16 at 11:05
  • 1
    What is the error in logs? You can also try with just "space". watermark_action.parameters["destination-folder"] ="space"; – mitpatoliya Aug 18 '16 at 12:03
  • still having a `Cannot Run Rule` error. i've tried `watermark_action.parameters["destination-folder"] = document.parent` and `watermark_action.parameters["inplace"] = true` any ideas ? – TheQuestioner Aug 19 '16 at 00:47

1 Answers1

2

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.

Jeff Potts
  • 10,468
  • 17
  • 40
  • this solved my problem. so the case is that, all parameters must be filled when i'm trying to execute pdf-toolkit via javascript ?. Thank you for such an effort Mr Potts (i am also the youtube guy who keeps asking you question. hehe) Case closed here. keeping this post to help future users too. – TheQuestioner Aug 19 '16 at 03:00