1

I want a tool or library that can extract the text in PDF documents so that it can be retained in a text document. Formatting does not need to be retained, though I would like to be able to recognize it so that I can determine sections of the document. (e.g. write a rule that says every instance of H1 is the start of a new section.) Also acceptable is something that extracts the PDF to a format like ODF or DOCx, which includes formatting and pictures.

Tools like PDFParser can only read text and only when the PDF is not protected.

Though free tools are preferred, I am also willing to pay.

If it matters, the project that would use this is written in PHP using Laravel.

  • 1
    "Tools like PDFParser can only read text and only when the PDF is not protected": PDFs protected against copying usually can't be scraped (that's the idea behind the copy protection here), so for those you'd probably need OCR. – Izzy Jun 1 '16 at 5:38
1

I recommend checking out the LEADTOOLS Document Imaging SDK for this. This SDK has a couple different ways to extract text from PDF, including parsing vector PDFs and running OCR on raster data in PDFs. There isn't any native PHP support, but using the .NET interface, you can use the Document Converters to get text from either type of PDF file.

Here's some sample code:

using (DocumentConverter documentConverter = new DocumentConverter())
{
   var inFile = Path.Combine(ImagesPath.Path, @"Leadtools.pdf");
   var outFile = Path.Combine(ImagesPath.Path, @"output.txt");
   var format = DocumentFormat.Text;
   var jobData = DocumentConverterJobs.CreateJobData(inFile, outFile, format);
   jobData.JobName = "conversion job";
   var job = documentConverter.Jobs.CreateJob(jobData);
   documentConverter.Jobs.RunJob(job);
}

Disclaimer: I am an employee of the company that wrote this library.

0

at work we use Seta PDF Extractor library for PHP, at several projects after discarding some free tools. So if you're willing to pay, you can evaluate the library first (free download). Will not do your image extraction desire but you can easily perform phrase search, limit text extraction to bounding boxes. It's pretty flexible. Requires PHP 5.3

0

I woudl highly recommend everyone's favo(u))rite eBook mamnagement program: Calibre.

calibre supports the conversion of many input formats to many output formats. It can convert every input format in the following list, to every output format.

Input Formats: AZW, AZW3, AZW4, CBZ, CBR, CBC, CHM, DJVU, DOCX, EPUB, FB2, HTML, HTMLZ, LIT, LRF, MOBI, ODT, PDF, PRC, PDB, PML, RB, RTF, SNB, TCR, TXT, TXTZ

Output Formats: AZW3, EPUB, DOCX, FB2, HTMLZ, OEB, LIT, LRF, MOBI, PDB, PMLZ, RB, PDF, RTF, SNB, TCR, TXT, TXTZ, ZIP

It also has many useful features and plugins. I wouldn't use anything else.

0

If you need to convert your pdf file to txt format, PDFMate PDF Converter Free is recommended to you. I've been using it for some time and upgraded to the pro version cause I use the program quite often.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.