Comments (2)
The problem here is that the document contains internal damages, message: mupdf: expected generation number (0 ? obj)
.
MuPDF has repaired and opened the document, but that does not necessarily mean all is roses.
Try to detect this via checking doc.is_repaired
, and if true, work with a cleaned document version:
>>> import fitz
>>> doc = fitz.open("Facture.n.91614287.pdf")
mupdf: expected generation number (0 ? obj)
>>> doc.is_repaired
True
>>> # aha! we therefore make a cleaned doc version:
>>> pdfbytes = doc.tobytes(garbage=4, deflate=True, clean=True)
>>> # reopen from the returned bytes object
>>> doc = fitz.open("pdf", pdfbytes)
>>> doc.is_repaired
False
>>> page = doc[0]
>>> blocks = page.get_text("blocks")
>>> blocks.sort(key=lambda b: (b[1], b[0]))
>>> # etc.
from pymupdf-utilities.
thanks a lot
from pymupdf-utilities.
Related Issues (20)
- Suggestion for Jupyter notebooks HOT 3
- ModuleNotFoundError: No module named 'ParseTab' HOT 2
- export-toc script outputs invalid csv when bookmark entry has newline character
- anonymize.py raises UnicodeDecodeError HOT 2
- libcrypt.so.2: cannot open shared object file: No such file or directory HOT 3
- multi_column.py does not identify multiple columns in some cases HOT 3
- How to use fitz to delete tables in PDF? Need help, Thanks. HOT 1
- document rescale after replacing fonts HOT 1
- fitzcli.py open file as in-memory stream & parameter for printing instead of writing to .txt HOT 1
- multi_column.py errors with latest version of pymupdf HOT 4
- Use a template for documenting the examples
- Make sure the examples are PEP8 compliant HOT 1
- Merge the demo scripts into the examples folder HOT 2
- Update links in Read the Docs HOT 3
- Merge the conversion scripts into the examples folder
- Merge the image-replacement scripts into the examples folder
- Merge the font-replacement scripts into the examples folder
- Merge the text-extraction scripts into the examples folder
- Merge the textbox-extraction scripts into the examples folder
- Define a folder structure for the examples
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pymupdf-utilities.