Schema LawSign in with Google

Does OCR Keep Formatting? Headings, Numbering, Tables

By Schema LawPublished Updated

OCR keeps some formatting and loses the rest. Structure-aware OCR can keep headings, paragraphs, lists, tables and bold text, because those can be worked out from the page image. It does not keep the original fonts, exact spacing, margins or automatic numbering, because a scan is a picture and never contained them.

In short: the structure, mostly, and the appearance, no. The practical question is which of the two you need. A lawyer who wants to reuse three clauses needs structure. A lawyer who wants a page that looks identical to the original should keep the page image and add text behind it.

Which formatting survives OCR and which does not?

Formatting that describes what a piece of text is tends to survive OCR: heading, paragraph, list item, table cell, bold. Formatting that describes how the page was typeset tends not to: typeface, point size, line spacing, indents, tab stops, columns and page breaks at exact positions.

Feature of the originalUsually survives?What to expect
The words, in reading orderYesThe main thing OCR does
Paragraph breaksYesOccasionally merged or split at page ends
HeadingsOftenRecognized as headings, but the level may be wrong
BoldOftenLight bold or poor scans lose it
Italic and underlineSometimesUnderline is easily confused with a rule or a signature line
Bulleted and numbered listsOftenNumbers come back as typed text, not automatic numbering
TablesOftenSimple grids do well; merged cells and borderless tables less so
Typeface and sizeNoThe output uses its own fonts
Exact indents, tabs and line spacingNoRebuilt approximately or not at all
Margins and page sizeNoSet by the output file
Headers, footers and page numbersAs text onlyThey arrive as ordinary lines, not as header and footer regions
FootnotesAs text onlyThe note text is there; the link to its reference mark is not
Signatures, seals, stamps, logosNoThey are pictures, and only the image shows them
Tracked changes, comments, cross-reference fieldsNoA scan never held them

"Usually" and "often" are deliberate. Results depend on the scan and on the tool, and nobody can promise a figure for your documents. Test with a page that has the features you care about.

Multi-column pages are a special case, because the risk there is the order of the words more than their look. The post on whether OCR can handle two-column documents deals with that.

Why does OCR lose fonts and exact spacing?

OCR loses fonts and exact spacing because a scan stores neither. A scanned page is a grid of dots. The software has to infer letters from shapes, and then infer structure from where those letters sit. Anything it writes about formatting is a reconstruction, never a copy.

Compare that with the file the document started as. A Word document records that a paragraph uses 12-point Times, is indented half an inch, and belongs to numbering level two. Printing throws all of that away and leaves ink. Scanning records the ink. The instructions that produced the page cannot be recovered from the page alone.

What OCR can do is reason backwards from appearance:

  • A short line in larger or heavier type, with space around it, is probably a heading.
  • Lines that start with a number or a bullet and share a left edge are probably a list.
  • Text that lines up in rows and columns is probably a table.
  • Thicker strokes than the surrounding words probably mean bold.

Each of those is a judgment, and each can be wrong. A defined term in bold capitals on a line of its own can be taken for a heading. A signature block with two aligned columns can be taken for a table. Poor input makes every judgment harder: a faxed page has too few dots to tell bold from regular, and a tilted page disturbs the alignment that lists and tables depend on.

On a deposition transcript, the question and answer labels and the line numbers are part of the layout you need. Keep each line of testimony with its line number, and keep a speaker label from merging into the witness answer. A court reporter parenthetical should stay on its own line so a later cite can find it.

Exact spacing fails for a plainer reason. Even when the software measures the indent correctly, the output uses a different font with different letter widths, so the same words no longer break at the same places. Tools that try to pin every line to its original position produce Word files full of text boxes and manual line breaks. Those look right until you edit a sentence, and then the page falls apart. A structural result looks less like the original and is far easier to work in.

Headings and outline numbering after conversion

Headings usually come through as headings, and numbering comes through as typed characters. The living outline that a Word document uses, where deleting clause 4 renumbers everything after it, does not exist in a scan and is not recreated by conversion.

Headings

In the Schema Law Word export, a recognized heading becomes a Word heading style, from Heading 1 down to Heading 6. That gives you the navigation pane and a table of contents in a few clicks. Check the levels, though. Recognition judges level by appearance, and a contract that sets "ARTICLE IV" and "4.1 Rent" in similar type can come out with both at one level, or with a bold defined term promoted to a heading.

Numbering

Legal numbering is the feature most worth checking. A clause such as "4.1 Rent" or "(a) the Tenant shall" is carried over as the text it is, number included. A cross-reference such as "subject to Section 7.2" also stays as typed text, so it keeps saying 7.2 even if you later move the clause.

Simple lists need a closer look. Where the page was read as a numbered list, such as "1." "2." "3." down the margin, the Schema Law Word export writes each item with a typed number and an indent, and it counts from 1 at the top of each list. Two consequences follow:

  • A list interrupted by an ordinary paragraph restarts. If items 1 to 3 are followed by an unnumbered paragraph and then item 4, the item after the break can appear as 1.
  • A list that continues from the previous page can restart too. Lists are numbered page by page in the export.

So compare clause numbers with the page image before relying on them. The Markdown export carries each page as it was recognized, which makes it a useful second reference when a number looks wrong.

A quick check for a converted contract

  1. Write down the number of the last numbered clause on the scan.
  2. Find the same clause in the converted file and confirm its number matches.
  3. Search the converted file for "Section" and spot-check five cross-references against the scan.
  4. Scan the navigation pane for headings that are really body text, and for articles that are missing.

