Padding the suffix in the split element

Post Reply
jstotz
Newbie
Posts: 10
Joined: Thu Jan 22, 2015 7:47 pm

Padding the suffix in the split element

Post by jstotz »

I'm using the split element to split files and I'm adding "#[index]" as a suffix. This works as an inline value. However, the split element pads the index to the number of digits in the original page count of the original file. If the original file had 7 pages, then the suffix for the first file is #1. If the original file had 43 pages, then the suffix for the first file is #01. This leaves me with a bunch of files that have different length suffixes.

I want to always pad it to 3 digits. I thought I could use a script expression like this:

Code: Select all

#[index].padstart(3, "0");
however I get a syntax error when I run the flow. (Why doesn't the script expression window check the syntax? Why do I have to wait until runtime?)

I tried using the "single line text with variables" but that window gives me an error at the bottom that says "[index] - unknown variable" and I can't find index in any of the variable categories.

What is the correct syntax for using [index] in a script expression?
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Padding the suffix in the split element

Post by jan_suhr »

You can construct what you want by using the different suffixes or prefixes in the SplitPDF element.
Screenshot 2018-02-21 23.00.16.jpg
Screenshot 2018-02-21 23.00.16.jpg (70.61 KiB) Viewed 3803 times
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
jstotz
Newbie
Posts: 10
Joined: Thu Jan 22, 2015 7:47 pm

Re: Padding the suffix in the split element

Post by jstotz »

Thanks, but that doesn't do what I want. I'm already using the [index] as a suffix but I want to modify it by padding it to 3 digits using the javascript padstart method.
Post Reply