Live data from Hacker News

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

github.com

51–60 of 126 posts

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

#51
post #29
post #17

On the field of PDF parsing, I think the most interesting project I encountered is pdfquery[1], where the PDF is parsed as a XML tree and you can use XPath to query it. You might encounter rough edges when put it into production work but the idea is like “how come i never thought of this” because PDF has some tree like structure and should be a straightforward solution. [1]: https://github.com/jcushman/pdfquery

There is a command line utility (pdf2text) that will also parse the pdf to an XML tree and you can query with XPaths. I found it works well. https://pdfminersix.readthedocs.io/en/latest/reference/comma...

That makes sense, as "pdfquery" uses pdfminer.six as a dep: https://github.com/jcushman/pdfquery/blob/master/requirement...

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

#52
This is really wonderful, thank you! It's great to see someone focusing on the internal structure of PDF files (the "Syntax" chapter of the spec), and doing things with a focus on browsing the internal structure etc. (I had a similar idea and did something in Rust/WASM back in May; let me see if I can dust it off and put it on GitHub. Edit: not very usable, but here FWIW: https://github.com/shreevatsa/pdf-explorer)

In particular, there are so many PDF libraries/tools that simply hide all the structure and try to provide an easy interface to the user, but they are always limited in various ways. Something like your project that focuses on parsing and browsing is really needed IMO.

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

#53

I’ve done a bit of PDF wrangling in Python, so figured I’d describe the lay of the land. PyPDF [1] is great for reading and writing PDF files, especially dealing with pages, but it’s not great for generating paths, shapes, graphics, etc. However, reportlab [2] has a great API for generating those things, but is lacking in the file IO and page management department. But the content streams it generates can be plugged…

QPDF is a good C++ library for "content preserving" PDF transformations, and is used by the Python PikePDF library.

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

#58

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 once had to do this and turned all the docx into one document, used Word to export as PDF and then used a PDF splitter to get separate documents.

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

#60

I’ve done a bit of PDF wrangling in Python, so figured I’d describe the lay of the land. PyPDF [1] is great for reading and writing PDF files, especially dealing with pages, but it’s not great for generating paths, shapes, graphics, etc. However, reportlab [2] has a great API for generating those things, but is lacking in the file IO and page management department. But the content streams it generates can be plugged…

I had the same experience. Thanks for the summary. Need to read that the next time.
Post reply on HN