As already mentioned by Ivan Nack, this will depend on the browser, there is how to manipulate the header header / em> Content-Disposition
, however it will depend on how the browser will handle the file, because there is a way to configure the browser to always download the file, or if the browser does not handle native PDFs, use plugins such as Adobe Reader.
As stated by the bfavaretto in comment , one way to do this is to convert each page of the PDF file into an image and display it, this is how Google should do ( I believe ), this in PHP is using ImageMagick
.
Here is a sample taken from here :
$arquivoPDF = 'demo.pdf';
$imagem = 'demo.jpg';
$img = new imagick();
$img->setResolution(200,200); // Isto é importante para dar uma saída de boa qualidade, caso contrário, o texto pode não ser claro
$img->readImage("{$arquivoPDF}[0]"); // Lê a primeira página do PDF, o número entre [] indica a página
$img->scaleImage(800, 0); // Reduz as dimensões
$img->setImageFormat('jpg'); // Define novo formato
$img = $img->flattenImages(); // Isso é necessário para imagens com transparência, que irá produzir um fundo branco para regiões transparentes
$img->writeImages($imagem, false); // Salva a imagem
Another alternative, now in Javascript, is to use a renderer such as pdf.js >, which does not require third-party applications. There's a demo here .
Finally, there's also how to use the Google viewer to do this what you want, for example:
<iframe src="http://docs.google.com/gview?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true"
style="width:600px; height:500px;" frameborder="0">
</iframe>
DEMO