#1958·xberg

bug: PDF: alignment instructions are lost or detached from spanning table cells

Author: thisislvcaCreated Sep 29, 2026Updated Sep 29, 2026
Labelsbug

Description

On page 7 of this public PDF, the Allineamento cells for CB, DT and DN are empty in the extracted table, although the instructions are visible in the PDF and present in plain page text.

Row Expected alignment cell Actual table cell
CB Destra empty
DT Destra con 8 spazi a sinistra empty
DN Destra con 8 spazi a sinistra empty

In document.nodes, the two con 8 spazi a sinistra strings appear together in a paragraph outside the table. The three corresponding Destra occurrences are lost from the structured page. The instructions should remain in their respective alignment cells, not be omitted or detached from the rows they describe.

This is a remaining case from #1802 / #1804. The row labels are now retained, but the alignment instructions are not. I replayed the original PDFs before our patch, at the submitted PR revision and on 1.3.0: these alignment cells were already empty before our change. This is not a regression introduced after that PR. The exact cause of the remaining omission has not been isolated yet.

Steps to reproduce

Download the PDF above as instructions-770-2026.pdf.

Install @xberg-io/[email protected] in a scratch directory and save this as repro.mjs:

bash
npm install @xberg-io/[email protected]
javascript
import { readFile } from 'node:fs/promises';
import { createHash } from 'node:crypto';
import { extract, ExtractInputKind } from '@xberg-io/xberg';

const [filename, pageArg, expectedHash] = process.argv.slice(2);
const page = Number(pageArg);
const bytes = await readFile(filename);
if (createHash('sha256').update(bytes).digest('hex') !== expectedHash) {
  throw new Error('PDF SHA-256 mismatch');
}
const output = await extract(
  { kind: ExtractInputKind.Bytes, bytes, filename, mimeType: 'application/pdf' },
  {
    disableOcr: true,
    useCache: false,
    enableQualityProcessing: false,
    outputFormat: 'plain',
    pages: { extractPages: true },
    includeDocumentStructure: true,
    pdfOptions: { extractTables: true, ocrInlineImages: false },
  },
);
const result = output.results[0];
console.log(JSON.stringify({
  pageText: result.pages[page - 1].content,
  tables: result.tables.filter(t => t.pageNumber === page),
  nodes: result.document.nodes.filter(n => n.page === page),
}, null, 2));

Run:

bash
node repro.mjs instructions-770-2026.pdf 7 b2919f591497d1d1c7b0b7719865a121c1ba365d2b3e66fee0ee2b4c145a242a > result.json

Compare pageText with the Allineamento column in tables[0].cells and the table/paragraph entries in nodes. The script verifies the original PDF hash before extraction.

Relevant files and configuration

Reproduced with the published macOS arm64 Node binding, @xberg-io/[email protected]. OCR, caching and quality processing are disabled; table extraction and document structure are enabled. No application-side transformation is involved.