示例#1
0
 def convert(self, orig, data, cache=None, filename=None, context=None, **kwargs):
   data = str(orig)
   doc = OOOdCommandTransform(context, filename, data, self.inputs[0])
   pdf = doc.convertTo('pdf')
   if cache is not None:
     cache.setData(pdf)
     return cache
   else:
     stream = OOoDocumentDataStream()
     stream.setData(pdf)
     return stream
示例#2
0
 def convert(self, orig, data, cache=None, filename=None, context=None, **kwargs):
   data = str(orig)
   doc = OOOdCommandTransform(context, filename, data, self.inputs[0])
   builder = OOoBuilder(doc)
   content = builder.extract('content.xml')
   if cache is not None:
     cache.setData(content)
     return cache
   else:
     stream = OOoDocumentDataStream()
     stream.setData(content)
     return stream
示例#3
0
  def convert(self, orig, data, cache=None, filename=None, context=None, **kwargs):
    # Try to recover broken HTML documents, specially regarding encoding used
    html_node = etree.XML(orig, parser=html_parser)
    includeMetaContentType(html_node)
    orig = html.tostring(html_node, encoding='utf-8',
                         include_meta_content_type=True)

    doc = OOOdCommandTransform(context, filename, orig, self.inputs[0])
    odt = doc.convertTo('odt')
    if cache is not None:
      cache.setData(odt)
      return cache
    else:
      stream = OOoDocumentDataStream()
      stream.setData(odt)
      return stream
示例#4
0
 def convert(self,
             orig,
             data,
             cache=None,
             filename=None,
             context=None,
             **kwargs):
     data = str(orig)
     doc = OOOdCommandTransform(context, filename, data, self.inputs[0])
     msword = doc.convertTo('doc')
     if cache is not None:
         cache.setData(msword)
         return cache
     else:
         stream = OOoDocumentDataStream()
         stream.setData(msword)
         return stream
示例#5
0
    def convert(self,
                orig,
                data,
                cache=None,
                filename=None,
                context=None,
                **kwargs):
        # Try to recover broken HTML documents, specially regarding encoding used
        html_node = etree.XML(orig, parser=html_parser)
        includeMetaContentType(html_node)
        orig = html.tostring(html_node,
                             encoding='utf-8',
                             include_meta_content_type=True)

        doc = OOOdCommandTransform(context, filename, orig, self.inputs[0])
        odt = doc.convertTo('odt')
        if cache is not None:
            cache.setData(odt)
            return cache
        else:
            stream = OOoDocumentDataStream()
            stream.setData(odt)
            return stream