0

I am attempting to stream a PDF file created by FPDF. The data for the PDF is generated perfectly and I send the stream back using Flask make_response setting the headers like this:

response.headers.set('Content-Type', 'application/pdf')
response.headers.set('Content-Disposition', 'inline; filename="ledger.pdf"')                                            

I am using Apache2 mod_wsgi module to host the the API that generates this PDF. My problem is: The PDF stream gets sent to Apache's error log. Am I going about this the wrong way or is there a setting that I am missing in Apache that allows the stream to go back to the client?

My Python version is 3.9 running on Ubuntu Linux Server

Elcid_91
  • 1,571
  • 4
  • 24
  • 50
  • Does this answer your question? [Flask handling a PDF as its own page](https://stackoverflow.com/questions/18281433/flask-handling-a-pdf-as-its-own-page) – Kruspe Jul 14 '21 at 16:17
  • Thanks Kruspe. These solutions suggest to me that I should, perhaps, save the pdf as a file and use `send_file` to push it instead of using a stream. Is this the way it should be handled? – Elcid_91 Jul 14 '21 at 16:25
  • Yes. That's the way to go - as far as I know. I would create it in a temporary directory if there is no need to store it. If you don't want to handle it this way, you might want to look for some errors on top of the stream content in Apaches error log. – Kruspe Jul 14 '21 at 18:11

0 Answers0