File tree 1 file changed +5
-7
lines changed
1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -95,16 +95,14 @@ def _set_source_file_name(self):
95
95
96
96
def _return_response (self , file_src , basename ):
97
97
"""Read the generated pdf and return it in a django HttpResponse."""
98
- try :
99
- # Open the file created by PhantomJS
100
- return_file = open (file_src , 'r' )
101
- except IOError :
102
- exc_msg = "The PDF was not created. Enable debug at RequestToPDF instance."
103
- raise Exception (exc_msg )
98
+ # Open the file created by PhantomJS
99
+ return_file = None
100
+ with open (file_src , 'rb' ) as f :
101
+ return_file = f .readlines ()
104
102
105
103
response = HttpResponse (
106
104
return_file ,
107
- mimetype = 'application/force-download '
105
+ content_type = 'application/pdf '
108
106
)
109
107
content_disposition = 'attachment; filename=%s.pdf' % (basename )
110
108
response ['Content-Disposition' ] = content_disposition
You can’t perform that action at this time.
0 commit comments