Live data from Hacker News

Show HN: I am building a new Python library to read/write PDF files

github.com

71–80 of 126 posts

Re: Show HN: I am building a new Python library to read/write PDF files

#71
post #6

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 > e…

J is for complex numbers. While math.sqrt(-1) raises an exception, cmath.sqrt(-1) returns 1j.

There is not distinction between values and references in python, everything is a reference. In fact, primitive like numbers are big struct objects in cpython, you cannot just manipulate the raw numbers.

The difference will rather wether you can modify an object or not. You cannot modify numbers, as they are immutable. Any increment will produce a new object. But you can modify a list. This gives the feeling numbers are passed as values and list are passed as references.

Re: Show HN: I am building a new Python library to read/write PDF files

#72

I once had to help an accountant friend to fill in 1000's of docx files, and convert them to pdf. No open source tool does a proper conversion, it really sucked.

it's such a complex messy format that i'm really not surprised.

Re: Show HN: I am building a new Python library to read/write PDF files

#74

Is there a list of open source PDF libraries for various languages? And related: the best tools to generate PDFs from HTML.

As I'm currently fighting with css3/paged media[pm] - I've recently tried to figure it out.

Theres a rather comprehensive list at: https://www.print-css.rocks/tools

As far as Foss tools go, I've only found paged.js (a polyfyll) in combination with a browser print-to-pdf (eg wkhtmltoodf (webkit) or puppeteer (chrome)) that has any semblance of css support.

There's also ghostscript - but AFAIK it doesn't support much/any css3 for print.

[pm] https://www.w3.org/TR/css-page-3/

Re: Show HN: I am building a new Python library to read/write PDF files

#78

I once had to help an accountant friend to fill in 1000's of docx files, and convert them to pdf. No open source tool does a proper conversion, it really sucked.

Yeah, this would be horrible, but on flip side relatively easy to do with Word to hand.

Re: Show HN: I am building a new Python library to read/write PDF files

#79

I once had to help an accountant friend to fill in 1000's of docx files, and convert them to pdf. No open source tool does a proper conversion, it really sucked.

I have used Perl and Win32::OLE for this kind of job.

Converting to PDF is actually quite easy. Before Office 2010, you had to print to Postscript and then convert to PDF using Ghost. Nowadays Word gives you the option of saving to PDF.

Re: Show HN: I am building a new Python library to read/write PDF files

#80
post #6

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 > e…

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

Post reply on HN