IDEAS, METHODS & DOCUMENTS

OmniDoc Journal.

A closer look at documents.
Parsing, translation, and what comes next.

77 articles

Structured data

extraction to JSON is not equivalent to correct extraction: establish field contracts for amount, unit, and source

hands the invoice or quotation to the parser and obtains a valid JSON, which only indicates that it can be read by the program.1200 is the unit price or the tot

Read article
HTML & web

HTML to plain text: how to prevent two paragraphs from being stuck together

When you use Beautiful Soup to extract web page content, the most common issue isn't extraction failure, but rather that the extracted text gets "stuck" togethe

Read article
Excel & data

Percentage and amount cannot be read-only value: carry the format along with it

When automating Excel report processing or performing document translation, developers often fall into a subtle trap: directly reading cell.value and assumes th

Read article
Excel & data

Exporting large tables in a single operation—what are the costs associated with write_only mode?

writes to the worksheet only via sequential appending and does not support random access by coordinates. You should first define the relevant layout, then appen

Read article
Excel & data

Excel merged cells have values only in the top-left corner; how should they be extracted?

When using openpyxl to iterate through Excel row data, developers often encounter a typical issue: in the Excel application, cells A2:A5 clearly display the sam

Read article
Word & layout

Header issue in multi-page Word tables: First, distinguish between data and layout

The most common failure when programmatically parsing cross-page Word tables is not that the content cannot be read, but rather that “repeated header rows in th

Read article
Word & layout

The author and revision attributes of the Word document—should they be preserved before exporting?

The core string attributes can be cleared, but the date attribute cannot be assigned None. Below, we retain the date and demonstrate only the cleaning of string

Read article
Word & layout

After translation, the word count increases; first examine the text before and after the paragraph

An empty paragraph does not have spacing explicitly set, nor can it be assumed to be harmless; style inheritance, section breaks, and drawing objects may all af

Read article
Word & layout

Where should the caption for a Word image be placed so it doesn’t get lost?

The text of the paragraph containing the image is merely contextual candidate material, not a verified figure caption. Inline and floating figures should be inv

Read article
Word & layout

For landscape table pages in the same Word document, do not uniformly change the orientation for the entire document

After constructing all sections, re-fetch the target section by its index to avoid mistakenly treating the last section object saved before adding new subsectio

Read article
Word & layout

The Word document text is fine, but the header remains in the original language.

When translating multi-chapter Word documents, a common issue is this: the main text has been perfectly replaced with the target language, yet the headers and f

Read article
Word & layout

Why does Word read out duplicate content when merging cells?

merged cells appear repeatedly in layout grid access and cannot be deduplicated by text. This synthetic example constructs only horizontal merges; omitting grid

Read article
PDF engineering

After overlaying two PDFs, a portion is missing: check the page boxes rather than just looking at the paper size

The CropBox modifies the display area, not the page content itself. If a stamp becomes invisible after being overlaid on the right side of the page, first check

Read article
PDF engineering

pypdf cannot extract text from scanned documents; simply changing a parameter will not solve the issue

Short or empty text is merely a signal for further verification and should not be directly equated with a scanned document. Below, we record page by page whethe

Read article
PDF engineering

PDF and attachments? Don’t forget to embed the files before delivery

attachments with the same name can correspond to multiple pieces of content. Do not use local sequence numbers or cleaned-up names as global keys; instead, assi

Read article
PDF engineering

Why can’t the body text be extracted from a filled-in PDF form?

The values of AcroForm fields and the text rendered on the page come from different sources. Below, we construct text fields using PyMuPDF and then read them wi

Read article
PDF engineering

encounters an encrypted PDF; how should the task queue be stopped

When building an automated document-processing pipeline, the most insidious failures are often not program crashes, but rather the silent generation of blank or

Read article
PDF engineering

Where did the table of contents go after merging PDFs: First, define bookmark retention rules

When merging, first decide whether to import the original table of contents. If you wish to create the top-level entry yourself, explicitly set import\outline=F

Read article
PDF parsing

When parsing PDFs in batch, why should each process open the file itself?

Multi-process tasks should pass serializable parameters, with each worker process independently opening the document rather than sharing Document or Page object

Read article
PDF parsing

