• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

mpdf file only works in browser, not in adobe acrobat (format error)

New Here ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

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.5accountant), won't fix the problem.

Thanks

Views

339

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

LATEST

What can you see when you open the PDF file with a text editor, like Notepad?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines