0

I create a pdf file with this code.

case 'D':
//Download file
        header('Content-Description: File Transfer');
        if (headers_sent())
            $this->Error('Some data has already been output to browser, can\'t send PDF file');

            //Time on timezone+summertime
            if(date('I',filemtime ($name))==1){ $timez=filemtime ($name)+3*3600;}else{ $timez=filemtime ($name)+2*3600;}
            
            header('Pragma: public');   // required
            header('Expires: 0');       // no cache
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Cache-Control: private',false);
            header('Last-Modified: '.gmdate ('D, d M Y H:i:s', $timez).' GMT');
            
            
            //header('Content-Type: '.'application/pdf');
            //header('Content-Type: application/pdf');
            
            header('Content-Type: application/force-download');
            //header('Content-Type: application/octet-stream', false);
            //header('Content-Type: application/download', false);
            //header('Content-Type: application/pdf', false);

            header('Content-Disposition: attachment; filename="'.$name.'.pdf"');
            header('Content-Transfer-Encoding: binary');

            header('Connection: close');

The PDF file will create successful. If I open the created file in my browser, all is ok. If I click in my explorer and try to open with adobe acrobat, I get a error-message that adobe could not open the file caused by unsupported filetype or damaged/corrupt file.

So I play a bit about the different header options, but in every case at the end I have the same result.

How I can create a pdf file with mpdf which is supported by adobe acrobat to open it with them?

Follow this post(How to make mPDF 6.1 work with PHP 7.1.5), won't fix the problem.

Thanks

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
relo80
  • 245
  • 2
  • 13
  • 1
    _"So i play a bit about the different header options"_ - that's a rather pointless exercise, for a file that is _already_ on your hard disk. There is no HTTP involved any more at the point where you double-click on a file in your explorer. – CBroe Jun 24 '22 at 07:45
  • @CBroe HI, i change the setting for header for the createtion of the pdf file, to check if it make any changes, but it failed. but anyway, it wont help to fix my problem :-) – relo80 Jul 01 '22 at 04:40

1 Answers1

0

At the end the problem was easy to fix.

So i open the pdf-file in my coding/text-editor.

There i could see some php-errors/error-warnings.

In the mpdf.php i changed the $errorlevel=error_reporting(E_ERROR | E_PARSE);

thats all.

relo80
  • 245
  • 2
  • 13