Taking results from PDF and entering into website form

Hi there! I’m relatively new to KM and I’m looking for a way of tackling a particular usage case.

I regularly get lab test results back in a PDF (in the same format each time) and then I manually enter these results into an online form. Anyone have tips for automating this? Which tools would you use and where would you begin tackling this?

Thanks for your help.

Best wishes,
Mel

I would start with something simple like this (example):

[test] Get Text from PDF.kmmacros (3.5 KB)

This is the test file for the macro: test.pdf.zip (7.1 KB) with this content:

####The macro…

  1. gets the text from the PDF (using the pdftotext tool) and saves it to a variable
  2. scans the variable for a given string (in the example: lines that begin with “Parameter”)
  3. gets the value from each “Parameter” string
  4. copies the value to the clipboard

After that you have all the values in the clipboard history:

Then use @JMichaelTX’s little macro to reverse-paste from the history into the fields of the online form:

Notes

  • If you don’t have pdftotext, you can install it via Homebrew with brew install poppler

  • You can also automize the entry of the values into the online form. But it certainly depends on the form how this could be done

Thank you so much @Tom, I’ll have a tinker with this and see how I go. :slight_smile:

If you don't want to fool with Homebrew you can get the most recent executables here:

http://www.foolabs.com/xpdf/download.html

Look for “x86, Mac” under Precompiled binaries.

Their server is a trifle slow, so be prepared to wait 2-3 minutes.

There are installation instructions in the INSTALL file, although you might need to add a “.txt” suffix to read it (or drop it onto BBEdit or TextEdit).

Anyone wanting to convert PDFs to text should have this tool.

-Chris

Xpdf is the older (original) package, Poppler is a fork of Xpdf. I had the impression that Poppler is more actively developed than Xpdf. Xpdf (3.04) is from 2014, whereas Poppler was updated March 2017.

Poppler’s pdftotext also has a couple of additional options, e.g you can set crop areas. Besides that I don’t see big differences. Poppler has a centralized library, the Xpdf tools seem to be static builds.

BTW, for convenience, Xpdf can also be installed via Homebrew :smiling_face:

1 Like

Hey Tom,

Thanks for the heads-up. I was able to install Poppler with MacPorts.

The -layout options looks a little cruder in Poppler, but in fact you get greater separation of columns – and that helps greatly with parsing them.

Xpdf could at times place a single space between columns.

-Chris

It depends exactly what software do you use to create those forms. Actually, some of the tools create them in such a poor way, so form's data became unrecognizable after it's filled. Last time I used this form builder https://online-form-builder.pdffiller.com/ and it worked out fine after all, yet it works so with paid version only, not with free one