Open Source Software and Linux

Sep 4 2008   11:54AM GMT

Script Word and OpenOffice documents to pdf

John Little Profile: Xjlittle

Tags:
Storage

I ran into a situation a couple of weeks ago where it would be convenient to script Word and OpenOffice documents into pdf format. One of my jobs here is to create the network and email login documentation for newly hired people. I have the document creation automated through an AutoIT script. I previously posted about AutoIT here.

The next step after creating the Word document is to copy it to my Linux workstation where my Lotus Notes client resides. Once there I want to convert it to pdf and attach it to an email for sending to the new hire’s manager.

I copy the newly created Word document using Putty’s pscp application. This script is called from the AutoIT script that creates the documents. The pscp script is written as follows:

pscp -pw mypassword -r c:\userdocs jslittl@centos5-xvm:/home/jslittl/Documents/Notes-Domino/users2convert

You can place this script at the end of your AutoIT script so that it copies your document to wherever you want. So this is where I am in the process: AutoIT script to create the document => scp the document to my Linux workstation.

I followed the instructions here to setup OpenOffice for scripting the documents to pdf. My script to do so is setup like this:

[jslittl@centos5-xvm userdocs]$ cat convertDir2PDF.sh
#!/bin/sh
for i in *.doc; do echo $i; doc2pdf "$i"; sleep 5; done #this will convert all documents in the directory
# zip newusers *.pdf # this is for when there are a large number documents going to the same place-easier to attach 1 zip file
mv *.doc `pwd`/finished-doc # I created the next 3 directories to hold the finished documents
mv *.pdf `pwd`/finished-pdf
mv *.zip `pwd`/finished
[jslittl@centos5-xvm userdocs]$

That’s it! Just attach them to the email and send them on.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: