def create_rtf(matiere): httpResponse = render_to_response('coeur/matiere_rtf.html', {'matiere' : matiere, }) filename = '/tmp/rtf/%s %s.rtf' % (matiere.promotion, matiere.titre) f = open(filename, 'w') doc = XHTMLReader.read(httpResponse.content, "") Rtf15Writer.write(doc , f) return filename
from pyth.plugins.xhtml.reader import XHTMLReader from pyth.plugins.rtf15.writer import Rtf15Writer import sys if len(sys.argv) > 1: filename = sys.argv[1] else: filename = "tests/html/sample-with-image.html" source = open(filename, "rb") doc = XHTMLReader.read(source) print Rtf15Writer.write(doc).getvalue()
from pyth.plugins.rtf15.writer import Rtf15Writer import pythonDoc doc = pythonDoc.buildDoc() print Rtf15Writer.write(doc).getvalue()