We generate PDFs using phpwkhtmltopdf, so PHP wrapper for wkhtmltopdf. The inline view of the generated PDFs works when not using Slim as a router. As soon as Slim hands over the request, I get black diamonds with the question mark.
Allow me to refer to this post that unfortunately seems to be dead but describes the issue well.
Sure, I had the same issue with TCPDF the other day. You’re probably sending the PDF data inline to the browser without the correct content-type header.
If you do it the Slim way, then you have to return an HTTP response object with the PDF data in its response body. So the following lines do:
Change the default response header “Content-type” to “application/pdf”
Write the PDF output as a string to the response body stream (TCPDF uses the “S” option for this, not sure which option phpwkhtmltopdf has to output as a string)