* src/plugins/GraphViz.py: 0000627: Relationship graph PDF papersize problems.
Use ghostscript instead of epstopdf svn: r7905
This commit is contained in:
parent
b26df1c195
commit
d1130cd58a
@ -1,3 +1,7 @@
|
|||||||
|
2007-01-14 Brian Matherly <brian@gramps-project.org>
|
||||||
|
* src/plugins/GraphViz.py: 0000627: Relationship graph PDF papersize problems.
|
||||||
|
Use ghostscript instead of epstopdf
|
||||||
|
|
||||||
2007-01-13 Don Allingham <don@gramps-project.org>
|
2007-01-13 Don Allingham <don@gramps-project.org>
|
||||||
* po/gramps.pot: update
|
* po/gramps.pot: update
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
import os
|
import os
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from time import asctime
|
from time import asctime
|
||||||
|
import tempfile
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -125,14 +126,23 @@ class _options:
|
|||||||
('', "Descendants - Ancestors", _("Descendants - Ancestors")),
|
('', "Descendants - Ancestors", _("Descendants - Ancestors")),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
gs_cmd = ""
|
||||||
|
|
||||||
if os.sys.platform == "win32":
|
if os.sys.platform == "win32":
|
||||||
_dot_found = Utils.search_for("dot.exe")
|
_dot_found = Utils.search_for("dot.exe")
|
||||||
|
|
||||||
|
if Utils.search_for("gswin32c.exe") == 1:
|
||||||
|
gs_cmd = "gswin32c.exe"
|
||||||
|
elif Utils.search_for("gswin32.exe") == 1:
|
||||||
|
gs_cmd = "gswin32.exe"
|
||||||
else:
|
else:
|
||||||
_dot_found = Utils.search_for("dot")
|
_dot_found = Utils.search_for("dot")
|
||||||
|
|
||||||
if Utils.search_for("epstopdf") == 1:
|
if Utils.search_for("gs") == 1:
|
||||||
|
gs_cmd = "gs"
|
||||||
|
|
||||||
|
if gs_cmd != "":
|
||||||
_options.formats += (("pdf", "PDF", _("PDF"), "application/pdf"),)
|
_options.formats += (("pdf", "PDF", _("PDF"), "application/pdf"),)
|
||||||
_pdf_pipe = 'epstopdf -f -o=%s'
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -1158,7 +1168,9 @@ class GraphVizGraphics(Report):
|
|||||||
self.doc = options_class.get_document()
|
self.doc = options_class.get_document()
|
||||||
|
|
||||||
self.user_output = options_class.get_output()
|
self.user_output = options_class.get_output()
|
||||||
self.junk_output = os.path.join(const.home_dir,"junk")
|
(handle,self.junk_output) = tempfile.mkstemp(".dot", "rel_graph" )
|
||||||
|
os.close( handle )
|
||||||
|
|
||||||
self.the_format = self.options_class.handler.options_dict['gvof']
|
self.the_format = self.options_class.handler.options_dict['gvof']
|
||||||
self.the_font = self.options_class.handler.options_dict['font']
|
self.the_font = self.options_class.handler.options_dict['font']
|
||||||
|
|
||||||
@ -1170,26 +1182,31 @@ class GraphVizGraphics(Report):
|
|||||||
|
|
||||||
def end_report(self):
|
def end_report(self):
|
||||||
if self.the_format == "pdf":
|
if self.the_format == "pdf":
|
||||||
command = ('dot -Tps %s | ' + _pdf_pipe + ' ; rm %s') % \
|
# Create a temporary Postscript file
|
||||||
(self.junk_output,self.user_output,self.junk_output)
|
(handle,tmp_ps) = tempfile.mkstemp(".ps", "rel_graph" )
|
||||||
os.system(command)
|
os.close( handle )
|
||||||
else:
|
|
||||||
os.system('dot -T%s -o"%s" "%s"' %
|
|
||||||
(self.the_format,self.user_output,self.junk_output) )
|
|
||||||
os.remove(self.junk_output)
|
|
||||||
|
|
||||||
if self.doc.print_req:
|
# Generate Postscript using dot
|
||||||
_apptype = None
|
command = 'dot -Tps -o"%s" "%s"' % ( tmp_ps, self.junk_output )
|
||||||
for format in _options.formats:
|
os.system(command)
|
||||||
if format[0] == self.the_format:
|
|
||||||
_apptype = format[3]
|
paper = self.options_class.handler.get_paper()
|
||||||
break
|
# Add .5 to remove rounding errors.
|
||||||
if _apptype:
|
width_pt = int( (paper.get_width_inches() * 72) + 0.5 )
|
||||||
try:
|
height_pt = int( (paper.get_height_inches() * 72) + 0.5 )
|
||||||
app = Mime.get_application(_apptype)
|
|
||||||
Utils.launch(app[0],self.user_output)
|
# Convert to PDF using ghostscript
|
||||||
except:
|
command = '%s -q -sDEVICE=pdfwrite -dNOPAUSE -dDEVICEWIDTHPOINTS=%d -dDEVICEHEIGHTPOINTS=%d -sOutputFile="%s" "%s" -c quit' \
|
||||||
pass
|
% ( gs_cmd, width_pt, height_pt, self.user_output, tmp_ps )
|
||||||
|
os.system(command)
|
||||||
|
|
||||||
|
os.remove(tmp_ps)
|
||||||
|
|
||||||
|
else:
|
||||||
|
os.system('dot -T%s -o"%s" "%s"' %
|
||||||
|
(self.the_format,self.user_output,self.junk_output) )
|
||||||
|
|
||||||
|
os.remove(self.junk_output)
|
||||||
|
|
||||||
if self.doc.print_req:
|
if self.doc.print_req:
|
||||||
_apptype = None
|
_apptype = None
|
||||||
|
Loading…
Reference in New Issue
Block a user