← All posts

Extracting Hebrew Text and Data from PDF Files

Why Hebrew PDF text appears reversed, why numbers move, and the right process for extracting clean text and focused data before sending it to AI.

· document data extraction · Hebrew · business automation

Extracting Hebrew Text and Data from PDF Files

Almost every business that tries to send Hebrew documents to an AI model encounters the same strange problem. The text comes out reversed, numbers and dates move into the wrong place, and sometimes random English letters appear instead of Hebrew. This is not a failure of the model. The problem occurs much earlier, when the text is extracted from the PDF.

Why does Hebrew text break in a PDF?

A PDF does not store text like a Word document. In simple terms, it stores where each letter is drawn on the page. When text is extracted, the software reads the letters in the order they were written to the file. That order does not always match the order in which a person reads them. For Hebrew, which runs from right to left, this becomes a serious problem.

Three failures appear repeatedly:

  • Reversed order. The letters arrive in the order produced by the PDF engine rather than reading order. A complete line can become scrambled.
  • Mixed directions. In a line containing Hebrew together with a number, date, or English word, sections running in different directions become mixed. A telephone number or amount may appear with its digits in the wrong order.
  • Incorrect font encoding. Some Israeli PDF generators map Hebrew letters to similar Latin letters in the file’s character table. The page looks correct on screen, but the extracted text is English gibberish.

The correct extraction sequence

The solution is not one magic tool, but an ordered process. This is how we build Hebrew PDF extraction that holds up in practice:

  1. Read according to the document type. A PDF containing real text is read directly. A scanned PDF requires optical character recognition. Word documents and ZIP archives are handled in their own ways. One method does not fit every file.
  2. Correct font encoding first. If the file maps Hebrew to Latin characters, repair that mapping before any further processing. Otherwise, every later step is working with gibberish.
  3. Reorder by physical position. Instead of relying on the order produced by the file, arrange the letters in each line according to their position on the page. Reconstruct word boundaries using the spaces between characters.
  4. Apply the bidirectional algorithm. Run the Unicode bidirectional algorithm on each line. It restores Hebrew to right-to-left order while keeping numbers and English left to right, so telephone numbers remain readable and brackets do not reverse.

Only after this process do you have clean text that can be searched or sent on for further processing.

Focused extraction: extract less, get a better answer

It is tempting to send the entire document to a language model and ask it to find the answer. In most cases, that is a mistake. A long document costs more on every request, while accuracy can fall because the relevant information is buried in pages of noise unrelated to the question.

The approach that works is the opposite. First extract only the sections relevant to the question, then send those sections to the model. Turning eighty pages into one focused page costs less, reads faster, and produces a more accurate answer. Focused extraction is not a shortcut. It is what makes using AI on documents worthwhile at all.

What should you remember?

If Hebrew breaks when you send documents to a model, the problem is almost always in extraction rather than the model. Reliable extraction of Hebrew text and data follows a precise sequence: read according to file type, repair encoding, reorder by position, apply a bidirectional algorithm, and then extract only what is needed. Do that properly, and everything that follows, including search, summarization, and language models, can work as intended.

Want to extract data from Hebrew documents in your business and not sure where to start? Talk to us, and we will tell you honestly whether there is something worth automating.