Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Easily convert Word documents to PDFs UNIX
Are you too cheap to buy MS Office? Well, this may be the solution to your document-sharing woes. The following script will convert .doc files to .pdf files. You need to have antiword and ghostscript installed -- both are available via fink.

#!/bin/bash
INPUT_FILE=$*
OUTPUT_FILE=${INPUT_FILE%.doc}.pdf
echo "INPUT_FILE=${INPUT_FILE} OUTPUT_FILE=${OUTPUT_FILE}"
antiword -p letter "$INPUT_FILE" | ps2pdf - "$OUTPUT_FILE"
Just paste this into a file named doc2pdf, make sure it is in your path, then type chmod +x doc2pdf to make it executable, and fire away.
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[5,657 views]  

Easily convert Word documents to PDFs | 8 comments | Create New Account
Click here to return to the 'Easily convert Word documents to PDFs' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Easily convert Word documents to PDFs
Authored by: DougAdams on Oct 13, '03 11:10:54AM

Cool tip. But does this method have any advantages over printing to PDF?



[ Reply to This | # ]
Easily convert Word documents to PDFs
Authored by: vogunaescht on Oct 13, '03 11:15:51AM

You don't have to have Word installed to use this hint, that's the big advantage. And Antiword and Ghostscript are free. That's also an advantage.



[ Reply to This | # ]
Too Cheap!
Authored by: prk on Oct 13, '03 11:19:09AM

I would not say too cheap when the software is $500!!!! MS Office costs more than a low end Mac's.

But, everyone has it so I conclude that they are steeling it. Where can I get a copy? ;-)



[ Reply to This | # ]
Too Cheap!
Authored by: rusto on Oct 14, '03 07:55:55AM

"Everyone" has cars too, are they stolen as well?



[ Reply to This | # ]
Easily convert Word documents to PDFs
Authored by: vogunaescht on Oct 13, '03 11:19:47AM
Those uncomfortable with the shell might want to look at AntiWord Service.
It provides antiword translation to any service-aware application.

[ Reply to This | # ]
Considerations
Authored by: Lectrick on Oct 13, '03 12:08:50PM

1) Panther, to be released shortly, will open .doc files in TextEdit.
2) If you need a non-Microsoft OS X office suite, take a look at OpenOffice.org or ThinkFree Office.

None of these are perfect solutions, but there ARE other options.

---
In /dev/null, no one can hear you scream



[ Reply to This | # ]
Easily convert Word documents to PDFs
Authored by: joebeone on Oct 13, '03 01:38:21PM

There's many things that antiword and ghostscript cannot do... I would recommend installing (and donating to!) OpenOffice.org, print to a postcript and then use ps2pdf... not a one-liner but much more consistent and agreeable for a production environment.



[ Reply to This | # ]
Easily convert Word documents to PDFs
Authored by: MichaelJJ on Nov 14, '03 06:15:18PM

How can this be done with OpenOffice over the web? Several people have told me that it can't be done with OpenOffice via the command line.

I too need to convert MS Word Docs to PDF and I need to do it via a PHP script. I need to allow users to upload Word docs and have those files converted to PDF files. The people I'm dealing with aren't tech saavy at all and would have trouble doing something as simple as printing to a postscript file first.

I'm going to try the AntiWord and Ghostscript solution, but if there's a way to do it with OpenOffice, I'd love to hear it.

Thanks!



[ Reply to This | # ]