简体   繁体   中英

Count the number of lines in a PDF file in PHP

In a PHP script, I would need to count the number of (text) lines in a PDF file. How can I do that? I cannot seem to find any answers on Google.

The PDF files I am interested in are templates for bindings of master theses (created and uploaded by users). I do not expect to find paragraphs of text in there, rather just single lines spread across a single page.

Here is a short suggestion which might work. First of all have a look at this link http://www.phpclasses.org/browse/file/31030.html . It is a pdf to txt converter. If you know the text size you can calculate the line over this script.

include('class.pdf2text.php');
$a = new PDF2Text();
$a->setFilename('file.pdf');
echo $a->output();
...
Calculate how many lines the file contains

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM