You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automator: Watermark PDF Documents not working

Hi,


The "Watermark PDF Documents" action of Automator is not working.


No matter which files you choose, and I tested a lot of combinations, the action ends up with the following error:


"Watermark PDF Watermark failed - 1 error"

"Command line tool returned error 1. (1)"


User uploaded file


I have a clean Install of Yosemite. I tested with 2 more Mac Book Pro's with Yosemite and the same happen.


To replicate you just have to create a new Automator, with 2 actions:

- Get Specified Finder Items, and choose a PDF file

- Watermark PDF Documents, and choose a PNG or JPG file


Run and see the error.


Thank you.

MacBook Pro, OS X Mavericks (10.9)

Posted on Oct 23, 2014 3:24 AM

Reply
53 replies

Jan 9, 2015 11:42 AM in response to Hiroto

Hiroto Sir you are a lifesaver. Many thanks for the Python script to fix this. Our business relies on 4 scripts to merge/chop/resize and watermark in and outbound PDF's for invoicing and deliveries - we have been running manual on Yosemite until I found your solution. 30 mins in and I have 1 of 4 scripts fixed, it will be a breeze to duplicate now I have it working. Thanks for your help. 🙂


[Yosemite Automator PDF Fix]

Jan 18, 2015 2:01 PM in response to Tony T1

Hello Tony! I have the same problem, and I followed everything from your post of November the 16th where you say to change line 29, add a line after line 75, and execute the file.


My files are:

~/Desktop/tool.py

~/Desktop/input.PDF

~/Desktop/watermark.jpg


I did the check with ~/Desktop/tool.py -h which seems fine. In Automater I removed the unnecessary spaces:

~/Desktop/tool.py \

--under \

--xOffset 0.7 \

--yOffset -5 \

--angle 0 \

--scale 0.24 \

--opacity 1 \

--input "$1" \

--output "${1%.*} (COPY).${1##*.}" \

~/Desktop/watermark.jpg


But that gives me the traceback error. And if I run it in Terminal with ~/Desktop/tool.py --input ~Desktop/input.PDF --output ~/Desktop/WaterMarked.pdf ~/Desktop/watermark.jpg I get the following:


['/Users/home/Desktop/tool.py', '--input', '~Desktop/input.PDF', '--output', '/Users/home/Desktop/WaterMarked.pdf', '/Users/home/Desktop/watermark.jpg']

--input ~Desktop/input.PDF

--output /Users/home/Desktop/WaterMarked.pdf

Traceback (most recent call last):

File "/Users/home/Desktop/tool.py", line 140, in <module>

main(sys.argv[1:])

File "/Users/home/Desktop/tool.py", line 131, in main

watermark(readFilename, args, writeFilename, under, xOffset, yOffset, angle, scale, opacity, verbose);

File "/Users/home/Desktop/tool.py", line 40, in watermark

images = map(createImage, watermarkFiles)

File "/Users/home/Desktop/tool.py", line 30, in createImage

if provider:

NameError: global name 'provider' is not defined

MacBook-Pro-3:~ home$


On December the 4th however, you say to add a code after line 32. But that gives me the following:


['/Users/artnaz/Desktop/tool.py', '--input', '~Desktop/input.PDF', '--output', '/Users/artnaz/Desktop/WaterMarked.pdf', '/Users/artnaz/Desktop/watermark.jpg']

--input ~Desktop/input.PDF

--output /Users/home/Desktop/WaterMarked.pdf

Traceback (most recent call last):

File "/Users/home/Desktop/tool.py", line 141, in <module>

main(sys.argv[1:])

File "/Users/home/Desktop/tool.py", line 132, in main

watermark(readFilename, args, writeFilename, under, xOffset, yOffset, angle, scale, opacity, verbose);

File "/Users/home/Desktop/tool.py", line 41, in watermark

images = map(createImage, watermarkFiles)

File "/Users/home/Desktop/tool.py", line 30, in createImage

if provider:

UnboundLocalError: local variable 'provider' referenced before assignment

MacBook-Pro-3:~ artnaz$


Could you please help? It would be highly appreciated! Thanks!

Jan 19, 2015 6:27 AM in response to artnaz

artnaz wrote:


Hello Tony! I have the same problem, and I followed everything from your post of November the 16th where you say to change line 29, add a line after line 75, and execute the file.


Making the edits to tool.py should have worked, however, try copying the entire code of the modified tool.py posted by Hiroto here: Automator Watermark PDF Workflow

Mar 23, 2015 12:34 PM in response to Re.flex

Guys, I had to change the locations of my folders and now it doesn't work anymore. Of course I need to update the references/locations in Automator, but the tool.py gives me errors. Shouldn't it be independent from the location? Anyway, I copied the file to my desktop, repasted Hiroto's script (which previously worked), made the file executable (chmod u+x), but it gives me the following errors if I use ~/Desktop/tool.py:


['/Users/user/Desktop/tool.py']

Traceback (most recent call last):

File "/Users/user/Desktop/tool.py", line 143, in <module>

main(sys.argv[1:])

File "/Users/user/Desktop/tool.py", line 136, in main

shutil.copyfile(readFilename, writeFilename);

NameError: global name 'shutil' is not defined


Any idea what it means and what I could do? Thanks!

Mar 24, 2015 6:03 AM in response to artnaz

artnaz wrote:


Guys, I had to change the locations of my folders and now it doesn't work anymore. Of course I need to update the references/locations in Automator, but the tool.py gives me errors. Shouldn't it be independent from the location?

Any idea what it means and what I could do? Thanks!


Try copying Hiroto's script again. Changing the location of the script should not have any effect.

Automator: Watermark PDF Documents not working

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.