Phillip Briggs

Q: Applescript to Duplicate PDF (x) number of times

Is is possible to duplicate a PDF a variable number of times?

 

Ideally I want to take a single page PDF and duplicate the page {n} number of times within the PDF file, to create a multiple page PDF.

 

I'd be launching this from Esko Automation Engine and passing the PDF and the variable quantity to the script - applescript or shell script.

 

Any help would be greatly appreciated!

Posted on Aug 8, 2016 12:21 AM

Close

Q: Applescript to Duplicate PDF (x) number of times

  • All replies
  • Helpful answers

Previous Page 2
  • by Hiroto,

    Hiroto Hiroto Aug 9, 2016 10:55 AM in response to Phillip Briggs
    Level 5 (7,281 points)
    Aug 9, 2016 10:55 AM in response to Phillip Briggs

    Hello

     

    You're welcome and glad to hear you found solution.

     

    I used negative indices for the last two list items (i.e., output directory and duplicate count) because I wrote code to accept variable number of arguments for input pdf files. Esko only requires input files are to be joined with : (colon) and thus the input pdfs consume one and only one argument whereas my python code is written to accept such input file argument as required by Esko as well as normal input file arguments separated by white space.

     

    E.g., my shell script can be called in any ways as:

     

     

    script.sh a.pdf:b.pdf:c.pdf:d.pdf out 2
    
    script.sh a.pdf b.pdf c.pdf d.pdf out 2
    
    script.sh a.pdf:b.pdf c.pdf:d.pdf out 2
    
    etc.
    

     

     

     

    So it implemented optional argument processing at a cost of slightly more complicated coding.

     

     

    ---

    And here's a minor correction on argument count test, which will not surface if proper arguments are given.

     

     

    WRONG:

     

     

    def main():
        uargv = [ a.decode('utf-8') for a in sys.argv ]
        if len(uargv) < 3: usage()
        ...
    

     

     

     

    CORRECT:

     

     

    def main():
        uargv = [ a.decode('utf-8') for a in sys.argv ]
        if len(uargv) < 4: usage()
        ...
    

     

     

     

    All the best,

    Hiroto

Previous Page 2