Introduce support for PDFs
CONTRIBUTOR
#self-assign
2024-12-10T17:00:49Z
https://github.com/huggingface/datasets/issues/7318#issuecomment-2532294231
https://api.github.com/repos/huggingface/datasets/issues/7318
IC_kwDODunzps6W775X
https://api.github.com/repos/huggingface/datasets/issues/comments/2532294231/reactions
2024-12-10T17:00:49Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2532294231
https://avatars.githubusercontent.com/u/4812761?v=4
https://api.github.com/users/yabramuvdi/events{/privacy}
https://api.github.com/users/yabramuvdi/followers
https://api.github.com/users/yabramuvdi/following{/other_user}
https://api.github.com/users/yabramuvdi/gists{/gist_id}
https://github.com/yabramuvdi
yabramuvdi
MDQ6VXNlcjQ4MTI3NjE=
https://api.github.com/users/yabramuvdi/orgs
https://api.github.com/users/yabramuvdi/received_events
https://api.github.com/users/yabramuvdi/repos
https://api.github.com/users/yabramuvdi/starred{/owner}{/repo}
https://api.github.com/users/yabramuvdi/subscriptions
User
https://api.github.com/users/yabramuvdi
public
MEMBER
Awesome ! Let me know if you have any question or if I can help :)

cc @AndreaFrancis as well for viz
2024-12-10T17:30:45Z
https://github.com/huggingface/datasets/issues/7318#issuecomment-2532359692
https://api.github.com/repos/huggingface/datasets/issues/7318
IC_kwDODunzps6W8L4M
https://api.github.com/repos/huggingface/datasets/issues/comments/2532359692/reactions
2024-12-10T17:30:45Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2532359692
https://avatars.githubusercontent.com/u/42851186?v=4
https://api.github.com/users/lhoestq/events{/privacy}
https://api.github.com/users/lhoestq/followers
https://api.github.com/users/lhoestq/following{/other_user}
https://api.github.com/users/lhoestq/gists{/gist_id}
https://github.com/lhoestq
lhoestq
MDQ6VXNlcjQyODUxMTg2
https://api.github.com/users/lhoestq/orgs
https://api.github.com/users/lhoestq/received_events
https://api.github.com/users/lhoestq/repos
https://api.github.com/users/lhoestq/starred{/owner}{/repo}
https://api.github.com/users/lhoestq/subscriptions
User
https://api.github.com/users/lhoestq
public
MEMBER
Other candidates libraries for the Pdf type: PyMuPDF pypdf and pdfplumber

