Changes in / [e843a1c:0c4bca6] in sasview


Ignore:
Location:
src/sas/perspectives
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/perspectives/fitting/report_dialog.py

    r4ec242e rd06ae30  
    1717import os 
    1818import wx.html as html 
    19 import logging 
    2019 
    2120_STATICBOX_WIDTH = 480 
     
    298297        """ 
    299298        Create a PDF file from html source string. 
    300         Returns True is the file creation was successful.  
    301299         
    302300        : data: html string 
    303301        : filename: name of file to be saved 
    304302        """ 
    305         try: 
    306             from xhtml2pdf import pisa 
    307             # open output file for writing (truncated binary) 
    308             resultFile = open(filename, "w+b") 
    309             # convert HTML to PDF 
    310             pisaStatus = pisa.CreatePDF(data, dest=resultFile) 
    311             # close output file 
    312             resultFile.close() 
    313             self.Update() 
    314             return pisaStatus.err 
    315         except: 
    316             logging.error("Error creating pdf: %s" % sys.exc_value) 
    317         return False 
     303        import ho.pisa as pisa 
     304        f = file(filename, "wb") 
     305        # pisa requires some extra packages, see their web-site 
     306        pdf = pisa.CreatePDF(data, f) 
     307 
     308        # close the file here otherwise it will be open until quitting 
     309        #the application. 
     310        f.close() 
     311        self.Update() 
     312        return not pdf.err 
  • src/sas/perspectives/invariant/report_dialog.py

    r4ec242e r79492222  
    1818import os 
    1919import wx.html as html 
    20 import logging 
    2120ISPDF = False 
    2221if sys.platform == "win32": 
     
    247246    def HTML2PDF(self, data, filename): 
    248247        """ 
    249         Create a PDF file from html source string. 
    250         Returns True is the file creation was successful.  
     248        Create a PDF file from html source string.  
    251249         
    252250        : data: html string 
    253251        : filename: name of file to be saved 
    254252        """ 
    255         try: 
    256             from xhtml2pdf import pisa 
    257             # open output file for writing (truncated binary) 
    258             resultFile = open(filename, "w+b") 
    259             # convert HTML to PDF 
    260             pisaStatus = pisa.CreatePDF(data, dest=resultFile) 
    261             # close output file 
    262             resultFile.close() 
    263             self.Update() 
    264             return pisaStatus.err 
    265         except: 
    266             logging.error("Error creating pdf: %s" % sys.exc_value) 
    267         return False 
     253        import ho.pisa as pisa 
     254        f = file(filename, "wb") 
     255        # pisa requires some extra packages, see their web-site 
     256        pdf = pisa.CreatePDF(data, f) 
     257        # close the file here otherwise it will be open until quitting 
     258        #the application. 
     259        f.close() 
     260 
     261        return not pdf.err 
     262 
     263         
     264         
Note: See TracChangeset for help on using the changeset viewer.