Welcome Guest, Not a member yet? Register   Sign In
Tying to download mpdf files
#1

(This post was last modified: 05-11-2022, 07:11 PM by sevmusic.)

So I've installed mPDF 8.1 to use with my CodeIgniter 4.

Got it working with opening a file in the browser.
Got it working with creating a file on the server.
Got it working with creating an attachment in an email.

But when I try to force download the created PDF using:

Code:
$mpdf->Output('filename.pdf', \Mpdf\Output\Destination::DOWNLOAD);

or

Code:
$mpdf->Output('filename.pdf', 'D');

I get a broken PDF that cannot be opened.

I used another program to see what was in the PDF and I see this:

Code:
<script type="text/javascript"  id="debugbar_loader" data-time="1652299385" src="https://local.mywebsite.com/?debugbar"></script><script type="text/javascript"  id="debugbar_dynamic_script"></script><style type="text/css"  id="debugbar_dynamic_style"></style><script  class="kint-rich-script">void 0===window.kintShared&&(window.kintShared=function(){"use strict";var e={dedupe:function(e,n){return[].forEach.call(document.querySelectorAll(e),function(e){e!==(n=!n||!n.ownerDocument.contains(n)?e:n)&&e.parentNode.removeChild(e)}),n},runOnce:function(e){"complete"===document.readyState?e():window.addEventListener("load",e)}};return window.addEventListener("click",function(e){var n;e.target.classList.contains("kint-ide-link")&&((n=new XMLHttpRequest).open("GET",e.target.href),n.send(null),e.preventDefault())}),e}())...

The code is much longer than that, but I think you get the idea.

Any clue as to what I'm doing wrong?

Thank you for any help!

-max
Reply
#2

Nevermind, I figured it out.

I had the mpdf being created in the view.

As soon as I moved it to the controller, I was able to download it.

-max
Reply
#3

Please edit your Topic Title and add [SOLVED] to it.

Thank you.
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