Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am creating a few documents in Libre office and I have to always send them as .pdf.

but each and every time I forget to export it as pdf , So is there any way to auto convert the .odt document into pdf every time I save the document ?

I have only about 4 docs , I keep making changes on them , So each and every time I make a change and save the odt I need that change to be updated in the corresponding pdf file .

Ps : I understand that unoconv can be used to convert via command line but is there a way to automatically do it ?

Another Ps : I found out that there is something called inotify and inotify-tools and that can be used to trigger events when a file changes . But I have no idea on how to use it .

share|improve this question
    
You could create a little bash script that does it for you. But you are looking for a way to let LibreOffice to the work? –  queueoverflow Oct 13 '11 at 13:34
    
I actually don't mind how it works whether through a bash script or through LibreOffice as long as it works –  mataug Oct 13 '11 at 13:50

4 Answers 4

up vote 3 down vote accepted

A quick and dirty example using code from the pyinotify project [http://github.com/seb-m/pyinotify]

You will need to change the WATCHED_DIR to your directory containing ODT files. Also remember to install unoconv first.

# Notifier example from tutorial
#
# See: http://github.com/seb-m/pyinotify/wiki/Tutorial
#
# odtwatcher.py

import os
import pyinotify
import subprocess

WATCHED_DIR = '/tmp/test'

wm = pyinotify.WatchManager()  # Watch Manager
mask = pyinotify.IN_MODIFY

class EventHandler(pyinotify.ProcessEvent):
    def process_IN_MODIFY(self, event):
        fname = event.pathname            
        if os.path.splitext(fname)[1] == '.odt':
            print 'MODIFIED: ', fname
            args = ['unoconv', '-f', 'pdf', fname]
            try:
                subprocess.Popen(args)
            except OSError as e:
                print 'Could not convert file %s to PDF. Error %s' % (fname, str(e))

if __name__ == '__main__':
    handler = EventHandler()
    notifier = pyinotify.Notifier(wm, handler)
    wdd = wm.add_watch(WATCHED_DIR, mask, rec=True)        
    notifier.loop()

Save this as odtwatcher.py and then run it in the background

python odtwatcher.py &
share|improve this answer

Try this extension (works well with LibreOffice on Gnome-Shell/Quantal) :

MultiSave enables you to save simultaneoulsly a document in the OpenDocument, MS Office and/or PDF formats as you choose.


MultiFormatSave is a new updated fork of MultiSave designed to work better with recent revisions of Libreoffice:

MultiFormatSave enables you to save simultaneously a document in the OpenDocument, MS Office and/or PDF formats as you choose for Writer, Calc or Impress

Forked fromt the starXpert MultiSave-extension

Make sure to choose the appropriate release for your LibreOffice version, e.g. 1.3.2 for LO 3.5 and 3.6.

share|improve this answer

You can also run libreoffice from the command line for your purpose. This gives you the advantage of batch conversion, but single files are also possible. This example converts all ODT files in the current directory to PDF:

libreoffice --headless --convert-to pdf *.odt

Get more information on command line options with:

man libreoffice

Note: Due to bug 37531, you have to close all running instances of LibreOffice before this command will work.

share|improve this answer

This post explains how to convert odt to pdf from the command-line very simply using CUPS.

http://www.yamamoto.com.ar/blog/?p=50

You can actually batch convert all the odt to pdf from a directory so this would actually save you from having to remember to export to pdf each single time!

Hope this helps!

share|improve this answer
    
I think you have misinterpreted my question ,I have only about 4 docs , but I keep making changes on them , So each and every time I make a change and save I need that change to be updated in the corresponding pdf file . –  mataug Oct 13 '11 at 16:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.