PDF to Text Conversion
If your server (or your desktop computer) is running a Linux operating system, you are likely to have PDF to text conversion software onboard
I built interface software to make the Linux PDF to text conversion software easier to use. It is named "PDF to Text Conversion". It is an interface between you and the Linux software.
To use the Linux software directly requires that you type text commands via Terminal or other command line interface. Further, some hosting accounts don't have a command line interface at all.
But why would you want to do it in the first place? Here are a few reasons.
-
Some (most?) PDFs are klutzy when it comes to copying and pasting. With text extracted from the PDF, it's as easy as copying regular text.
-
Some search engines read and index PDF contents; the bigger ones. But if you have your own search engine installed exclusively for your website, it might not have that ability. Providing a text version of your PDF files may get them searched.
-
If you have a PDF and want to edit it, but don't have the original, converting it to text is likely to save the day.
As an example of what PDF to Text Conversion can help you do, here is a PDF (a fiction story) and here is the converted text.
The PDF to Text Conversion software won't convert PDFs that are password protected. And another caveat; recently, I ran into a situation where a specific font
Here is a screenshot of the PDF to Text Conversion software dashboard.

To convert a PDF file to plain text with this software, you'll need to know where the Linux PDF2Text software is. This pdf2textTest.php
script can be used to find it. Here is the source code for the software.
<?php // Will Bontrager Software LLC echo '<p>Testing for presence of PDF2Text:</p>'; $s = ''; $arr = array(); $s = exec('which pdf2text'); if( strlen($s) ) { $arr[] = $s; } $s = exec('which pdf2txt'); if( strlen($s) ) { $arr[] = $s; } $s = exec('which pdftotext'); if( strlen($s) ) { $arr[] = $s; } if( count($arr) ) { echo "Found:<pre>" . implode("\n",$arr) . '</pre>'; } else { echo "No PDF2Text system software found."; } ?>
Save the source code as pdf2textTest.php
and upload it to your server. Type it's URL into your browser's address bar. The software will let you know what it found or didn't find.
If no PDF2Text software is found, it may be because the software is not available with your hosting account or, perhaps, your hosting company turned off some or all PHP exec()
functionality.
Here is the source code for the software I made to use the Linux PDF to plain text converter:
<?php /* PHP to Plain Text Conversion With Linux PHP2Text Version 1.0 March 1, 2025 Will Bontrager Software LLC https://www.willmaster.com/ */ /* Instructions: Upload this software to your server and type it's location into your browser. */ $message = array(); $continue = false; $selfname = preg_replace('!^.*/!','',$_SERVER['PHP_SELF']); if( isset($_POST['to_convert']) ) { $continue = file_exists($_POST['phpdoc']); if(!$continue) { $message[] = "PDF file <code>{$_POST['phpdoc']}</code> was not found in the directory where this script is running."; } } if($continue) { $execline = "{$_POST['php2txt']} {$_POST['phpdoc']}"; $message[] = "Converting with<br><code>exec(\"$execline\")</code>"; $ret = exec($execline); if( strlen($ret) ) { $message[] = "<p>$ret</p>"; } $convertedFile = preg_replace('/\.pdf$/','.txt',$_POST['phpdoc']); if( file_exists($convertedFile) ) { $message[] = "<p>Done:<br>Tap <a href=\"$convertedFile\">$convertedFile</a> to view $convertedFile</p>"; } else { $message[] = "<p>The file was expected to be converted to <code>$convertedFile</code> but wasn't there when I checked. Maybe the file just hadn't been finished yet. Or, maybe the file's name is <code>{$_POST['phpdoc']}.txt</code> or something similar."; } } ?><!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>PDF to Text Conversion</title> <style type="text/css"> @charset "utf-8"; html { font-family:sans-serif; font-size:100%; } a { text-decoration:none; } .bold { font-weight:bold; } .italic { font-style:italic; } .underline { text-decoration:underline; } .overline { text-decoration:overline; } .nowrap { white-space:nowrap; } input { box-sizing:border-box; width:100%; } input[type="text"] { font-size:1rem; font-family:monospace; borde:1px solid #ccc; border-radius:.3em; padding:.3em; } </style> </head> <body><div style="max-width:5in; margin:.25in auto;"> <h1>PDF to Text Conversion</h1> <?php if(count($message)): ?> <div style="border:3px solid green; border-radius:.5rem; padding:0 1rem;"> <?php echo( '<p>'.implode('</p><p>',$message).'</p>'); ?> </div> <?php endif; ?> <p>To convert a PDF file to plain text with the Linux system PDF2Text software, you'll need to know where the PDF2Text software is.</p> <p>Script <code>pdf2textTest.php</code> can be used to find the PDF2Text software location. Upload <code>pdf2textTest.php</code> to your server and run it.</p> <p>If it does not find PDF2Text software, it may be because the software is not available with your hosting account or, perhaps, your hosting company turned off some or all PHP <code>exec()</code> functions for your account.</p> <form action="<?php echo($_SERVER['PHP_SELF']) ?>" method="post""> <h3>Convert PHP to Plain Text</h3> <p> <span style="font-size:1.4em; font-weight:bold;">1.</span><br> Upload your PDF file into the directory where this <code><?php echo($selfname) ?></code> script is run. That would be directory <br><code><?php echo(__DIR__) ?></code> <p> <span style="font-size:1.4em; font-weight:bold;">2.</span><br> Specify the location of your PDF2Text software.<br> <input type="text" name="php2txt"> </p> <p> <span style="font-size:1.4em; font-weight:bold;">3.</span><br> Specify the file name of the PDF document.<br> <input type="text" name="phpdoc"> </p> <p> <span style="font-size:1.4em; font-weight:bold;">4.</span><br> Tap this button. (The text document will be put on the server. This script will attempt to let you know where.)<br> <input type="submit" name="to_convert" value="Convert"> </p> </form> © <a href="https://www.willmaster.com/">Will Bontrager Software LLC</a> </div> </body> </html>
No customization is required for the source code. Simply save it as pdf2txt.php
and, when you're ready to use it, upload it to your server.
To convert a file, first upload the PDF into the directory where pdf2txt.php
has been installed. Then, type the URL of pdf2txt.php
into your browser's address bar and fill in the form. (You can see the form in the dashboard screenshot further above.)
When the PDF to Text Conversion software has completed a conversion, it will show a progress message similar to this screenshot.

If you can use a PDF to text converter and your website is on a Linux machine, the above should do you well.
(This content first appeared in Possibilities newsletter.)
Will Bontrager