Didier Gabory a écrit :
Merci Jean-Pierre et Julien pour le temps que vous consacrer à m'aider...
La meilleure option à mon avis est de créer un convertisseur du fichier
de type epslatex par exemple (i.e. nommer essai1.tex essai1.epslatex) et
d'associer un script du style de celui utilisé pour xfig (voir dans le
répertoire scripts de la dustribution LyX). Peut-être même qu'une
duplication du convertisseur EPS->PDF suffit, je n'ai pas le temps de
tester maintenant, je vous tiens au courant.
J'ai copié le fichier external_templates dans mon répertoire perso
et j'ai ajouté à la fin:
Template GnuplotExport
GuiName "GnuplotExport: $$AbsOrRelPathParent$$Basename"
HelpText
Pdf conversion of the eps part of a gnuplot export
HelpTextEnd
InputFormat eps
FileFilter "*.tex"
AutomaticProduction true
Transform Rotate
Transform Resize
Preview InstantPreview
Format PDFLaTeX
Product "\\input{$$AbsOrRelPathMaster$$Basename.epslatex}"
UpdateFormat pdf
UpdateResult "$$AbsPath$$Basename.pdf"
Requirement "color"
Requirement "graphicx"
# Preamble WarnNotFound
# Preamble InputOrWarn
ReferencedFile pdflatex "$$AbsPath$$Basename.eps"
ReferencedFile pdflatex "$$AbsPath$$Basename.pdf"
FormatEnd
TemplateEnd
J'ai créé un convertisseur gs2pdf.py dans mon répertoire perso
scripts.py
J'ai défini un format GnuplotExport de nom court epslatex et de suffixe
esplatex
J'ai défini un convertisseur GunplotExport de epslatex vedrs PDF
(ps2pdf) qui appelle le convertisseur gs2pdf.py
9a ne marche pas encore parce que le convertisseur ne trouve pas le
fichier .eps que n'est pas copié dans le temporaire, mais j'ai bon espoir...
--
Jean-Pierre
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# file gp2pdf.py
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.
#
# \author Angus Leeming
# \author Bo Peng
#
# Full author contact details are available in file CREDITS
# modified from fig2pdftex by Jean-Pierre Chr\'etien
#<[email protected]>
# This script converts the eps part of a gnuplot export
# into high quality PDF.
# Usage:
# python gp2pdf.py ${base}.epslatex ${base}.pdf
# This command generates
# ${base}.pdf the converted pdf file
#
# Note:
# Do not use this command as
# python gp2pdftex.py file.epslatex file.pdf
# the real pdf file will be overwritten by a tex file named file.pdf.
#
import os, sys, re, tempfile
def runCommand(cmd):
''' Utility function:
run a command, quit if fails
'''
if os.system(cmd) != 0:
print "Command '%s' fails." % 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)
# Strip the extension from ${output}
outbase = os.path.splitext(output)[0]
# manipulates the Bounding Box info to enable gs to produce
# the appropriate PDF file from an EPS one.
# The generated PostScript commands are extracted from epstopdf, distributed
# with tetex.
epsfile = outbase + '.eps'
tmp = tempfile.mkstemp()
boundingboxline = re.compile('%%BoundingBox:\s+(\d*)\s+(\d*)\s+(\d*)\s+(\d*)')
for line in open(epsfile).xreadlines():
if line[:13] == '%%BoundingBox':
(llx, lly, urx, ury) = map(int, boundingboxline.search(line).groups())
width = urx - llx
height = ury - lly
xoffset = - llx
yoffset = - lly
tmp.write('''%%%%BoundingBox: 0 0 %d %d
<< /PageSize [%d %d] >> setpagedevice
gsave %d %d translate
''' % (width, height, width, height, xoffset, yoffset))
else:
tmp.write(line)
tmp.close()
# direct move(rename) may fail under windows
os.unlink(epsfile)
os.rename(epsfile + '.??', epsfile)
# Convert the ${pstex} EPS file (free of "special" text) to PDF format
# using gs
runCommand('gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile=%s.pdf %s.pstex'\
% (outbase, outbase))
os.unlink(epsfile)