Welcome Guest, Not a member yet? Register   Sign In
No me genera los documentos PDF en el navegador
#1

Buenos días, estoy realizando un pequeño sistema con CI4, en realidad estoy aprendiendo este esta versión ya que e realizado varios sistema en la versión 3 de CI pero quiero migrar esos sistemas a CI4, mi problema es que cuando trato de generar un documento PDF con algún listado, ya sea de productos, clientes o usuarios, no los genera en el navegador, solo me muestra en una nueva pestaña, una seria de caracteres especiales y mas nada, si le coloco al código para que los descargue directamente a la PC, si lo hace perfecto, el problema esta al querer generarlo en el navegador. No se si será alguna extensión de PHP que se debe activar. Si me pueden ayudar con este inconveniente se los agradezco. Gracias
Reply
#2

Use DOMPdf or other library. If you see text instead of a file, check the headers and mime type
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply
#3

You must add to your code the following line:
$this->response->setContentType('application/pdf');
$mpdf->Output();
Reply
#4

(This post was last modified: 06-01-2025, 09:41 AM by paulbalandan.)

Good morning,
I'm currently working on a small system using CodeIgniter 4 as part of my learning process. I’ve developed several systems with CodeIgniter 3 and now I'm migrating them to CI4. However, I'm encountering an issue when trying to generate PDF documents—for example, lists of products, clients, or users.
The PDFs aren't displaying correctly in the browser. Instead of rendering properly, a new tab opens showing only a stream of special characters. Interestingly, if I modify the code to force the PDF to download directly to the PC, it works perfectly. So the problem only occurs when trying to view the PDF in the browser.
I’m not sure if this could be related to a missing or inactive PHP extension. If you have any suggestions or guidance to resolve this issue, I’d greatly appreciate your help. Thank you!
Reply
#5

You need to send it to the web browser inline.

Read this:

CodeIgniter 4 display pdf file in web browser
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB