Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Community Beginner ,
Nov 08, 2016 Nov 08, 2016

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?

1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Nov 08, 2016 Nov 08, 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});

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2016 Nov 08, 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...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 08, 2016 Nov 08, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2016 Nov 08, 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});

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 09, 2016 Nov 09, 2016

Ah, great, thank you so much!

Lesson learned: not getting seduced by clickable action items, focus on JavaScript right away.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 09, 2016 Nov 09, 2016
LATEST

JS can do a lot of things that the built-in commands can't, and is more flexible in doing so, but the reverse is also true. The trick is to select the right kind of command for the task... But that is something you learn the more you do it. There's no clear guide on what's the best command to use, because it depends a lot on what you want to achieve.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines