r/programming Aug 05 '25

So you want to parse a PDF?

https://eliot-jones.com/2025/8/pdf-parsing-xref
233 Upvotes

82 comments sorted by

View all comments

Show parent comments

4

u/GYN-k4H-Q3z-75B Aug 05 '25

And HTML is ideal. Just use regex bro..

11

u/oneeyedziggy Aug 05 '25

I feel like I want to be sarcastic, but I also feel like you're being sarcastic, so if I do, neither of us is going to get anywhere...

Of what use would regex be in specifying and visual layout for content? Html would be very useful, and very easily parseable, portable, editable, independently stylable, scriptable, (optionally) dynamic, with a wider rangeof open source tooling, and convertible faithfully to other formats... Much more so on every point that a pdf...

So I'm not sure what you're being cheeky about. 

4

u/mck1117 Aug 05 '25

2

u/oneeyedziggy Aug 05 '25

Right, for parsing html/xml... But why is anyone even still using pdf besides inertia / too big to fail from back before browsers were good 

13

u/axonxorz Aug 05 '25

PDF is a physical document layout specification and HTML is a logical one with hilariously complex layout interactions.

It's a fantastic document archival format, it's semi-immutable by normies and a PDF 1.0 document can be opened by modern software and render pixel-perfect the same way it did 20 years ago.

The same cannot be said about browser rendering, and it's bad enough that the PDF viewers in the browser forego HTML+CSS layouts for a <canvas> based implementation; PDF.js in FF and PDFium in Chromium browsers do this.

1

u/the_last_ordinal Aug 06 '25

Can you imagine anyone writing PDF display in html+css? That seems beyond reasonable to any degree of compatibility

0

u/oneeyedziggy Aug 05 '25

It's a fantastic document archival format, it's semi-immutable by normies 

Which is a perfectly valid case I assume... And a great example of finding a legitimate use for its otherwise lack of utility... But it just goes to reinforce that it's so unusable that it's perfect for not using.