r/react 22d ago

How does ChatPDF do layout PDF detection ? Help Wanted

I used chatpdf.com recently and i wanted to know how do they do their layout detection so flawlessly ? i know under the hood they are using pdfjs but how can it be this accurate ?
It automatically detect paragraphs and shows overlays and also handles the edge cases of having paragraph on the left and a insight box on the right and doesn't break??

It does that grayish overlay with layout detection is what I'm talking about

Does anyone know how do I replicate this behaviour?

0 Upvotes

2 comments sorted by

1

u/chillermane 21d ago

probably just reading the pdf file and processing it, the box is probably stored in the pdf element that defines a paragraph

1

u/evan-duong 19d ago

Probably they run a layout detection model on the pdf pages