To make the numbering live again, apply a multilevel list style in Word and delete the typed numbers. That is rebuilding, and the last section helps you decide whether it is worth it. The step-by-step guide to converting a scanned PDF to Word covers the conversion itself.

Footnotes, headers and page numbers

Footnotes, running headers and page numbers are read as text like everything else on the page. They are not rebuilt as Word footnotes or header and footer regions. They appear in the body, at the spot where they sat on the scanned page.

That has visible effects in an editable file:

  • Running headers repeat. A header such as "Case 2:21-cv-00417 Document 38" appears once per page, in the middle of your text wherever a page ended.
  • Page numbers interrupt sentences. A sentence that runs over a page break can have "- 14 -" between its two halves.
  • Footnote text sits at the foot of its page. The superscript mark in the body often comes through as an ordinary digit stuck to a word, such as "damages3", or is dropped.
  • Bates numbers and exhibit stickers arrive as short stray lines.

The Schema Law Word export contains headings, paragraphs, lists and tables, and it starts each source page on a new page. Because pages stay separate, the clutter is at least predictable: look at the top and bottom of every page.

Before you delete any of it, decide whether you need it. For a quotation you will cite by page, the page boundaries are the most useful thing in the file. For a clause you want to reuse, they are debris.

Your purposeHeaders and page numbersFootnotes
Reusing language in a new draftDeleteReinsert as real Word footnotes if they matter
Quoting with a page citeKeep until the cite is checkedKeep with their page
Searching onlyLeave aloneLeave alone
Comparing against another versionDelete from both sides firstMove to one consistent position

A stray footnote digit is a dangerous error in legal text, because "30 days3" can be misread as a number. Search the converted file for a digit directly after a letter or a full stop and check each hit.

How each export format treats structure

Each export format carries a different share of the structure. Word, HTML and Markdown keep headings, lists and tables as such. Plain text keeps the words and their order. Spreadsheet formats keep tables above all. A searchable PDF keeps the appearance, because it reuses the page image.

Schema Law offers eight export formats. This is what each one does with a page that has been read:

ExportHeadingsListsTablesBoldPage boundaries
WordWord heading stylesBullets, or typed numbers with an indentWord tables with a bold header rowKeptEach source page starts a new page
Searchable PDFSeen in the page imageSeen in the page imageSeen in the page imageSeen in the page imageIdentical to the original
Plain textAn ordinary lineHyphens or numbersTabs between cellsDroppedA page break character between pages
MarkdownLines starting with #Markdown list itemsPipe tablesAs recognizedA horizontal rule between pages
HTMLHeading tagsList tagsTable tags with a header rowKeptA labelled section per page
ExcelA row on the text sheetA row on the text sheetOne sheet per tableHeader row onlyPage number beside each row or in the sheet name
CSVLeft out when the document has tables; otherwise unmarked linesLeft out when the document has tables; otherwise one line per item with its hyphen or numberThe rows, comma separatedDroppedNot recorded for tables
JSONIn each page's MarkdownIn each page's MarkdownA header and rows for every tableIn each page's MarkdownOne entry per page

The searchable PDF row is the odd one out. It adds hidden text to your original file and leaves the visible page as it was. If "keep the formatting" means "it must look exactly like the original", that is your export, and you give up editing. Every plan, the free one included, exports all eight formats, so choose by what the file has to do next. The format list on the homepage describes each format, and the pricing page gives each plan's page limits.

Italics deserve a note. The Word and HTML exports carry bold through and do not carry italics. If italics matter to your reading, as with case names or emphasis in a quotation, restore them by hand against the scan and say "emphasis in original" only after checking the page image.

For a closer look at the two lightweight formats, see the post on PDF to Markdown OCR.

Deciding when to rebuild formatting by hand

Rebuild formatting by hand only when the document will live on as a working draft. For a quotation, a search or a one-off review, the converted structure is enough. For a lease you will amend three times, an hour spent applying styles pays for itself.

Count the cost before you start. Rough cleanup work for a converted contract includes:

  1. Removing running headers, page numbers and stamps from the body.
  2. Rejoining paragraphs that were split across pages.
  3. Correcting heading levels.
  4. Replacing typed numbers with a multilevel list.
  5. Turning typed cross-references into real ones, if you want them to update.
  6. Resetting fonts, margins and spacing to the firm's template.
  7. Proofreading the whole text against the scan.

Step 7 is not optional and is usually the longest. The others scale with the length and the mess.

SituationSensible choice
You need two paragraphs for a briefCopy them, verify them, format in place
You are drafting a short amendmentLeave the conversion as is and draft the amendment as a new document
You will redline the document against future draftsRebuild fully, once, and keep that as the master
The other side or the client has the original Word fileAsk for it before converting anything
The document is a form the firm uses oftenRebuild fully and save it as a template
The scan is poor and the document is longConsider retyping the key sections only

The fourth row is the cheapest fix on the list and the one most often overlooked. A native file has real styles, real numbering and no recognition errors. Conversion is for the cases where that file is gone or was never yours.

When you do rebuild, work from the structure outward. Fix headings and numbering first with styles, then spacing and fonts through the template, then proofread. Formatting line by line before the styles are right means doing the work twice. Keep the scan open beside the draft throughout, and save the untouched conversion so you can show what the software produced and what you changed.

All posts in Converting scans