Before handing over the PDF translation task, first check the fonts instead of rushing to change them.

’s default font list differs in length from the tuple returned when full=True. Below, read the first six items, then check whether the font bytes returned by ex

Read article
PDF parsing

PDF can be viewed but not copied; it may not be a scanned document

lacks text, so it cannot be directly determined to have a “normal text layer,” nor can it be directly classified as a scanned document. Below, we separately rec

Read article
PDF parsing

Will the links still work after translating the PDF? First, create a list of the links

The link protocol is on the allowlist, which only indicates that this particular format check has passed; it does not imply that the target website is trustwort

Read article
PDF parsing

applying a black box to a PDF is not anonymization: what checks are actually required for true deletion

draws a black rectangle over the ID number in the PDF, saves it, and sends it to a colleague; the recipient can still use Ctrl+F to search for the complete numb

Read article
PDF parsing

When handing over annotated documents, don’t just submit a seemingly clean PDF.

directly addresses a high-frequency fault: when you use page.gettext() When extracting PDF content for translation or archiving, the default output typically do

Read article
PDF parsing

Cover page, Roman numerals, and the first page of the main text: Don’t confuse PDF page numbers

page-numbering tag rules use firstpagenum, not start. When the cover page has only a prefix, the read-back rule dictionary may omit style; a more meaningful acc

Read article
PDF parsing

File name does not match the document title: How to organize PDF metadata

when the automation script processes reportfinalv2.pdf When the document title is written into the database, downstream translation or retrieval systems may rec

Read article
PDF parsing

PDF table recognition is not just converting to CSV: first, check the headers and boundaries

When you receive a scanned or typeset PDF financial report, run findtables() After directly exporting to CSV, you will very likely encounter three types of “sil

Read article
PDF parsing

highlights search terms in the PDF, but why does the rectangle incorrectly enclose italicized text?

Italics do not necessarily ensure that the area of the searched Quad is smaller than that of its bounding rectangle. When it is necessary to preserve corner-dir

Read article
PDF parsing

I just want to see the signature section of the contract—why do you have to render the entire page?

Whether image cropping is valid should be verified by checking the decoded pixel dimensions, rather than using the PNG byte count as a quality metric. For examp

Read article
PDF parsing

generates thumbnails for long PDFs, first calculating the pixel dimensions and memory usage

generates thumbnails in batch for a 200-page engineering drawing PDF; the script is killed by the system due to OOM when it reaches page 30. This is a typical i

Read article
PDF parsing

Why do the images extracted from the PDF differ from those displayed on the page?

Images with transparency may be stored separately as the main image and a soft mask. Below, we construct an RGBA PNG using Pillow, then insert it into an in-mem

Read article
PDF parsing

After trimming the page margins, does the PDF’s content really disappear?

When you use code to shrink the CropBox of a PDF page by a small margin, visually it does indeed appear that only the core content remains; however, this does n

Read article
PDF parsing

The PDF appears to be in landscape orientation, but the extracted coordinates are incorrect: clarify the rotation matrix

You are parsing a scanned document or an engineering drawing; to the naked eye, the table appears on the right side of the page, but gettext() The returned coor

Read article
PDF parsing

An amount in the PDF—how can its position on the page be retrieved?

appears twice in a single statement 1,200.00: once in the payable amount field, and once in the description text. A full-text search can locate both, but it can

Read article
PDF parsing

Why does the two-column PDF turn into a single column when extracted? First, preserve the coordinates; then discuss the reading order.

The left column is read halfway through when the next sentence abruptly transitions to the formula explanation in the right column. Such issues do not necessari

Read article
OCR & images

How to quickly inspect a 100-page scan: Start with a traceable thumbnail overview

Opening a hundred-page scan one page at a time is very slow, and skipping to the first page risks missing inverted, blank, or duplicate pages. A thumbnail overv

Read article
OCR & images

OCR has performed scaling and cropping; how is the recognition box mapped back to the original text

The bounding box returned by OCR is very accurate on the local image, but when rendered back into the PDF, it is offset overall. Do not immediately suspect the

Read article
OCR & images

How can the OCR upload interface be designed to prevent a single image from consuming the entire machine’s memory

