pdf2docx icon indicating copy to clipboard operation
pdf2docx copied to clipboard

AttributeError: 'Rect' object has no attribute 'get_area'

Open HaoSun1 opened this issue 2 months ago • 3 comments

Description of the bug

AttributeError: 'Rect' object has no attribute 'get_area'

ltow.py FVShard.pdf

How to reproduce the bug

Run the following code C:\Users\hao_s\Downloads>py ltow.py
[INFO] Start to convert C:\Users\hao_s\Downloads\FVShard.pdf [INFO] ←[1;36m[1/4] Opening document...←[0m [INFO] ←[1;36m[2/4] Analyzing document...←[0m Traceback (most recent call last): File "C:\Users\hao_s\Downloads\ltow.py", line 7, in cv.convert(docx_file) File "C:\Users\hao_s\AppData\Local\Programs\Python\Python39\lib\site-packages\pdf2docx\converter.py", line 349, in convert self.parse(start, end, pages, **settings).make_docx(docx_filename, **settings) File "C:\Users\hao_s\AppData\Local\Programs\Python\Python39\lib\site-packages\pdf2docx\converter.py", line 128, in parse return self.load_pages(start, end, pages)
File "C:\Users\hao_s\AppData\Local\Programs\Python\Python39\lib\site-packages\pdf2docx\converter.py", line 169, in parse_document self._pages.parse(self.fitz_doc, **kwargs) File "C:\Users\hao_s\AppData\Local\Programs\Python\Python39\lib\site-packages\pdf2docx\page\Pages.py", line 37, in parse raw_page.restore(**settings) File "C:\Users\hao_s\AppData\Local\Programs\Python\Python39\lib\site-packages\pdf2docx\common\share.py", line 240, in inner objects = func(*args, **kwargs) File "C:\Users\hao_s\AppData\Local\Programs\Python\Python39\lib\site-packages\pdf2docx\page\RawPage.py", line 67, in restore raw_dict = self.extract_raw_dict(**settings) File "C:\Users\hao_s\AppData\Local\Programs\Python\Python39\lib\site-packages\pdf2docx\page\RawPageFitz.py", line 36, in extract_raw_dict shapes, images = self._preprocess_shapes(**settings) File "C:\Users\hao_s\AppData\Local\Programs\Python\Python39\lib\site-packages\pdf2docx\page\RawPageFitz.py", line 123, in _preprocess_shapes paths = self._init_paths(**settings) File "C:\Users\hao_s\AppData\Local\Programs\Python\Python39\lib\site-packages\pdf2docx\common\share.py", line 240, in inner objects = func(*args, **kwargs) File "C:\Users\hao_s\AppData\Local\Programs\Python\Python39\lib\site-packages\pdf2docx\page\RawPageFitz.py", line 136, in _init_paths return Paths(parent=self).restore(raw_paths) File "C:\Users\hao_s\AppData\Local\Programs\Python\Python39\lib\site-packages\pdf2docx\shape\Paths.py", line 27, in restore path = Path(raw) File "C:\Users\hao_s\AppData\Local\Programs\Python\Python39\lib\site-packages\pdf2docx\shape\Path.py", line 258, in init if rect.get_area()==0: rect += (-w, -w, w, w)


C:\Users\hao_s\Downloads>


### pdf2docx version

0.5.8

### Operating system

Windows

### Python version

3.9

HaoSun1 avatar Oct 26 '25 06:10 HaoSun1

I have the same problem.

Micraow avatar Oct 27 '25 14:10 Micraow

It seems an issue of pymupdf: https://github.com/pymupdf/pymupdf/issues/4742

pip install pymupdf==1.26.4 resolved this issue for me.

pipme avatar Nov 01 '25 11:11 pipme

I have the same problem. To avoid installing it in a project that does not require this package, could you update it in the next version of pdf2docx? Thank you in advance!

AlexandreJunod avatar Nov 21 '25 10:11 AlexandreJunod