This script prompts the user for a file (presumably a
.bike file), opens it in Google Chrome as HTML, and then displays Chrome’s print dialog.
The script offers further customization options for printing a Bike document, whether it’s scaling it correctly (setting margins, etc.) or adding custom styling rules using Chrome’s DevTools.
NOTE: The script assumes you have Google Chrome installed. You can modify the script as needed.
To test in
- Copy & paste the entire script from behind the expansion triangle below.
- Select a
- Click “Run”.
-- Prompt user to choose a file set theFile to choose file with prompt "Select your file:" -- Create a temporary path with .html extension set filePath to POSIX path of theFile set tempFilePath to filePath & ".temp.html" -- Copy the original file to the temporary path do shell script "cp " & quoted form of filePath & " " & quoted form of tempFilePath -- Open the temporary file with Google Chrome do shell script "/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome " & quoted form of tempFilePath -- Introduce a 0.5-second delay before sending the keystroke delay 0.5 -- Send a simulated Command + P keystroke to the Chrome window tell application "System Events" tell process "Google Chrome" keystroke "p" using command down end tell end tell -- Delete the temporary file do shell script "rm " & quoted form of tempFilePath