uploads a file that is only a few megabytes in size, yet after decoding it may require far more memory than expected. Highly compressible images, in particular,

Read article
OCR & images

A TIFF file does not necessarily contain only a single image: frame-by-frame processing ensures that no pages are missed

After opening a TIFF file, only the first page was processed; the program did not report any errors, yet it had already skipped the remaining content. For multi

Read article
OCR & images

Can enlarging the small image by a factor of four improve OCR?

enlarges the small image by a factor of four, increasing the number of pixels, but strokes that were not originally recorded will not automatically reappear. Re

Read article
OCR & images

scanned pages appear grayish; why does enhancing contrast not necessarily improve accuracy?

The scanned page appears washed out; increasing the contrast does make it more noticeable, but light-colored stamps and fine lines may also disappear. Preproces

Read article
OCR & images

Transparent PNG turns black after OCR; how to properly apply a white background?

A text PNG with a transparent background looks fine on the web page, but after being fed into a certain processing pipeline, it turns into a black background. T

Read article
OCR & images

How big is a scanned image, exactly: don’t confuse pixels, DPI, and page dimensions

changes the image DPI from 72 to 300; the file properties now look more professional, but the text edges remain unclear. DPI is information about physical size

Read article
Delivery pipelines

The same PDF code fails when run on another machine; first submit the environment information

“The same piece of code runs on my computer” is not a reproduction report. PDF rendering and document conversion are also affected by library versions, system f

Read article
Delivery pipelines

task shows as completed, why isn’t the file ready for download yet

The button says “Complete,” but clicking download returns an empty file. Typically, this isn’t a matter of textual feedback; rather, the backend only logs that

Read article
Delivery pipelines

When handing the translation to a colleague, which checklist should be included in the zip file?

The delivery package contains only a few translation files, and the colleague does not know which source document they correspond to, what the target language i

Read article
Delivery pipelines

Power loss during export—how can we avoid delivering a half-finished file?

The file was halfway written when the service restarted, yet the download link had already been made available to users. Such failures are not as simple as “the

Read article
Delivery pipelines

document processing timed out; do not let a single task stall the entire batch

A scanned PDF got stuck, and the subsequent ninety-nine tasks remained idle. Adding a timeout to the request seemed to resolve the issue, but in reality, the pr

Read article
Delivery pipelines

Before processing DOCX and EPUB, first set a budget for ZIP decompression.

DOCX is essentially a set of ZIP entries, and EPUB also uses a ZIP container. Receiving a very small compressed file does not mean it will remain small after de

Read article
Delivery pipelines

The name of the file uploaded by the customer cannot be used directly as the storage path

uploads a file named ../../report.pdf, does not mean the server should save the file under that name. The filename originates from the user and constitutes inpu

Read article
Delivery pipelines

Files with the same name do not necessarily refer to the same file: use content hashing to identify inputs.

The client subsequently sent two documents, both titled final.pdf Which of the files has been translated? Relying on file names to answer this question is risky

Read article
Structured data

Why is it worthwhile to store page numbers and original text fragments in JSON?

extraction yields only one amount: 1200, the reviewer still has to reread the entire document. Saving additional page numbers and short original text fragments

Read article
Structured data

Invoices and receipts share a common entry point; how can we prevent the two structures from becoming mixed together

An interface that accepts both invoices and receipts at the same time can easily result in a large object with “all fields optional.” Such an object can accommo

Read article
Structured data

Can the amount be negative: Separate business rules from type rules

writes all amount fields as minimum: 0, though seemingly rigorous on the surface, ends up blocking legitimate refund records. Whether the amount has been conver

Read article
Structured data

The model outputted one extra field; should it be accepted or rejected?

The extraction result contains one extra item. confidence, which appears quite useful on the front end, was thus directly displayed as “trustworthiness.” The pr

Read article
Structured data

extraction detail table—make sure the sorting doesn’t alter the row-to-row relationships

The amounts in the two rows of details are identical, which does not indicate that they are duplicate data; nor does the sorted table, which appears more organi

Read article
Structured data

When extracting the order status, why should there be an "unknown" option?

When the order status is not in the system’s predefined list, the easiest approach is often to select the value that “most closely resembles” it. The time saved

Read article
Structured data

