Go Back   The macosxhints Forums > OS X Help Requests > AppleScript



Reply
 
Thread Tools Rating: Thread Rating: 4 votes, 5.00 average. Display Modes
Old 11-17-2011, 09:34 AM   #1
MVasilakis
Prospect
 
Join Date: Jul 2002
Location: FLA
Posts: 49
wkpdf Automator

Hi,
I found this great command line tool wkpdf for taking web pages and saving it as a pdf. The advantage of this to the built in print to pdf are that it can pint the web page without page breaks. (--paginate no)


I built an Automator action to handle HTML files I have downloaded and convert to pdf.

Pretty simple to do:
Application receives files and folders as input
Run shell script [/bin/bash Pass input: as arguments]
Code:
#! /bin/bash
for file in "$@"
do 
wkpdf --source "$file" --print-background yes --paginate no --output "$file".pdf
done
Works fine.
So I figured well why not make an Automator service that will work directly from within Firefox (or any web browser or application)

So I set up:
Service recieves selected URLs in any application
input is only URLs
Run shell script [/bin/bash Pass input: as arguments]
Code:
mkdir -p ~/Documents/SavedHTML
cd ~/Documents/SavedHTML

wkpdf --source "$@" --print-background yes --paginate no --output "$@".pdf
This wont work. I've tried every combination of "service receives..." I can think of. I've only been able to make it work in safari if I first save the url via action and then pass to the shell script. Problem is I prefer Firefox so this solution, aside from being clunky since it saves the html aslo, wont work for me.

Anyone out there that can offer some assistance?

Last edited by MVasilakis; 11-17-2011 at 09:44 AM.
MVasilakis is offline   Reply With Quote
Old 11-21-2011, 12:16 AM   #2
tw
Hall of Famer
 
Join Date: Apr 2007
Posts: 4,262
My guess would be that $@ is being interpreted as an array (even though there's only one file). try using the for loop like you do in your original example, or try using $1 instead of $@ - either should get the desired URL out of the list of parameters.
__________________
Philosophy is a battle against the bewitchment of our intelligence by means of language. -LW-
tw is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 03:47 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.