George
George

Reputation: 31

How to display PDF from another server

I'm using the below script to display the PDF in browser.

$vPath = '/path/to/pdf/example.pdf';

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

The PDF files are on the same server where the script is. But now I have to move the PDF to image server(Only PDF and Image files resides here)

How can I display the PDF from another server? Please help

Upvotes: 0

Views: 1502

Answers (1)

George
George

Reputation: 31

Thanks guys.

I did a work around. The problem with using the above code is the relative path used. Instead I used IFRAME for displaying PDF using absolute path.

$vPath = 'http://path/to/pdf/example.pdf';
<iframe src="<?php echo $vPath;?>" style="width:600px; height:500px;" frameborder="0"></iframe>

Upvotes: 1

Related Questions