Field missing and field being null are two distinct types of failure.

“Field not found” and “Field is null” may both appear as blank on the user interface, but they should not be treated as equivalent once the program is executed.

Read article
Translation QA

How to sample long documents: Don’t just look at the first three pages

reviewing a lengthy translation draft—looking only at the first few pages is usually insufficient. The cover page and table of contents may be neatly formatted,

Read article
Translation QA

Duplicate paragraphs can reuse the translation, but the cache key cannot—only the original text

“Save” may look the same across two projects, but its translation, capitalization, and context can differ. Using the original text’s hash as the unique cache ke

Read article
Translation QA

Let the reviewer examine the changes first: How to create a translation difference table that does not mislead

An English draft was revised ten times, requiring the reviewer to read it from scratch each time, which is not very efficient. A diff view can focus attention o

Read article
Translation QA

Why do seemingly identical terms fail to match?

The term is clearly listed in the glossary, yet the program reports no match. Printing out the string reveals that both sides appear identical. The issue may no

Read article
Translation QA

The translated webpage displays &—was it decoded one extra time?

The page displays a string of &, the first reaction is often to decode it once more. But the problem may be just the opposite: the same piece of content has

Read article
Translation QA

The glossary is not a find-and-replace operation: first define word boundaries and exceptions

The glossary contains API, does not mean that every word in the document containing these three letters should be replaced.APIs is morphological variation,apiga

Read article
Translation QA

The numerical values in the translation are correct, but the units have been omitted: the check should be performed in two layers

in the translation, 1,234.50 becomes 1.234,50, may merely represent a change in the numeric format, or it might be incorrectly parsed as another quantity. Numer

Read article
Translation QA

The {name} in the translation text is missing—how can we prevent this before going live?

“Welcome, {name}” After being translated into another language, the variable names are translated along with it, and the page typically only reports an error wh

Read article
HTML & web

being able to parse HTML does not mean it can safely render HTML

When you have successfully parsed a section containing <img src=x onerror=alert(1)> When the string is deserialized, this malicious code remains intact in the o

Read article
Structured data

Before using a regular expression to validate the number, first think carefully about what to do with full-width characters.

number AB-1234 looks simple, but the actual input may contain prefixes, trailing line breaks, or full-width characters. Writing just one regular expression and

Read article
HTML & web

The same piece of malformed HTML—why do two parsers produce different results?

When you use Beautiful Soup to extract the main content of a webpage, the most insidious issue isn’t an error message—it’s “no error, but the content is missing

Read article
HTML & web

Technical document translation is most afraid of translating the code along with it

puts userid is translated as “user identifier,” or <div class="container"> Localizing the class attribute in [ ] is the most costly and hardest-to-diagnose erro

Read article
HTML & web

Web page titles range from H1 to H6, but this does not necessarily imply a reasonable hierarchical structure

When dealing with technical documentation or web content, a common misconception is that as long as there is in HTML <h1> to <h6> tag; the document structure is

Read article
HTML & web

After translating a Chinese article into English, simply replacing the main text is not enough.

translates a segment of Chinese HTML into English, if it only replaces<p>The text content within the tags, without making corresponding changes.langAttributes—s

Read article
HTML & web

The exported HTML has changed its domain; why have the images and links broken?

The baseline for urljoin should be the original page URL; do not arbitrarily append a trailing slash to convert a file URL into a directory. This example handle

Read article
HTML & web

HTML’s rowspan and colspan, how to expand them into a two-dimensional table

When you are working with an HTML document that contains complex table headers, directly extracting<td>text often yields corrupted data. A setting withrowspan="

Read article
PDF engineering

Is a PDF that can be opened considered fixed? The correct position in strict mode

In the engineering practice of batch-processing PDF files, the most dangerous signal is often not a program error, but rather PdfReader silently returned what a

Read article
PDF engineering

Before compressing the PDF, first determine whether you can accept image loss.

below only checks lossless compression of the content stream: the decoded bytes before and after compression should be identical to the extracted text. It does

Read article
Word & layout

In Word, bold is None—so does that count as bolding or not?

’s direct format of None indicates that no value has been set, not False. Here, only the direct format and the explicit character style chain are checked; when

Read article