I want to read a pdf file using php. but i want toread that file line by line and made changes in it is it possible

Hi akbar ali butt,

Without knowing further details, it's hard to say if it's possible or not. It is certainly possible to open, create and modify PDF's using PHP's built in PDF functions. You may benefit from reading through the PDF functions that PHP offers and deciding for yourself if that will be enough to suit your needs:


Let us know if you have further questions.

Thanks chrelad
For your reply i am new to php igot that link for multiple sites but i am unable to configure php for pdflib library and its use.

i am able to read from html replace the text according to requirement and generate a pdf.
but i want to read from pdf instead oh html and then replace the the text and generate the pdf again

i also want to do url rewriting dynamically is it possible

Thanks again

i want to read file pdf with php
i have this problem and i don't find
in the web
you can help me

To re write url dynamically you need to fetch data from Db and write
echo "<script>window.location='Your URL from DataBase';</script>"
its sipmle and works or use function header("Location: URL");

akbar ali butt did u know the method to read the text in pdf files line by line ?

Did anyone else know how to read pdf text line by line to locate specific text ?

Read PDf File Using php


function pdfVersion($filename)
    $fp = @fopen($filename, 'rb');

    if (!$fp) {
        return 0;

    /* Reset file pointer to the start */
    fseek($fp, 0);

    /* Read 20 bytes from the start of the PDF */


    if (isset($match[0])) {
        return $match[0];
    } else {
        return 0;

$version = pdfVersion("example.pdf");
$filename= 'sample.pdf';
  header('Content-type: application/pdf');
  header('Content-Disposition: inline; filename="' . $filename . '"');
  header('Content-Transfer-Encoding: binary');
  header('Accept-Ranges: bytes');

it is work on local but i want to read pdf file on server.