Changeset f2530048 in sasview for src/sas/qtgui/Utilities


Ignore:
Timestamp:
Aug 29, 2018 5:04:23 AM (6 years ago)
Author:
Torin Cooper-Bennun <torin.cooper-bennun@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
e9359e0a
Parents:
906e0c7
Message:

report save functionality: fix saved images not being referenced in the HTML (was also breaking xhtml2pdf)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Utilities/ReportDialog.py

    r5330be2 rf2530048  
    33import re 
    44import logging 
     5import traceback 
    56from xhtml2pdf import pisa 
    67 
     
    100101        pictures = self.getPictures(basename) 
    101102 
    102         # translate png references into html from base64 string to on-disk name 
    103         cleanr = re.compile('<img src.*$') 
     103        # self.data_html contains all images at the end of the report, in base64 form; 
     104        # replace them all with their saved on-disk filenames 
     105        cleanr = re.compile('<img src.*$', re.DOTALL) 
    104106        replacement_name = "" 
    105107        html = self.data_html 
    106108        for picture in pictures: 
    107109            replacement_name += '<img src="'+ picture + '"><p></p>' 
     110        replacement_name += '\n' 
    108111        # <img src="data:image/png;.*>  => <img src=filename> 
    109112        html = re.sub(cleanr, replacement_name, self.data_html) 
     
    178181                return pisaStatus.err 
    179182        except Exception as ex: 
    180             logging.error("Error creating pdf: " + str(ex)) 
     183            # logging.error("Error creating pdf: " + str(ex)) 
     184            logging.error("Error creating pdf: " + traceback.format_exc()) 
    181185        return False 
    182186 
Note: See TracChangeset for help on using the changeset viewer.