[Erp5-report] r9417 - in /erp5/trunk/products/ERP5OOo/Document: OOoDocument.py PdfDocument.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Aug 24 18:30:05 CEST 2006
Author: bartek
Date: Thu Aug 24 18:30:01 2006
New Revision: 9417
URL: http://svn.erp5.org?rev=9417&view=rev
Log:
html representation functions (for web display)
Modified:
erp5/trunk/products/ERP5OOo/Document/OOoDocument.py
erp5/trunk/products/ERP5OOo/Document/PdfDocument.py
Modified: erp5/trunk/products/ERP5OOo/Document/OOoDocument.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/Document/OOoDocument.py?rev=9417&r1=9416&r2=9417&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/Document/OOoDocument.py (original)
+++ erp5/trunk/products/ERP5OOo/Document/OOoDocument.py Thu Aug 24 18:30:01 2006
@@ -376,6 +376,30 @@
except AttributeError:
pass
+ def getHtmlRepresentation(self):
+ '''
+ get simplified html version to display
+ '''
+ # XXX use caching method
+ # we have to figure out which html format to use
+ tgts=[x[1] for x in self.getTargetFormatItemList() if x[1].startswith('html')]
+ if len(tgts)==0:
+ return 'no html representation available'
+ fmt=tgts[0]
+ fmt,data=self.getTargetFile(fmt)
+ cs=cStringIO.StringIO()
+ cs.write(self._unpackData(data))
+ z=zipfile.ZipFile(cs)
+ h='could not extract anything'
+ for f in z.infolist():
+ fn=f.filename
+ if fn.endswith('html'):
+ h=z.read(fn)
+ break
+ z.close()
+ cs.close()
+ return h
+
security.declareProtected(Permissions.View,'getTargetFile')
def getTargetFile(self,format,REQUEST=None):
"""
Modified: erp5/trunk/products/ERP5OOo/Document/PdfDocument.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/Document/PdfDocument.py?rev=9417&r1=9416&r2=9417&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/Document/PdfDocument.py (original)
+++ erp5/trunk/products/ERP5OOo/Document/PdfDocument.py Thu Aug 24 18:30:01 2006
@@ -83,6 +83,22 @@
SearchableText=getSearchableText
+ def getHtmlRepresentation(self):
+ '''
+ get simplified html version to display
+ '''
+ # XXX use caching method
+ if not hasattr(self,'data'):
+ return 'no data'
+ tmp=tempfile.NamedTemporaryFile()
+ tmp.write(self._unpackData(self.data))
+ tmp.seek(0)
+ cmd='pdftohtml -enc UTF-8 -stdout -noframes -i %s' % tmp.name
+ r=os.popen(cmd)
+ h=r.read()
+ tmp.close()
+ r.close()
+ return h
# vim: syntax=python shiftwidth=2
More information about the Erp5-report
mailing list