The zopyx.convert2 package helps you to convert HTML to PDF, RTF, ODT, DOCX and WML using XSL-FO technology or using PrinceXML. This package is used as the low-level API for zopyx.smartprintng.core.
Windows, Unix
Some examples from the Python command-line:
from zopyx.convert2 import Converter
C = Converter('/path/to/some/file.html')
pdf_filename = C('pdf-xinc') # using XINC
pdf2_filename = C('pdf-pisa') # using PISA
pdf3_filename = C('pdf-fop') # using FOP
pdf4_filename = C('pdf-prince') # using FOP
rtf_filename = C('rtf-xfc')
pdt_filename = C('odt-xfc')
wml_filename = C('wml-xfc')
docx_filename = C('docx-xfc')
A very simple command-line converter is also available:
html-convert --format rtf --output foo.rtf sample.html
html-convert has a –test option that will convert some sample HTML. If everything is ok then you should see something like that:
>html-convert --test
Entering testmode
pdf: /tmp/tmpuOb37m.html -> /tmp/tmpuOb37m.pdf
rtf: /tmp/tmpuOb37m.html -> /tmp/tmpuOb37m.rtf
docx: /tmp/tmpuOb37m.html -> /tmp/tmpuOb37m.docx
odt: /tmp/tmpuOb37m.html -> /tmp/tmpuOb37m.odt
wml: /tmp/tmpuOb37m.html -> /tmp/tmpuOb37m.wml
pdf: /tmp/tmpZ6PGo9.html -> /tmp/tmpZ6PGo9.pdf
rtf: /tmp/tmpZ6PGo9.html -> /tmp/tmpZ6PGo9.rtf
docx: /tmp/tmpZ6PGo9.html -> /tmp/tmpZ6PGo9.docx
odt: /tmp/tmpZ6PGo9.html -> /tmp/tmpZ6PGo9.odt
wml: /tmp/tmpZ6PGo9.html -> /tmp/tmpZ6PGo9.wml
The following environment variables can be used to resolve OS or distribution specific problems:
ZOPYX_CONVERT_SHELL - defaults to sh and is used to as shell command to execute external converters
ZOPYX_CONVERT_EXECUTION_MODE - default to process and refers to the method of Python executing external command (by default using the process module. Other value: system, commands
zopyx.convert2 was written by Andreas Jung for ZOPYX Ltd., Tuebingen, Germany.
zopyx.convert2 is published under the Zope Public License (ZPL 2.1). See LICENSE.txt.