示例#1
0
 def exportPDF(self, doc, path_save, options):
     """
         Export to PDF
         http://wiki.services.openoffice.org/wiki/API/Tutorials/PDF_export
     """
     close = False
     if isinstance(doc, str):
         close = True
         doc = self.openDoc(doc, (('Hidden', True), ))
     if path_save:
         if comun.isdir(path_save):
             path_save = comun.replace_name_ext(path_save, doc.getURL(),
                                                EXT_PDF)
     else:
         path_save = comun.replace_ext(doc.getURL(), EXT_PDF)
     path_save = comun.path_to_url(path_save)
     try:
         filter_name = '{}_pdf_Export'.format(self.getTypeDoc(doc))
         if options:
             filter_data = comun.set_properties(options)
             filter_options = (
                 ('FilterName', filter_name),
                 ('FilterData', filter_data),
             )
         else:
             filter_options = (('FilterName', filter_name), )
         media_descriptor = comun.set_properties(filter_options)
         doc.storeToURL(path_save, media_descriptor)
     except:
         log.error('PDF', exc_info=True)
     if close:
         doc.dispose()
     if comun.exists(path_save):
         return comun.path_to_os(path_save)
     return ''
示例#2
0
 def exportPDF(self, doc, path_save, options):
     """
         Export to PDF
         http://wiki.services.openoffice.org/wiki/API/Tutorials/PDF_export
     """
     close = False
     if isinstance(doc, str):
         close = True
         doc = self.openDoc(doc, (('Hidden', True),))
     if path_save:
         if comun.isdir(path_save):
             path_save = comun.replace_name_ext(path_save, doc.getURL(), EXT_PDF)
     else:
         path_save = comun.replace_ext(doc.getURL(), EXT_PDF)
     path_save = comun.path_to_url(path_save)
     try:
         filter_name = '{}_pdf_Export'.format(self.getTypeDoc(doc))
         if options:
             filter_data = comun.set_properties(options)
             filter_options = (
                 ('FilterName', filter_name),
                 ('FilterData', filter_data),
             )
         else:
             filter_options = (('FilterName', filter_name),)
         media_descriptor = comun.set_properties(filter_options)
         doc.storeToURL(path_save, media_descriptor)
     except:
         log.error('PDF', exc_info=True)
     if close:
         doc.dispose()
     if comun.exists(path_save):
         return comun.path_to_os(path_save)
     return ''
示例#3
0
 def zip(self, source, target):
     if comun.isdir(source):
         comun.zip_dir(source, target)
     else:
         comun.zip_file(source, target)
     return
示例#4
0
 def zip(self, source, target):
     if comun.isdir(source):
         comun.zip_dir(source, target)
     else:
         comun.zip_file(source, target)
     return