3 ms·
PDF is an unusual and awkward hybrid format containing both textual (complete with comments!) and binary data. Thanks to this and other dubious design choices,
by userbinator 8y ago
PDF is an unusual and awkward hybrid format containing both textual (complete with comments!) and binary data. Thanks to this and other dubious design choices, it's far easier to write a PDF than to read one. One of the most memorable examples is indirect object references; when reading an array, you can only distinguish them from integers once you've already read and parsed 2 integers, and then see the letter 'R' (e.g. "5 0 R"). A trivial transposition that puts the 'R' first (e.g. "R 5 0") would've simplified parsing greatly, since then the first character is enough to know what comes next. I remember having to deal with lots of trivial-yet-easily-fixable annoyances like this when I worked on some PDF parsing code.
- fulafel 8y agoThis comes straight from the PostScript ancestry and the Forth style stack, right? Are there problems associated implementing this processing Forth-style, so you parse words and put them on the stack, and pop 2 operands when you see 'R'?
- Someone 8y agoIt’s easiest to see it as what it is: a textual format that evolved allowing binary blobs inside it. You can write a PDF in notepad, or every text editor, and, if you know your postscript, it isn’t that bad of an experience if you forget about modern features, except for that table of contents at the end of the file. See https://brendanzagaeski.appspot.com/0004.html https://brendanzagaeski.appspot.com/0004.html
- userbinator 8y agoIt's a textual format... with byte offsets. That's the most unusual part, and it's been there since the beginning (PDF 1.0).
- peapicker 8y agoWhile PDF uses different syntax, it is conceptually similar to the IFF file format from 1985 (the basis of which is still used in some file formats like PNG and AIFF) in being a format that can contain multiple types of data. PDF is a little bit more focused on being an object-based file format in specific, but one could have made PDF fit into IFF boxes easily in an alternative universe.