News for hackers. Stuff that matters.
Re:Show HN: I am building a new Python library to read/write... by mdaniel on Thursday November 17, 2022 @07:32PM (#33648113)
I never knew about the J number suffix in python: https://docs.python.org/3/reference/lexical_analysis.html#im... which it would appear is used to represent references: https://github.com/desgeeko/pdfsyntax/blob/main/tests/test_p...

I wish you good luck, this file format has tripped up many, many a developer. It blew up on a pdf I had lying around:

    ValueError: could not convert string to float: b'5.0.0'


    104 0 obj <<
    /Producer (pdfTeX-1.40.10)
    /Creator (TeX)
    /CreationDate (D:20131209161146-08'00')
    /ModDate (D:20131209161146-08'00')
    /Trapped /False
    /PTEX.Fullbanner (This is pdfTeX, Version 3.1415926-1.40.10-2.2 (TeX Live 2009/Debian) kpathsea version 5.0.0)
    >> endobj
as it seems a string with nested parens jams up the parser
Re:Show HN: I am building a new Python library to read/write... by mdaniel on Thursday November 17, 2022 @07:39PM (#33648173)
This is tangential to your submission, but PDF is the file format I use for exercising any library that claims to be a declarative file format (ala https://github.com/kaitai-io/kaitai_struct_formats#readme )
Re:Show HN: I am building a new Python library to read/write... by BiteCode_dev on Friday November 18, 2022 @01:40AM (#33651162)
J is for complex numbers. While math.sqrt(-1) raises an exception, cmath.sqrt(-1) returns 1j.
Re:Show HN: I am building a new Python library to read/write... by lordgrenville on Friday November 18, 2022 @05:32AM (#33652836)
Parent was referring to "references" in the PDF spec (eg 42 0 R)
Re:Show HN: I am building a new Python library to read/write... by fgeiger on Friday November 18, 2022 @04:53AM (#33652551)
The PDF format is diverse enough for such a new project to still have plenty of incompatibilities. If you wanted to find many of them quickly, you might want to have a look at the documents used as test cases in other projects, such as pdf.js:

https://github.com/mozilla/pdf.js/tree/master/test/pdfs

Re:Show HN: I am building a new Python library to read/write... by jonnycomputer on Friday November 18, 2022 @07:49AM (#33653833)
Valuable practical, actionable advice