Jump to content

displaying PDF file failed although i followed the instructions i found here


sab
 Share

Recommended Posts

Hi,

I am trying to display PDF pages on different parts of my webpage I am creating.

Failed to load PDF file

**********************************************************************************************

on my showPDF template, i have: $filePdf = $page->showPdf->filename;

on my main.inc:

if($filePdf){
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filePdf . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($filePdf));
header('Accept-Ranges: bytes');
@readfile($filePdf);
$filePdf='';
}

else{
echo $content;  
}
 

**********************************************************************************************

I must be definitely doing something wrong!

Edited by arvixeuser
please use the code block
Link to comment
Share on other sites

you can check on your main.inc if there is a valid filename in $filePdf, if it exists:

if (file_exists($filePdf)) {
   ...
}
else {
    echo $content;
}

BUt currently for debugging purposes you temporarily should do this:

if (file_exists($filePdf)) {
   ...
}
else {
    //echo $content;
    echo "<pre>";
    var_dump($filePdf);
    echo "</pre>";
}

this way you can get information what it is what you have assigned to $filePdf. :)

Edited by horst
Link to comment
Share on other sites

Maybe you have had output before that line? What does it say trying this:

if (headers_sent()) {
    $filename = $linenum = null;
    headers_sent($filename, $linenum);
    echo "<p>read on <a href='http://php.net/manual/en/function.headers-sent.php' target='_blank'>here</a>!</p>";
    exit(1);
}

if (file_exists($filePdf)) {
   ...
}
else {
    echo $content;
}
Link to comment
Share on other sites

that's a file i can't change the content but still supposed to be there although the size is big.

i followed the instructions from suggestion or two from older forum posts. and not sure what i'm doing wrong.

i need to display many pdf files on the website.

i hope you guys have more suggestions.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...