Skip to main content
Participating Frequently
November 8, 2016
Answered

Export/import action using a watermark/background pdf - can we use a relative path?

  • November 8, 2016
  • 1 reply
  • 1318 views

We are using several single user licenses in the company. Those colleagues shall be able to apply stationery to pdf files via an action.

I have created an action which sets this background file. That file is in the same folder as the future merge files, like this:

folder - D:\Templates\Offers

background file - background.pdf

file to be merged - offer_12345.pdf

the exported action - our-stationery.sequ

Now when the action is imported by a colleague, the background.pdf will not be found, even though it's located in the same folder.

Let's have a look into the .sequ file (xml):

<Command name="COMP:AddBackground" pauseBefore="false" promptUser="false">

    <Items>

    <Items name="WaterBackCmd">

        <Item name="ANNOT" type="boolean" value="false"/>

        <Item name="BACKGROUND" type="boolean" value="true"/>

        […]

        <Item name="WATERMARK" type="boolean" value="false"/>

    </Items>

    <Item name="WaterBackCmd_SRC_FILE" type="text" value="Rb-Kopfbogen_Folgeseite.pdf"/>

    <Item name="WaterBackCmd_SRC_PARENT" type="text" value="/D/Templates/Offers/"/>

    </Items>

</Command>

Of course. If my colleague is using a folder C:\Offers, this cannot work.

I have tried to manually empty the WaterBackCmd_SRC_PARTENT value, but that breaks the imported action.

What are the allowed values for the folder?

I cannot believe that there shouldn't be something like "self" or at least a relative path. What sense would it make to export an action if it ist not suitable for collaboration, then?

This topic has been closed for replies.
Correct answer try67

Do NOT edit the SEQU file directly, unless you really know what you're doing. I recommend you delete that Action and create a new one.

The only thing you need to do is add an Execute JavaScript command with the code I provided, and a Save command.

Adding two backgrounds is a bit trickier, as they can conflict. You can try this code:

this.addWatermarkFromFile({cDIPath: this.path.replace(this.documentFileName, "background-first.pdf"), nStart: 0});

this.addWatermarkFromFile({cDIPath: this.path.replace(this.documentFileName, "background.pdf"), nStart: 1, nEnd: this.numPages-1});

1 reply

try67
Community Expert
Community Expert
November 8, 2016

It is possible to do it, but it requires using a script.

The basic command would be:

this.addWatermarkFromFile({cDIPath: this.path.replace(this.documentFileName, "background.pdf")});

There are a lot of other parameters that can be set, but you'll need to specify how you want the background to look like first...

Participating Frequently
November 8, 2016

Good hint, thanks.

Tested (to simulate collaboration):

  • added above javascript to action accordingly
  • edited the path in the .sequ file manually so as if it were a folder that does not exist on my computer
  • copied all files needed to a new folder
  • imported edite .sequ file

Result: the javascript makes no difference, the action is still prompting for file.

Actually I left out an important feature (hoping not to make it too complicated):

In fact we need to merge 2 backgrounds.

  1. background.pdf is merged with alle pages
  2. background-first.pdf is then merged with only the first page, replacing the background from step 1

Now with the javascript in the action, what happens is that it merges both! backgrounds with all the pages.

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
November 8, 2016

Do NOT edit the SEQU file directly, unless you really know what you're doing. I recommend you delete that Action and create a new one.

The only thing you need to do is add an Execute JavaScript command with the code I provided, and a Save command.

Adding two backgrounds is a bit trickier, as they can conflict. You can try this code:

this.addWatermarkFromFile({cDIPath: this.path.replace(this.documentFileName, "background-first.pdf"), nStart: 0});

this.addWatermarkFromFile({cDIPath: this.path.replace(this.documentFileName, "background.pdf"), nStart: 1, nEnd: this.numPages-1});