At this writing, we use an XML-RPC server running
elsewhere to do the XSL-FO → PDF conversion step.
This server is undocumented. Within a matter of a few
months our server should be upgraded and it will be
possible to do this using an os.system()
call on the server system.
# - - - c o n v e r t T o P d f
def convertToPdf(foName):
'''Convert the XSL-FO to PDF format.
[ foName is the absolute path to a readable .fo file ->
if XEPPER_URL can convert that file to PDF ->
(file named 'foName' but with its extension replaced by
PDF_EXTENSION) := PDF conversion of the file named
(foName)
else -> raise lib.ScriptError ]
'''
#-- 1
# [ foBase := basename of foName ]
foBase = os.path.basename(foName)
#-- 2
# [ if XEPPER_URL is running the xepper server ->
# s := an xmlrpclib.ServerProxy connected to that server
# else -> raise lib.ScriptError ]
try:
s = xmlrpclib.ServerProxy(XEPPER_URL)
except xmlrpclib.Error, x:
raise lib.ScriptError("PDF converter unavailable: %s" %
str(x))
#-- 3
# [ if s can compile foName into a PDF ->
# (file named 'foName' but with its extension replaced by
# PDF_EXTENSION) := PDF conversion of the file named
# (foName)
# else -> raise lib.ScriptError ]
try:
result = s.xep(foBase)
if result > 0:
raise lib.ScriptError("PDF converter failure code %d" %
result)
except xmlrpclib.Error, x:
raise lib.ScriptError("PDF converter failure: %s" %
str(x))