Tony T1

Q: Automator Watermark PDF Workflow

Seems with every major upgrade, Apple breaks the Automator Watermark PDF Workflow.

Can someone test this workflow in Yosemite so I know if the problem I'm having is with OS X 10.10.

OS X Yosemite (10.10)

Posted on Oct 22, 2014 9:48 AM

Close

Q: Automator Watermark PDF Workflow

  • All replies
  • Helpful answers

Previous Page 2 of 4 last Next
  • by Frank Caggiano,

    Frank Caggiano Frank Caggiano Oct 23, 2014 2:28 PM in response to VikingOSX
    Level 7 (25,782 points)
    Oct 23, 2014 2:28 PM in response to VikingOSX

    Another interesting quirk with the workflow in Yosemite is that when you add the Watermark PDF Documents action to the workflow,  in Mavericks the gray box to the left of the adjustments is filled with a pdf document from the actions resource folder, Bears.pdf, to enable you see what the watermark will look like. In Yosemite that dummy file is not loaded.

  • by Hiroto,

    Hiroto Hiroto Oct 23, 2014 5:31 PM in response to VikingOSX
    Level 5 (7,286 points)
    Oct 23, 2014 5:31 PM in response to VikingOSX

    Hello VikingOSX

     

    As far as I can tell, I had to adjust the values of scale, xOffset and yOffset to let the watermark image (word "Draft") be overlaid correctly on the base pdf. I got these values by trial and error using preview pane of the Automator action (Watermark PDF Documents.action). By the way, the angle parameter is not in radian but degree.

     

    My test watermark.png is generated from Pages 4 document using huge 144 point font, which surely reflects in the specific parameter values I have posted. So I think you may try other scales and offsets or simply try a colour-filled page for watermark, for scale and offsets shouldn't matter much for a whole page to be overlaid somehow.

     

    Good luck,

    H

     

    EDIT: fixed typo

  • by Tony T1,

    Tony T1 Tony T1 Oct 23, 2014 6:12 PM in response to Hiroto
    Level 6 (9,249 points)
    Mac OS X
    Oct 23, 2014 6:12 PM in response to Hiroto

    Hiroto,

     

    I must have used an incorrect flag last night.  Tried again and it works.

     

    Thanks!

     

    VikingOSX, try with the attached: Watermark(COPY).png

    Watermark(COPY).png

  • by Tony T1,

    Tony T1 Tony T1 Oct 23, 2014 6:13 PM in response to Tony T1
    Level 6 (9,249 points)
    Mac OS X
    Oct 23, 2014 6:13 PM in response to Tony T1

    I must have used an incorrect flag last night.  Hiroto's code works in 10.10

  • by $KMoney$,

    $KMoney$ $KMoney$ Oct 23, 2014 7:02 PM in response to Tony T1
    Level 1 (0 points)
    Oct 23, 2014 7:02 PM in response to Tony T1

    Tony,

    I've tried pasting in Hiroto's solution into the terminal but it doesn't seem to make a difference.  I still get the same error every time I try to run the watermark tool.  Is there a way you could walk a noob through the last step or two?

     

    Thanks!

    KH

  • by Tony T1,

    Tony T1 Tony T1 Oct 23, 2014 7:42 PM in response to $KMoney$
    Level 6 (9,249 points)
    Mac OS X
    Oct 23, 2014 7:42 PM in response to $KMoney$

    Copy Hiroto's script into a text editor, save as Watermark.py, then make executable (chmod u+x Watermark.py)

    Copy the COPY.PNG file I posted above to the Desktop (right-click, "Save image to the Desktop)

     

    Here's the command I used:

     

    ~/Desktop/Watermark.py —under —xOffset 15 --yOffset 55 --angle 0 --scale 0.75 --opacity 0.5 --input "Filename.PDF" —output "FilenameCOPY.PDF" ~/Desktop/Watermark(COPY).png
    
  • by Tony T1,

    Tony T1 Tony T1 Oct 23, 2014 8:14 PM in response to Tony T1
    Level 6 (9,249 points)
    Mac OS X
    Oct 23, 2014 8:14 PM in response to Tony T1

    Typos, in above, -under s/b —under (or -u) and -xOffset s/b —xOffset (or -x), - output s/b —outptut (or -o):

     

    ~/Desktop/Watermark.py -—under -—xOffset 15 --yOffset 55 --angle 0 --scale 0.75 --opacity 0.5 --input "Filename.PDF" -—output "FilenameCOPY.PDF" ~/Desktop/Watermark(COPY).png
  • by VikingOSX,

    VikingOSX VikingOSX Oct 23, 2014 8:27 PM in response to Tony T1
    Level 7 (20,819 points)
    Mac OS X
    Oct 23, 2014 8:27 PM in response to Tony T1

    Used Hiroto's updated Python script. Used the Waternark.png that you posted. Used your corrected command-line settings. There is no watermark produced, and the len(args) returns 1.

     

    I tried Hiroto's small shell script with its args unchanged except for my input and output filenames. Like above, it runs ok, and there is no watermark on the output PDF.

     

    Can I say frustrated?

  • by Tony T1,

    Tony T1 Tony T1 Oct 23, 2014 8:46 PM in response to VikingOSX
    Level 6 (9,249 points)
    Mac OS X
    Oct 23, 2014 8:46 PM in response to VikingOSX

    VikingOSX wrote:

     

    Used Hiroto's updated Python script. Used the Waternark.png that you posted. Used your corrected command-line settings. There is no watermark produced, and the len(args) returns 1.

     

     

     

    len(args) sounds like a bad flag — I may still have typo's in my corrected post .  Make sure that there are two dashes before the flags for the long args (i.e. —output), or just use the shortcut (i.e, -o)

     

    I now have this in an Automator Run Shell Script:

     

    ~/Library/Scripts/Watermark.py \
    --under \
    --xOffset 15 \
    --yOffset 55 \
    --angle 0 \
    --scale 0.75 \
    --opacity 0.5 \
    --input "$1" \
    --output "${1%.*} (COPY).${1##*.}" \
    ~/Pictures/Other\ Images/Watermark\(COPY\).png
    
    
    
  • by Tony T1,

    Tony T1 Tony T1 Oct 23, 2014 8:58 PM in response to Tony T1
    Level 6 (9,249 points)
    Mac OS X
    Oct 23, 2014 8:58 PM in response to Tony T1

    Here's a sample output:

     

    Screen Shot 2014-10-23 at 11.56.30 PM.png

  • by VikingOSX,

    VikingOSX VikingOSX Oct 24, 2014 5:40 AM in response to Tony T1
    Level 7 (20,819 points)
    Mac OS X
    Oct 24, 2014 5:40 AM in response to Tony T1

    Ok. After additional fiddling with the args, I now have watermarks using your Watermark.png and my Draft.png. Since my image is 50% transparency text on a transparent background, it does not act as a screen (dimming the underlying page of text) when placed above. I still could not arrive at any setting that would place either image behind the text, but I can live with that.

  • by tiago,

    tiago tiago Nov 7, 2014 5:12 AM in response to VikingOSX
    Level 1 (0 points)
    Nov 7, 2014 5:12 AM in response to VikingOSX

    It works! here is how i did it.

     

    I created a tool_2.py just to don't mess my native watermark with the code that you guys shared.

    Then fixed some indentation erros, since python doesn't like miss indentations and was giving errors. here is my file:

    http://pastebin.com/hNf8MaLT

    Copy this file to your folder at /System/Library/Automator/Watermark\ PDF\ Documents.action/Contents/Resources

     

    Now the watermark workflow so it acts as a print service and show in every document you print:

    The file is here but you will need to create your own since it uses my local folders, its attached so you can open and copy things up

    Basically it have this shell script:

    for f in "$@"

    do

      /System/Library/Automator/Watermark\ PDF\ Documents.action/Contents/Resources/tool_2.py --input "$f" --output /Users/tiagorodrigues/Downloads/print.pdf --v --over --xOffset 0.0 --yOffset 0.0 --angle 0 --scale 0.24 --opacity 1 /Users/tiagorodrigues/Library/Mobile\ Documents/com\~apple\~CloudDocs/Deepend/Watermark/Smuky\ Papel\ de\ Carta\ V6.png

    done

     

    https://www.dropbox.com/sh/56ee5d0xqldjnyb/AAAsYUye18XVTGHiF_pM1LzDa?dl=0

     

    Create a new automation for you with the correct folders and the desired watermark file and fix the scale value if you need to make it the correct size.

     

    Hope you can do it this way.

  • by Tony T1,

    Tony T1 Tony T1 Nov 7, 2014 5:54 AM in response to tiago
    Level 6 (9,249 points)
    Mac OS X
    Nov 7, 2014 5:54 AM in response to tiago

    Just be aware that your solution may break again with the next OS X update.

    You can prevent this by putting your tool_2.py in your local Library (or other) folder.

  • by tiago,

    tiago tiago Nov 7, 2014 6:28 AM in response to Tony T1
    Level 1 (0 points)
    Nov 7, 2014 6:28 AM in response to Tony T1

    True, thanks for the warning. I will make a backup of it but hope apple get a oficial fix soon.

  • by patriqq,

    patriqq patriqq Mar 26, 2015 7:38 AM in response to Tony T1
    Level 1 (0 points)
    Mar 26, 2015 7:38 AM in response to Tony T1

    In my case, I want to get rid of the original file and replace it with a watermarked file with the same filename.  This can be done with the following AppleScript.  You don't need to "Dispense Items Incrementally" with this.  Note I am moving the original file to an arbitrary folder called trashFolder.

    Screen Shot 2015-03-26 at 10.29.04 AM.png

Previous Page 2 of 4 last Next