Il 17/09/2011 18:31, Julien Rioux ha scritto:
Ahh, I just found out why I couldn't find this email anymore... you didn't include the list.
sorry about that.

So is the script needed only because libreoffice produces bad eps?

that depends on how you expect it to be called. If the output filename (referred to as "$$o" in the script invocation line) is only constrained to be equal to the input file-name with the extension changed, then the trick you're proposing (eps2) should work without scripts, but we'd need a "$$" variable to refer to the destination folder. However, if in principle $$o may be an arbitrary file-name as compared to $$i, then we do need a script, because all you can do with libreoffice is specify a destination *folder*, and the file-name is always equal to the input file-name, with extension changed to ".eps".

If so then there's at least another way, using a new format eps2, just like there is dvi2 for "not clean" dvi (on windows).

so, anyway, you're the expert(s) in this area -- I've attached the script that was missing in my last patch, which should work on Windows too -- so, please, feel free to propose the best solution in this ODG case.

    T.
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# file libreoffice2eps.py
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.
#
# \author Tommaso Cucinotta
#
# Full author contact details are available in file CREDITS


# This script converts an OpenOffice drawing to EPS.

# Usage:
#   python libreoffice2eps.py input.odg output.eps

import os, sys, tempfile, shutil

def runCommand(cmd):
    ''' Utility function:
        run a command, quit if fails
    '''
    if os.system(cmd) != 0:
        print "Command '%s' failed." % cmd
        sys.exit(1)

# We expect two args, the names of the input and output files.
if len(sys.argv) != 3:
    sys.exit(1)

input, output = sys.argv[1:]

# Fail silently if the file doesn't exist
if not os.path.isfile(input):
    sys.exit(0)

tmpdir = tempfile.mkdtemp()
fname = os.path.splitext(os.path.basename(input))[0]

# Generate the EPS file
runCommand('libreoffice -nologo -convert-to eps -outdir "%s" "%s"' % (tmpdir, input))
shutil.move('%s/%s.eps' % (tmpdir, fname), '%s/%s.ps' % (tmpdir, fname))
runCommand('ps2eps "%s/%s.ps"' % (tmpdir, fname))
shutil.move('%s/%s.eps' % (tmpdir, fname), output)
os.remove('%s/%s.ps' % (tmpdir, fname))
os.rmdir(tmpdir)

Reply via email to