From Paper Forms to Data-Entry Forms
A guide to a short video: Import Form from Documents in Polhem 1.15.0 English version (3:39) Chinese version (3:06) The video was recorded with Polhem 1.15.0. Most of the forms a company uses already exis
A guide to a short video: Import Form from Documents in Polhem 1.15.0
- English version (3:39)
- Chinese version (3:06)
The video was recorded with Polhem 1.15.0.
Most of the forms a company uses already exist as a PDF or a Word file, or at least as a sheet of paper you can take a photo of. To enter data through them in a system, though, you usually have to define them all over again: which fields the header has, what the line items look like, which fields pick an employee or a vendor, how the total is calculated. With many forms, that alone takes a good amount of time.
Polhem 1.15.0 adds Import Form from Documents to DefineEditor (Polhem's definition file editor). You give the document to an AI model, and it drafts the form. In a conversation, you answer its questions and ask for changes in your own words. Once the draft is settled, you create the definitions and upgrade the database, and the form is ready for data entry. The sections below follow the video step by step.
1οΈβ£ The form in the demo: a supply requisition
The video uses EEOC Form 123, a supply requisition PDF published by the US government. I picked it because it has everything a paper form usually has:
- A header: the requesting office, a contact, a delivery address and a suggested vendor
- A table of line items: one item per row, with quantity, unit, unit price and amount
- Check boxes
- Signature and approval boxes
2οΈβ£ Importing: you confirm before anything is sent
In DefineEditor, open the definition folder, choose File β Import Form from Documents..., and pick the documents. PDFs, Word documents and PNG or JPEG photos are all accepted. If the front and back of a form were photographed separately, select both.
Before anything is sent, a dialog lists the files that go to the AI model and the organization that pays for this request. Company forms may contain personal data, so agree only when you are allowed to share them. Without your agreement, nothing leaves your computer.
3οΈβ£ The first draft: a header and its line items
Once the documents are sent, the conversation window opens. The AI model reads the PDF and builds the draft step by step with tools the editor provides. Each step shows up in the conversation as it happens: which table it created, which field it set up, which existing form it matched.
A first draft usually has:
- A master table and a detail table
- Field captions in English and Chinese, with data types and lengths
- Drop-down choices where the document gives a fixed set of options
- Relations: fields that pick a person, a department or a vendor are matched to the forms already in your definition folder
- Totals: a read-only field on the master table that adds up the line items with
Sum(...)
On the right side of the window is a preview that draws the form from the draft. Scroll down and the detail table appears under the header. Next to it, the Fields tab lists every field together with the text it was read from in the document, and the Questions tab lists what is still open.
4οΈβ£ Adjusting it in plain words
Where the document is unclear, the AI model asks. Each question is a card with a few answers to click, and the one it suggests is marked. You can answer one by one, or use Use the Suggestions. The video takes the suggestions but changes one answer: Suggested Vendor is linked to the Supplier form instead of staying a text field.
Then the changes are typed in as a normal message. The video asks for four at once:
- Remove the signature boxes, since the approval workflow handles them in the system
- Turn the unit into a drop-down
- Make the total add up the line items
- Widen the justification box so it takes the whole row
After making the changes, the AI model explains each one, and points out the items the draft already handled. The preview updates after every change. One more round of answers, the draft is marked ready, and only then is Create Definitions enabled.
The AI model only proposes the draft. Whether it can become definitions is checked by DefineEditor itself. A computed field such as the total is parsed by the framework's expression evaluator before the draft can be ready. If something is wrong, it stays on the Questions tab, and the definitions cannot be created until it is fixed.
5οΈβ£ Creating the definitions and upgrading the database
After Create Definitions, the rest is the same as an Excel import: it lists the files it will write, and writes them only after you confirm. DefineEditor then offers to upgrade the database, and in the video this creates two tables, one for the master and one for the line items.
What comes out are ordinary Polhem definition files, no different from a form created by hand or imported from Excel. You can still rearrange the fields later in the FormLayout editor (the form layout editor).
6οΈβ£ Entering data on the website
Finally, the video opens the Blazor site of the Northwind sample, where the requisition is already on the menu. The related fields, such as the offices, the people and the vendor, all pick from existing records. Add two line items and the total updates as you type. After saving, the record is opened again in read-only mode.
How that Blazor site is built from the same definitions is covered in an earlier post, The Same Definitions on Blazor Server: What Has to Change?.
From one PDF to a form people can enter data into, without writing a line of code.
7οΈβ£ Cost, time and limits
Each message calls the AI model's paid API one or more times, and the organization shown before sending pays for it. You need API credit and a credential set up first; the guide explains how. The guide measured eight synthetic forms (printed, handwritten and photographed) at about US$0.25 and 80 seconds per form, with one or two replies. The actual cost depends on the length of the document and on how many questions the AI model needs to ask.
Current limits:
- One conversation drafts one form.
- A total can only add up all of the line items. Averages, or sums over only some of the lines, cannot be expressed.
- Business logic that definitions cannot express still has to be written as code, as with any other form.
β Wrapping up
What this feature saves is the time spent describing a form all over again. The AI model writes the draft, but which fields to keep, which form a field relates to and how the total is calculated are all decided by you in the conversation.
If a form has a complex layout or needs a lot of custom logic, the draft is only a starting point, and there is still plenty to adjust afterward. If the fields are clear and the form is mostly used for data entry, this is a much faster way to start. The best way to find out whether it fits your forms is to try it on one you already have.
Further reading
- Drafting Forms from Documents: the credential setup, every part of the conversation window, and the limits
- Polhem: source code, documentation and samples
π Original article on HackMD, in Traditional Chinese:
π https://hackmd.io/@jeff377/polhem-doc-to-form
π’ You are welcome to republish this, please credit the source.
π¬ Follow for more engineering notes:
Facebook ο½ HackMD ο½ GitHub ο½ NuGet
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.