How to create a PDF stream in PHP?

5

Is there any alternative to implementing a stream of PDF files that are on the server?

I would like the browser to download the pdf as it is viewed.

Same as the preview of google books

    
asked by anonymous 30.01.2014 / 01:54

4 answers

3

I do not know if this would help, but a PDF embed could not serve you? Just put Google's own PDF embed, look at the code below

<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>

See an example on JSFiddle

    
30.01.2014 / 02:42
1

Use the framework PDF.js is very simple and easy.

    
30.01.2014 / 02:51
0

I am afraid that you can not control through the server since it is the browser that "pulls" through the PDF file. The browser is going to download the file bit by bit.

    
30.01.2014 / 02:10
0

Adapting this answer : supposing you want to stream from the link " link "

$data = file_get_contents("http://bar.com/foo.pdf");
header("Content-type: application/octet-stream");
header("Content-disposition: attachment;filename=YOURFILE.pdf");

echo $data;

It's not what it needs exactly, but it's a great start.

    
30.01.2014 / 04:30