コード例 #1
0
ファイル: WebHelp.py プロジェクト: amake/kolekti
    def generate(self,pivot,css,pubpath,template):
        xslt=self.get_xsl('generate.xsl')
        templdir=os.path.join(self.publisher.model.projectpath,'design','publication',self._plugin,'config')+os.path.sep
        try:
            doc=xslt(pivot,
                     pubdir=u"'%s'"%pubpath.decode(self.LOCAL_ENCODING),
                     css=u"'%s'"%css.decode(self.LOCAL_ENCODING),
                     templatedir=u"'%s'"%templdir.decode(self.LOCAL_ENCODING),
                     template=u"'%s'"%template.decode(self.LOCAL_ENCODING),
                     label=u"'%s'"%self.label)
        except PublisherError:
            raise
        except:
            debug("ERROR FROM XSL")
            debug(xslt.error_log)
            raise Exception

        iff=file(os.path.join(pubpath,self.label.encode(self.LOCAL_ENCODING),'index.html'),'w')
        iff.write(str(doc))
        iff.close()
コード例 #2
0
ファイル: princexmlcsv.py プロジェクト: vbdx/kolekti-cli
    def generate_pdf(self, piv, css, pdf):
        ''' Generate pdf file with princeXML '''
        cmd = 'prince "%s" -s "%s" -o "%s"' %(piv, css, pdf)
        cmd = cmd.encode(self.LOCAL_ENCODING)
        debug(cmd)

        import subprocess
        (child_stdin, child_stdout, child_stde) = subprocess.os.popen3(cmd)
        child_stdin.close()
        err = child_stde.read()
        out = child_stdout.read()
        err = err.decode(self.LOCAL_ENCODING)
        out = out.decode(self.LOCAL_ENCODING)

        if not re.search(u'error', err) is None:
            yield(self.publisher.view.error(self.publisher.setmessage(u"[0074]Erreur lors de l'exécution de la commande : %(cmd)s (%(error)s)", {'cmd': cmd.decode(self.LOCAL_ENCODING), 'error': err})))
            raise Exception, 'Failed to execute cmd'
        else:
            outfile = '%s.pdf' %self.publisher.docname
            outref = '/'.join((self.publisher.model.pubdirurl, self.label, '%s.pdf' %self.publisher.docname))
            yield (self.publisher.view.publink(outfile,
                                            self.label,
                                            outref))
コード例 #3
0
ファイル: odtpdf.py プロジェクト: vbdx/kolekti-cli
 def exportDocUno(self, filepath, pdfname, pdfproperties):
     debug("Export to pdf")
     #calculate the url
     self._cwd = systemPathToFileUrl(dirname(filepath))
     fileUrl = systemPathToFileUrl(filepath)
     inProps = PropertyValue("Hidden" , 0 , True, 0),
     
     #load the document
     debug("load")
     self._doc = self._desktop.loadComponentFromURL(fileUrl, '_blank', 0, inProps)
     self._doc.reformat()
     #try:
     #    self._exportToPDF('/tmp/nocreate')
     #except:
     #    pass
     f = self._doc.CurrentController.Frame
     debug("repaginate")
     self.dispatcher.executeDispatch(f, ".uno:Repaginate", "", 0, ())
     debug("update index")
     self._updateIndex()
     debug("read properties")
     self._readProperties(pdfproperties)
     debug("export")
     self._exportToPDF(pdfname)
     debug("dispose")
     self._doc.dispose()
     debug("end pdf generation")