0xabu / pdfannots

Extracts and formats text annotations from a PDF file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rectangular (image) selection

rhaynes74 opened this issue · comments

Hi folks, thanks for your efforts with this tool. I was wondering if there are plans to add rectangular (image) selection to the tool?
The workflow that I imagine would be to select figures / tables / formulas using the often available rectangular selection, and then have those selection saved as images (.png, .jpg, etc...) and included as links in the markdown file.

Thanks for the suggestion. This sounds like a reasonable idea for a feature, but it's also not something I'm likely to work on soon as it's not directly relevant to my use-case... I'd be happy to review PRs.

I need that too

Badly needed here too :)
as well as #39 to import my okular collection to logseq

@0xabu would you by any chance have a recommended best way to extract an image rendering of a pdf given the precise bounding box location ? I am willing to try to implement this in the coming months.

@thiswillbeyourgithub not really, sorry. pdfminer already has the ability to extract images as bitmaps (see calls to render_image in https://github.com/pdfminer/pdfminer.six/blob/master/pdfminer/converter.py), but I'm not sure about capturing an arbitrary section of the page.

After looking a bit into it it appears that pdfminer is quite complicated to get into. I want to spend as little time on it as possible when i'll get to it so :

If I were to simply:

Would you find this a satisfactory PR or that that seem to hacky for you ? Of course with a bit of optimization to avoid converting useless pages etc.

Another possibility would be to open an issue in the pdfminer github and ask them their opinion.

I'm not excited about that approach, sorry -- it would add both pdf2image and PIL as dependencies (and from what I can see pdf2image itself just shells out to poppler utils). pdfminer has a gitter chat, maybe you could ask for advice there, or look around at some of the other apps that build on top of pdfminer for inspiration?

Thank you for the quick answer. Can you take a look at this comment in the github of pdfminer ? Would using py-pdf-parser be an acceptal PR by your standard or not ?

I looked at py-pdf-parser, if you look here it appears to be relying on wand (which is a python wrapper for imagemagick) to convert pdf pages to bitmaps. The rest of py-pdf-parser is irrelevant for us.

I think I would be ok with adding wand as an optional dependency, so if it is not present, then the image export functionality doen't work, but you don't need it to keep using pdfannots as today.

Alright. Thank you very much. I intend to do this in the summer probably.