write content length to the response AFTER rendering the pdf to fix broken pdfs