WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: article2pdf] PDF format unrecognize (2 posts)

  1. hobong
    Member
    Posted 4 years ago #

    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

  2. hobong
    Member
    Posted 4 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic