Live data from Hacker News

Show HN: HTML visualization of a PDF file's internal structure

github.com

21–30 of 60 posts

Re: Show HN: HTML visualization of a PDF file's internal structure

#21

Is the UI tooling that does the visualization a library? I really like the UI format, would love to use this for breaking down and debugging video byte streams too. EDIT: Oh it's actually reasonably simple, great use of CSS! https://github.com/desgeeko/pdfsyntax/blob/main/docs/simple_...

Yes, I value simplicity and the interactivity offered by basic HTML and CSS is sufficient for my use case :)

Re: Show HN: HTML visualization of a PDF file's internal structure

#22
post #5

I remember there was a similar project on github allows visualize any type of binary data by a given schema. There was an TCP/IP example IIRC.

Be careful, "any" is a strong word in this context. Interestingly enough, I actually use PDF as the "hello world" for kicking the tires on any such file format descriptor I find because PDF is such a crazypants specification. Thus, if the descriptor language is able to accurately capture the layout of a PDF, it's obviously well thought out.

I haven't had a lot of luck thus far, except ones which allow escaping out of declarative mode over into "and then run this code"

Re: Show HN: HTML visualization of a PDF file's internal structure

#23
post #4

Wow, I've been doing some PDF parsing at work and this is going to come in SO handy.

Was mentioned in this thread, but I can also endorse qpdf as being a great library.

It gives you a JSON representation of the PDF data structure. What's nice is that doesn't hide the underlying format but it takes care of a lot of the low level edge cases for you.

Re: Show HN: HTML visualization of a PDF file's internal structure

#25
post #3

Damn, this is also convenient for forensics and finding watermarks.

That does sound interesting. Forgive my ignorance, but how could this be used to detect watermarks? Could the same method be used to detect signatures?

This tool is pulling out all the metadata in the document. Lots of goodies in there not typically displayed.

Re: Show HN: HTML visualization of a PDF file's internal structure

#26
Many moons ago I was tasked with extracting data from a bunch of PDFs. I made a tool to visualise how characters were laid out on the page and bounding boxes of all the elements.

The project was in the end a complete failure and several people were upset at me for not delivering what I was supposed to.

In present day, with the capabilities that are now available with LLMs to extract data from PDFs I 100% would go the route of utilising AI to extract the data they wanted. Back then that did not yet exist.

Re: Show HN: HTML visualization of a PDF file's internal structure

#27

If you're interested in manipulating PDFs, I've found QPDF [0] to be a useful tool. Its "QDF mode" lays out the objects in a form where you can directly edit them, and it can automatically fix up the xref table afterwards. It can also convert to and from a JSON format that you can manipulate with your own scripts. [0] https://github.com/qpdf/qpdf , https://qpdf.readthedocs.io/en/stable/

Just so we have them, the top links I got for PDF to JSON:

https://qpdf.readthedocs.io/en/stable/json.html

https://www.jsonify.org

https://github.com/maximoguerrero/PDF-GPT4-JSON

PDF is such a curious format. It's not human-readable, it's not well-structured, it's not small. If it weren't for momentum and the political horse trading that Apple, Adobe and Microsoft were doing when the web went mainstream and freaked them out around 1995, I'm not sure that we'd be using it today. Postscript is better in countless ways, but since it's Turing-complete, it's not really ideal for storing static data, and to my knowledge was never extended to handle binary data well, like for embedded JPEGs. I remember trying to print a 10 MB ps file in the 1990s and it took maybe 20 minutes because the grayscale image was basically represented as a bunch of run-length encoded scan lines.

I would argue that frontend web development has reached a similar fate. It seems odd to use programming language (imperative, no less) to design media that we used to describe declaratively. If I had enjoyed success in my programming career, I would work on a declarative representation of HTML/CSS/Javascript that can represent the intersection of all existing markup across all mainstream browsers. Sort of like a mix between Markdown and CSS flexbox like Xcode's auto layout, but universal. It frankly would probably look like HTML, but with sane defaults/builtins/inheritance, as well as a way define and extend components from the beginning, similarly to how people try to use data attributes. For contrast, React and Vue come at this from the opposite direction. I'm talking about something more like htmx.

Then we could work with that format and transpile to HTML or even React Native and dump 90-99% of the boilerplate and build tooling that we use currently.

Re: Show HN: HTML visualization of a PDF file's internal structure

#28

If you're interested in manipulating PDFs, I've found QPDF [0] to be a useful tool. Its "QDF mode" lays out the objects in a form where you can directly edit them, and it can automatically fix up the xref table afterwards. It can also convert to and from a JSON format that you can manipulate with your own scripts. [0] https://github.com/qpdf/qpdf , https://qpdf.readthedocs.io/en/stable/

[deleted]

Re: Show HN: HTML visualization of a PDF file's internal structure

#30

I’ve been shopping for something that does a per-byte description of the content of visual media formats (jpeg, png, avi, mp4, etc). Anyone know of one?

This sounds like the format specification? What are you looking for that is not a document?

I want to drop a specific image in, and have a reader that debugs this. Sometimes images don't follow specs exactly, or stretch them in fun ways, and sometimes this leads to inconsistent behaviour across platforms. Sometimes passing an image through a platform strips or reformats this data.

The current context for me is I'm exploring various non-steganography approaches to embed metadata in photos. In the past, I've built custom formats to embed streaming data side-by-side: https://github.com/dustinfreeman/kriffer

Post reply on HN