EDIT: Pymupdf looks like a good choice when it comes to maturity + performance + versatility BUT the license is maybe an issue, and pypdf, pypdfium2 or pdfplumber are good options imo
2024-12-10T18:08:00Z
https://github.com/huggingface/datasets/issues/7318#issuecomment-2532495039
https://api.github.com/repos/huggingface/datasets/issues/7318
IC_kwDODunzps6W8s6_
https://api.github.com/repos/huggingface/datasets/issues/comments/2532495039/reactions
2024-12-11T15:11:08Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2532495039
https://avatars.githubusercontent.com/u/42851186?v=4
https://api.github.com/users/lhoestq/events{/privacy}
https://api.github.com/users/lhoestq/followers
https://api.github.com/users/lhoestq/following{/other_user}
https://api.github.com/users/lhoestq/gists{/gist_id}
https://github.com/lhoestq
lhoestq
MDQ6VXNlcjQyODUxMTg2
https://api.github.com/users/lhoestq/orgs
https://api.github.com/users/lhoestq/received_events
https://api.github.com/users/lhoestq/repos
https://api.github.com/users/lhoestq/starred{/owner}{/repo}
https://api.github.com/users/lhoestq/subscriptions
User
https://api.github.com/users/lhoestq
public
CONTRIBUTOR
Related to https://github.com/huggingface/datasets/issues/7058
2024-12-11T16:34:43Z
https://github.com/huggingface/datasets/issues/7318#issuecomment-2536498453
https://api.github.com/repos/huggingface/datasets/issues/7318
IC_kwDODunzps6XL-UV
https://api.github.com/repos/huggingface/datasets/issues/comments/2536498453/reactions
2024-12-11T16:34:43Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2536498453
https://avatars.githubusercontent.com/u/5564745?v=4
https://api.github.com/users/AndreaFrancis/events{/privacy}
https://api.github.com/users/AndreaFrancis/followers
https://api.github.com/users/AndreaFrancis/following{/other_user}
https://api.github.com/users/AndreaFrancis/gists{/gist_id}
https://github.com/AndreaFrancis
AndreaFrancis
MDQ6VXNlcjU1NjQ3NDU=
https://api.github.com/users/AndreaFrancis/orgs
https://api.github.com/users/AndreaFrancis/received_events
https://api.github.com/users/AndreaFrancis/repos
https://api.github.com/users/AndreaFrancis/starred{/owner}{/repo}
https://api.github.com/users/AndreaFrancis/subscriptions
User
https://api.github.com/users/AndreaFrancis
public
CONTRIBUTOR
PyMuPDF is AGPL licensed, so we can't use it. I will move forward with [pdfplumber](https://github.com/jsvine/pdfplumber?tab=readme-ov-file#python-library).
2024-12-12T14:01:19Z
https://github.com/huggingface/datasets/issues/7318#issuecomment-2539039294
https://api.github.com/repos/huggingface/datasets/issues/7318
IC_kwDODunzps6XVqo-
https://api.github.com/repos/huggingface/datasets/issues/comments/2539039294/reactions
2024-12-12T14:01:19Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2539039294
https://avatars.githubusercontent.com/u/4812761?v=4
https://api.github.com/users/yabramuvdi/events{/privacy}
https://api.github.com/users/yabramuvdi/followers
https://api.github.com/users/yabramuvdi/following{/other_user}
https://api.github.com/users/yabramuvdi/gists{/gist_id}
https://github.com/yabramuvdi
yabramuvdi
MDQ6VXNlcjQ4MTI3NjE=
https://api.github.com/users/yabramuvdi/orgs
https://api.github.com/users/yabramuvdi/received_events
https://api.github.com/users/yabramuvdi/repos
https://api.github.com/users/yabramuvdi/starred{/owner}{/repo}
https://api.github.com/users/yabramuvdi/subscriptions
User
https://api.github.com/users/yabramuvdi
public
CONTRIBUTOR
Hi both! I have made a pull request with a first basic implementation of the Pdf feature. I followed closely what I saw on the Video and Image features. It is my first time contributing so any comments are very welcomed. I think it would be useful to outline together what additional things we can implement (e.g. enabling parsing of the pdf). Thanks :) 
2024-12-12T18:38:11Z
https://github.com/huggingface/datasets/issues/7318#issuecomment-2539750783
https://api.github.com/repos/huggingface/datasets/issues/7318
IC_kwDODunzps6XYYV_
https://api.github.com/repos/huggingface/datasets/issues/comments/2539750783/reactions
2024-12-12T18:38:11Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2539750783
https://avatars.githubusercontent.com/u/4812761?v=4
https://api.github.com/users/yabramuvdi/events{/privacy}
https://api.github.com/users/yabramuvdi/followers
https://api.github.com/users/yabramuvdi/following{/other_user}
https://api.github.com/users/yabramuvdi/gists{/gist_id}
https://github.com/yabramuvdi
yabramuvdi
MDQ6VXNlcjQ4MTI3NjE=
https://api.github.com/users/yabramuvdi/orgs
https://api.github.com/users/yabramuvdi/received_events
https://api.github.com/users/yabramuvdi/repos
https://api.github.com/users/yabramuvdi/starred{/owner}{/repo}
https://api.github.com/users/yabramuvdi/subscriptions
User
https://api.github.com/users/yabramuvdi
public
### Feature request

The idea (discussed in the Discord server with @lhoestq ) is to have a Pdf type like Image/Audio/Video. For example [Video](https://github.com/huggingface/datasets/blob/main/src/datasets/features/video.py) was recently added and contains how to decode a video file encoded in a dictionary like {"path": ..., "bytes": ...} as a VideoReader using decord. We want to do the same with pdf and get a [pypdfium2.PdfDocument](https://pypdfium2.readthedocs.io/en/stable/_modules/pypdfium2/_helpers/document.html#PdfDocument).

### Motivation

In many cases PDFs contain very valuable information beyond text (e.g. images, figures). Support for PDFs would help create datasets where all the information is preserved.

### Your contribution

I can start the implementation of the Pdf type :)