News for hackers. Stuff that matters.
Re:Show HN: I am building a new Python library to read/write... by jahewson on Thursday November 17, 2022 @08:24PM (#33648571)
Despite the thousands of pages of ISO 32000, the reality is that the format is not defined. Acrobat tolerates unfathomably malformed PDF files generated by old software that predates the opening-up of the standard when people were reverse-engineering it. There’s always some utterly insane file that Acrobat opens just fine and now you get to play the game of figuring out how Acrobat repaired it.

Plus all the fun of the fact that you can embed the following formats inside a PDF:

PNG, JPEG (including CMYK), JPEG 2000 (dead), JBIG2 (dead), CCIT G4 (dead, fax machines), PostScript Type1 fonts (dead), PostScript Type3 fonts (dead), PostScript CIDFonts (pre-Unicode, dead), CFF fonts (the inside of an OTF), TrueType fonts, ICC Profiles, PostScript functions defining Color spaces, XML forms (the worst), LZ compressed data, Run-length compressed data, Deflate-compressed data.

All of which Acrobat will allow to be malformed in various non-standard ways so you need to write your own parsers.

Note the lack of OpenType fonts, also lack of proper Unicode!

Re:Show HN: I am building a new Python library to read/write... by userbinator on Thursday November 17, 2022 @09:47PM (#33649303)
JPEG 2000 (dead)

Not sure what you mean by "dead", but tons of book scans, particularly those at archive.org, are PDFs of entirely JPEG2000 images.

Re:Show HN: I am building a new Python library to read/write... by joe_guy on Thursday November 17, 2022 @09:58PM (#33649411)
Believe it or not, but digital cinema projection is done with jpeg 2000 https://en.wikipedia.org/wiki/Digital_cinema
Re:Show HN: I am building a new Python library to read/write... by jahewson on Thursday November 17, 2022 @10:17PM (#33649606)
That’s wild!
Re:Show HN: I am building a new Python library to read/write... by jahewson on Thursday November 17, 2022 @10:16PM (#33649602)
I mean dead as in the fact that it’s used somewhere is noteworthy.

I’d love for JPEG XL to replace such uses!

Re:Show HN: I am building a new Python library to read/write... by jwilk on Friday November 18, 2022 @08:40AM (#33654449)
> lack of proper Unicode

What do you mean?

Re:Show HN: I am building a new Python library to read/write... by pwg on Friday November 18, 2022 @09:11AM (#33654946)
PDF was defined way back before Unicode was ever a thing. It is natively an 8-bit character-set format for text handling. The way it gets around this limit of only 256 characters available is because it also allows defining custom byte to character glyph mappings (think both ASCII and EBCDIC encoding in different parts of the same document). To typeset a glyph that is not in the current in use 256 character sub-set mapping you switch to a different custom byte value to character glyph mapping to typeset that other character.
Re:Show HN: I am building a new Python library to read/write... by jwilk on Friday November 18, 2022 @09:27AM (#33655172)
> PDF was defined way back before Unicode was ever a thing.

Unicode 1.0 was released in 1991.

PDF 1.0 was released in 1993.