ITADN

d9ce5947 breaks whitespaces between words

#3973OpenJulienPalard 创建于 14 天前
workflow-text-extractionwhitespace
J
JulienPalardcommented
Hi! I'm parsing my bank PDFs using extract_text for https://pypi.org/project/boursobank/ (I don't work here, I'm just a client automating stuff for myself and sharing my code). I had not updated pypdf since january: I'm very sorry for the latency in reporting the bug. I noticed since d9ce5947 that many spaces are missing between words: Before I was getting : `Relevé différé Carte 1234` now I'm getting `Relevé différéCarte1234` for example. ## Environment ```bash $ python -m platform Linux-7.1.3+deb14-amd64-x86_64-with-glibc2.42 $ python -c "import pypdf;print(pypdf._debug_versions)" pypdf==6.5.0, crypt_provider=('cryptography', '47.0.0'), PIL=12.3.0 ``` ## Code + PDF ```python from pypdf import PdfReader print( PdfReader("demo.pdf") .pages[0] .extract_text(extraction_mode="layout", orientations=(0,)) ) ``` [demo.pdf](https://github.com/user-attachments/files/31115316/demo.pdf) Reproducer: ``` git checkout d9ce594772717fdcfcd505d0309843461579bbf7^ python demo.py demo.pdf # read "A réception d'un extrait de compte" somewhere, see that all words are clearly separated git checkout d9ce594772717fdcfcd505d0309843461579bbf7 python demo.py demo.pdf # Read "Aréceptiond'un extraitde compte" instead, see that most words are glued together ``` To redact some values in the PDF without altering it much I used: ``` qpdf --stream-data=uncompress demo.pdf uncompressed.pdf emacs uncompress.pdf # to edit personal info out of the PDF in fundamental mode, could use sed, whatever qpdf --stream-data=compress uncompressed.pdf demo.pdf ```
9 条评论