Comments (8)
Fixed in 1.24.5.
from pymupdf.
You must provide an example where this happens. Otherwise we cannot accept this bug report.
from pymupdf.
how about this
my method got wrong
def merge_pdfs(self, file_list: List[Union[Path, str]]):
if len(file_list) == 1:
self.merge_doc = fitz.open(file_list[0])
else:
self.merge_doc = fitz.open()
merged_toc = []
for file in tqdm(file_list, desc="merge", unit="file"):
pdf = fitz.open(file)
merged_toc.append((1, Path(file).stem.replace("\u3000", ""), len(self.merge_doc) + 1))
self.merge_doc.insert_file(pdf)
pdf.close()
self.merge_doc.set_toc(merged_toc, collapse=0)
self.merge_doc.save(self.out_pdf_file)
self.add_metadata()
self.set_file_view()
if self.pagenum:
self.add_pagnums()
if self.watermark:
self.add_watermark(self.watermark_text)
self.merge_doc.save(self.out_pdf_file)
error message, it stays in 1.24.4, but in 1.24.2 don't have these errors.
..\venv\lib\site-packages\pymupdf\__init__.py:87:exception_info: exception_info:
Traceback (most recent call last):
File "D:\JDBDocuments\Pycharm\table_name_cards\venv\lib\site-packages\pymupdf\utils.py", line 1444, in set_toc
txt += ol["dest"]
KeyError: 'dest'
..\venv\lib\site-packages\pymupdf\__init__.py:87:exception_info: exception_info:
Traceback (most recent call last):
File "D:\JDBDocuments\Pycharm\table_name_cards\venv\lib\site-packages\pymupdf\utils.py", line 1462, in set_toc
if ol["next"] > -1:
KeyError: 'next'
..\venv\lib\site-packages\pymupdf\__init__.py:87:exception_info: exception_info:
Traceback (most recent call last):
File "D:\JDBDocuments\Pycharm\table_name_cards\venv\lib\site-packages\pymupdf\utils.py", line 1469, in set_toc
if ol["parent"] > -1:
KeyError: 'parent'
..\venv\lib\site-packages\pymupdf\__init__.py:87:exception_info: exception_info:
Traceback (most recent call last):
File "D:\JDBDocuments\Pycharm\table_name_cards\venv\lib\site-packages\pymupdf\utils.py", line 1476, in set_toc
if ol["prev"] > -1:
KeyError: 'prev'
..\venv\lib\site-packages\pymupdf\__init__.py:87:exception_info: exception_info:
Traceback (most recent call last):
File "D:\JDBDocuments\Pycharm\table_name_cards\venv\lib\site-packages\pymupdf\utils.py", line 1483, in set_toc
txt += "/Title" + ol["title"]
KeyError: 'title'
Thank you guys for your hard work
from pymupdf.
Apologies - I should have looked into this myself!
from pymupdf.
Apologies - I should have looked into this myself!
I tried to fix this in your source code but failed. If it is not too much trouble to ask, can you explain why this happened?
from pymupdf.
I also encountered the same problem. It was so easy to reproduce the error by trying to bookmark a PDF file.
Here is a code that can reproduce this bug.
import fitz
from pathlib import Path
pdf = Path(r'test.pdf')
toc = [(1, 'level1', 1), (2, 'level2', 1)]
doc = fitz.open(pdf)
doc.set_toc(toc, collapse = 2)
from pymupdf.
I think this may be the same as #3479.
Internal exception diagnostics in utils.py were increased in 1.24.2.
The fix is simple enough. But i'm also looking at writing a test that checks that we don't generate such diagnostics in future.
from pymupdf.
I got the same error message when doing doc.set_toc(toc_list).
pymupdf version: 1.24.4
python version: 3.11.7
os: windows
I add key check in utils.py before next 5 variables assign ( I'm not sure if this is a good method.)
ol["dest"] (add if 'dest' in ol: ...)
ol["next"]
ol["parent"]
ol["prev"]
ol["title"]
from pymupdf.
Related Issues (20)
- page.get_pixmap() fails due to `fitz.mupdf.FzErrorLimit: code=5: too many nested graphics states` HOT 5
- No OCR support: TESSDATA_PREFIX not set HOT 1
- apply_redactions moves graphics HOT 1
- `Document.pagemode` or `Document.pagelayout` crashes for epub files HOT 10
- not last version reported HOT 2
- Why does PyMuPDF print checkmarks instead of 'X' for checkboxes. HOT 1
- Docker python:3.11.6-slim can't build with version 1.24.6 HOT 4
- The text information obtained by get_text() is partially missing HOT 2
- Build for linux/arm64 fails HOT 1
- flags of span is not right for Chinese text HOT 1
- Pdf file transform to image have a black block HOT 1
- Memory Retention with fitz.page.get_pixmap() HOT 8
- page.apply_redactions gives unwanted black rectangle HOT 3
- Allow creating custom drawing `Device` HOT 5
- Document.scrub() raises `RuntimeError: code=7: cannot find object in xref ...` HOT 4
- API documentation for the `open` function is not obvious to find. HOT 3
- Cannot replace fonts HOT 2
- bboxes of glyphs are all the same in a font HOT 5
- ImportError: libmupdf.so.24.4: cannot open shared object file: No such file or directory HOT 12
- When I want to compress PDF,I got an bigger PDF
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.