# HTML2PDF - converts HTML to PDF # Needs 'htmldoc' from Easy Software Products # Send comments to maik.jablonski@uni-bielefeld.de import AccessControl, os def html2pdf(self): """ html2pdf converts a HTML-Page to a PDF-Document """ securityContext=AccessControl.getSecurityManager() if securityContext.checkPermission('View', self): if self.meta_type=='Folder': html = self.index_html(self,self.REQUEST,self.REQUEST.RESPONSE) else: html = self(self,self.REQUEST,self.REQUEST.RESPONSE) (stin,stout) = os.popen2('htmldoc --footer " : " --webpage -t pdf --quiet --jpeg -') stin.write(html) stin.close() pdf = stout.read() stout.close() self.REQUEST.RESPONSE.setHeader('Content-type','application/pdf') self.REQUEST.RESPONSE.setHeader('Content-disposition','inline; filename="%s.pdf"' % (self.getId())) return pdf else: raise AccessControl.Unauthorized