Title: fix(file-parsers): read side-by-side calendar grids one block at a time by waleedlatif1 · Pull Request #8232 · simstudioai/sim · GitHub
Open Graph Title: fix(file-parsers): read side-by-side calendar grids one block at a time by waleedlatif1 · Pull Request #8232 · simstudioai/sim
X Title: fix(file-parsers): read side-by-side calendar grids one block at a time by waleedlatif1 · Pull Request #8232 · simstudioai/sim
Description: Summary pdf.js streams text in draw order. When a page puts grids side by side (e.g. year-at-a-glance calendar months) and the producer draws one row across every grid, extraction came out interleaved — Su Mo … Sa Su Mo … Sa, then 1 2 3 1 2 3 4 … — so no date could be tied back to its month New pdf-layout.ts: groups a page's items into rows, finds bands split by a wide whitespace gutter (1-level XY-cut), and emits each block top to bottom only when all of these hold: every block is a grid cut from one template: same header row near its top (Su Mo Tu We Th Fr Sa), same width and inner column positions the gutter is ≥ 2× any column gap inside the blocks a plain column is allowed only when sparse (a legend); one spanning the band means it's a table the stream actually interleaves the blocks — pages already drawn block by block are untouched Everything else (tables, prose, forms, math) keeps stream order exactly as before; reordered bands are spliced back in at their stream position Layout analysis buffers up to 20k items per page, then falls back to streaming, so pathological pages cost the same as today joinLines treats a reordered block's first line as a paragraph start and no longer rejoins across block boundaries via the wrapped-table-cell lookahead Type of Change Bug fix Testing Unit tests for calendars, legends, account boxes, and the negative cases (evenly spaced tables, label/value lists, wrapped-cell tables, column groups with different shapes, value grids without headers, already block-ordered streams, missing geometry, item cap); end-to-end test through real pdf.js with a pdf-lib calendar. Verified the positive tests fail with the reordering disabled Before/after benchmark on 264 real PDFs (94 from the pinned parser-eval corpus + 170 assorted real-world docs): output byte-identical on 263; the one change is a Fed paper whose three side-by-side balance-sheet boxes now read box by box instead of interleaved. 22 real public calendar PDFs of other layouts (month-per-column, month-per-row) are unchanged Latency: total 22.2s → 22.7s (+2.2%), median 18 → 18 ms, p99 809 → 816 ms Earlier iterations of the heuristic (gutter-only, then structure-only, then header-only) each changed 3–70 real documents for the worse (transposed tables, scrambled equations) — the combined gates above are what got it to zero regressions Precedent: XY-cut / whitespace-gutter projection is the standard rule-based reading-order method (pdftotext, pdfminer layout analysis, PyMuPDF's column-boxes recipe); keeping content-stream order by default matches PyMuPDF, pdfplumber use_text_flow, and pdf.js itself bun run lint, check:audits (49), docs-manifest:check, type-check, file-parser suite (508) all pass Already-indexed documents need a re-sync to pick this up. Markers drawn as filled shapes (not text) are still not recoverable from the text layer. Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA) 🤖 Generated with Claude Code
Open Graph Description: Summary pdf.js streams text in draw order. When a page puts grids side by side (e.g. year-at-a-glance calendar months) and the producer draws one row across every grid, extraction came out interle...
X Description: Summary pdf.js streams text in draw order. When a page puts grids side by side (e.g. year-at-a-glance calendar months) and the producer draws one row across every grid, extraction came out interle...
Opengraph URL: https://github.com/simstudioai/sim/pull/8232
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:8ce6bc4c-f765-5252-0fda-2a3f10c4a5f8 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E106:B85F4:E4B91E:138DA7D:6AFB5C69 |
| html-safe-nonce | 2951bb1088b84a341c009475f09f1e5a45366f4e32a8ba140bba7bb44f82e283 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMTA2OkI4NUY0OkU0QjkxRToxMzhEQTdEOjZBRkI1QzY5IiwidmlzaXRvcl9pZCI6IjgwNDM0MTAzMzQ3NzUyMDQ5NjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8d7c614b8db38086f3073916580ba6df2d5db90157fc933b3e6756835566c273 |
| hovercard-subject-tag | pull_request:4627957518 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/8232/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Summary pdf.js streams text in draw order. When a page puts grids side by side (e.g. year-at-a-glance calendar months) and the producer draws one row across every grid, extraction came out interle... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | ea33d13c96d0ff66bd8fa906b193d2213536b78cb06b0c50a4632c58b1418f94 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 59ef97164c52cf59bd10558ddec9c4f482763988 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width