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

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:

http://www.php.net/manual/en/ref.pdf.php

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

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

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");

Hi,
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 ?

Member Avatar for ampere

Read PDf File Using php

<?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 */
    preg_match('/\d\.\d/',fread($fp,20),$match);

    fclose($fp);

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

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.