Support » Plugins and Hacks » [Plugin: article2pdf] PDF format unrecognize

  • Resolved hobong

    (@hobong)


    I’m using article2pdf and it can generate a pdf file which automaticly downloaded but there’s error when open the pdf file, it says :

    Couldn’t open the file. It may be corrupt or a file format that Preview doesn’t recognize.

    Here I provide a link :

    Any help ?
    Thanks

Viewing 1 replies (of 1 total)
  • SOLVED :
    it’s because the webserver does not allow using readfile()
    here is the code from article2pdf_getfile.php on about line 44

    $tmpfile = $tmpdir . (substr( $tmpdir, -1 ) != '/' ? '/' : '') . 'a2p.tmp.' . $post_name . '.' . $tmprand . '.pdf';
    	if( file_exists( $tmpfile ) )
    	{
    		if( $_GET[ 'debug_pdf_file' ] != '1' )
    		{
    			header( "Content-Type: application/pdf" );
    			header( "Content-Disposition: attachment; filename=\"" . $post_name . ".pdf\"" );
    		}
    		//readfile( $tmpfile );
                    <strong>// replace with </strong>
                   echo file_get_contents($tmpfile);
    		unlink( $tmpfile );
    	}
    	else	die( 'Sorry no pdf tempfile found. Please try again.' );

    Hope it helps other

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: article2pdf] PDF format unrecognize’ is closed to new replies.