Re: google books

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



John Pillion wrote:
Not a PHP question. but could someone point me in the direction of how to
download/display only a portion of a PDF, much like google books does?  For
example, if you have a 200 page pdf, but the user wishes to see the portion
that is on page 150. rather than downloading the entire PDF, only
download/display page 150?

I would like to avoid having to split them into 200 individual PDF's
(whether manually or automatically).

Any suggestions?

- JP



You could use FPDF and FPDI to just load up the one page:

http://www.setasign.de/support/manuals/fpdi/

Just use importPage($thePageNumberYouWanted);

<code>

$pdf = new fpdi('P', 'pt', 'letter');

$pdf->setSourceFile(self::PATH);
$tpl = $pdf->ImportPage(1);
$pdf->AddPage();
$pdf->useTemplate($tpl, 0, 0);

$data = $pdf->buffer;
$pdf->closeParsers();

header("Content-type: application/pdf");
header("Content-disposition: inline; filename=FileName.pdf");
header("Content-length: " . strlen($data));

echo $data;

</code>

I just realized that the version of FPDI I've been using is a little old. There's a new update out, so some of the above code might change a little.

--
Ray Hauge
www.primateapplications.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux