header("Content-Type: ". $ContentType);
$sStreamFilePath = STREAM_CACHE . "/file_".$DocumentId.".binaryFile";
header('Content-Disposition: attachment; filename="'.$filename.'"');
fpassthru(fopen($sStreamFilePath,'rb'));
exit();
So to open a PDF on a specific page we need to update the url to have "#page=<page>" on it "http://domain/stream.php?id=<number>#page=<page>"Now your problem is that the hash part is not sent to the server so the stream.php never gets it. So you need to also pass it as a parameter like "http://domain/stream.php?id=<number>&page=<page>#page=<page>" this will send the page to the server which PHP will be able to access and add to the $iPageToOpenAt variable in the example below.
header("Content-Type: ". $ContentType);
$sStreamFilePath = STREAM_CACHE . "/file_".$DocumentId.".binaryFile";
if($ContentType=="application/pdf"){
if($iPageToOpenAt != NOT_FOUND){
header('Content-Disposition: attachment; filename="'.$filename.'#page='.$iPageToOpenAt.'"');
} else {
header('Content-Disposition: attachment; filename="'.$filename.'"');
}
} else {
header('Content-Disposition: attachment; filename="'.$filename.'"');
}
fpassthru(fopen($sStreamFilePath,'rb'));
exit();
What is actually happening is that we need to force both the browser and Acrobat Reader to see the page parameter.
No comments:
Post a comment