[Checkins] SVN: zopyx.convert2/branches/pisa/s fixes for PISA

Andreas Jung andreas at andreas-jung.com
Sun Jun 5 10:57:00 EDT 2011


Log message for revision 121860:
  fixes for PISA
  

Changed:
  U   zopyx.convert2/branches/pisa/setup.py
  U   zopyx.convert2/branches/pisa/src/zopyx/convert2/__init__.py
  A   zopyx.convert2/branches/pisa/src/zopyx/convert2/pisa.py

-=-
Modified: zopyx.convert2/branches/pisa/setup.py
===================================================================
--- zopyx.convert2/branches/pisa/setup.py	2011-06-05 14:37:07 UTC (rev 121859)
+++ zopyx.convert2/branches/pisa/setup.py	2011-06-05 14:57:00 UTC (rev 121860)
@@ -35,7 +35,14 @@
       include_package_data = True,
       test_suite='nose.collector',
       zip_safe=False,
-      install_requires=['setuptools', 'elementtree', 'BeautifulSoup<=3.0.9999', 'pisa', 'reportlab', 'pypdf'],
+      install_requires=[
+          'setuptools', 
+          'elementtree', 
+          'BeautifulSoup<=3.0.9999', 
+          'pisa', 
+          'reportlab', 
+          'pypdf', 
+          'html5lib'],
       namespace_packages=['zopyx'],
       entry_points={'console_scripts': ['html-convert = zopyx.convert2.cli:main',]},
       )

Modified: zopyx.convert2/branches/pisa/src/zopyx/convert2/__init__.py
===================================================================
--- zopyx.convert2/branches/pisa/src/zopyx/convert2/__init__.py	2011-06-05 14:37:07 UTC (rev 121859)
+++ zopyx.convert2/branches/pisa/src/zopyx/convert2/__init__.py	2011-06-05 14:57:00 UTC (rev 121860)
@@ -11,6 +11,7 @@
 import prince
 import xfc
 import calibre
+import pisa
 from convert import Converter
 
 

Copied: zopyx.convert2/branches/pisa/src/zopyx/convert2/pisa.py (from rev 121858, zopyx.convert2/branches/pisa/src/zopyx/convert2/prince.py)
===================================================================
--- zopyx.convert2/branches/pisa/src/zopyx/convert2/pisa.py	                        (rev 0)
+++ zopyx.convert2/branches/pisa/src/zopyx/convert2/pisa.py	2011-06-05 14:57:00 UTC (rev 121860)
@@ -0,0 +1,55 @@
+##########################################################################
+# zopyx.convert2 - SmartPrintNG low-level functionality
+#
+# (C) 2007, 2008, ZOPYX Ltd & Co. KG, Tuebingen, Germany
+##########################################################################
+
+import os
+import sys
+
+from convert import BaseConverter
+from util import runcmd, which, win32, checkEnvironment, newTempfile, execution_shell
+from logger import LOG
+
+from exceptions import ConversionError
+from sx.pisa3.pisa_document import pisaDocument
+
+
+def html2pdf(html_filename, output_filename=None, **options):
+    """ Convert a HTML file to PDF using FOP"""
+
+    if not output_filename:
+        output_filename = newTempfile(suffix='.pdf')
+
+    fin = file(html_filename)
+    fout = file(output_filename, 'wb')
+    pdf = pisaDocument(fin, 
+                       fout,
+                       encoding='utf-8',
+                       debug=True)
+
+    fin.close()
+    fout.close()
+    return dict(output_filename=output_filename,
+                status=0,
+                output='')
+
+
+class HTML2PDF(BaseConverter):
+
+    name = 'pdf-pisa'
+    output_format = 'pdf'
+    visible_name = 'PDF (PISA)'
+    visible = True
+
+    @staticmethod
+    def available():
+        return True
+
+    def convert(self, output_filename=None, **options):
+        result = html2pdf(self.filename, output_filename, **options)
+        return result
+
+from registry import registerConverter
+registerConverter(HTML2PDF)
+



More information about the checkins mailing list