Last active
July 18, 2023 18:14
-
-
Save jacobsalmela/6b6c8f8a3cdbf3583f6d to your computer and use it in GitHub Desktop.
Converts a DOC or DOCX to a PDF with a right-click
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Jacob Salmela | |
# 2016-03-12 | |
# Convert annoying DOCX into PDFs with a right-click | |
# Run this as an Automator Service | |
###### SCRIPT ####### | |
for f in "$@" | |
do | |
# Get the full file PATH without the extension | |
filepathWithoutExtension="${f%.*}" | |
# Convert the DOCX to HTML, which cupsfilter knows how to turn into a PDF | |
textutil -convert html -output "$filepathWithoutExtension.html" "$f" | |
# Convert the file into a PDF | |
cupsfilter "$filepathWithoutExtension.html" > "$filepathWithoutExtension.pdf" | |
# Remove the original file and the temporary HTML file, leaving only the PDF | |
rm "$filepathWithoutExtension.html" >/dev/null | |
done |
My output file ends up being zero bytes and empty. Although the filename is correct and I verified that the html file is being generated properly. The problem is occurring at the cupsfilter step. Do you have any ideas as to why this is happening?
Thanks a lot for creating this!
My output file ends up being zero bytes and empty. Although the filename is correct and I verified that the html file is being generated properly. The problem is occurring at the cupsfilter step. Do you have any ideas as to why this is happening?
Thanks a lot for creating this!
Same issue here!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
from the manual of cupsfilter:
so I suppose with that option line # 17 is not necessary
Thanks for the work!