pikepdf: pikepdf._qpdf.PdfError on a specific PDF file with pikepdf >= 4.5.0
Hi, I have a bug with a specific PDF (which I can’t publish unfortunately).
The error is the following:
Traceback (most recent call last):
File "/tests/test_pikepdf.py", line 10, in test_pikepdf
pdf.save("/tmp/toto.pdf")
File "/usr/local/lib/python3.8/site-packages/pikepdf/_methods.py", line 774, in save
self._save(
pikepdf._qpdf.PdfError: operation for dictionary attempted on object of type null: returning null for attempted key retrieval
It happens with this python code, on the save statement:
import pikepdf
from pathlib import Path
fpath = Path("tests/fixtures/scanned_rotation.pdf")
pdf = pikepdf.Pdf.open(fpath)
pdf.save("/tmp/toto.pdf")
This is my Dockerfile to reproduce the problem:
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8
RUN apt-get update -q -y && apt-get upgrade -q -y
RUN python -m pip install --upgrade pip
RUN pip install --no-cache-dir install pikepdf
COPY app /app
COPY tests /tests
WORKDIR /app
It worked until pikepdf version 4.4.1 but from 4.5.0 to current version (5.0.1) it raises this pikepdf._qpdf.PdfError exception.
Thank you for your help and support
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 17 (9 by maintainers)
Commits related to this issue
- handle null object in setDecodeParms fix fo https://github.com/pikepdf/pikepdf/issues/317 — committed to chantzish/pikepdf by chantzish 2 years ago
- Fix error on writing PDFs containing JBIG2 images with null DecodeParms Fixes pikepdf._qpdf.PdfError on a specific PDF file with pikepdf >= 4.5.0 #317 Closes #339 Thanks to @chantzish for investiga... — committed to pikepdf/pikepdf by jbarlow83 2 years ago
Thank you very much version 5.1.3 fixes the bug!
I was able to confirm the responsible commit is https://github.com/pikepdf/pikepdf/commit/63274fc534a356508b232f921af9475a06dad451 created pull request.
@sondrelg You need to install qpdf and its headers to be able to build pikepdf from source. pikepdf does not attempt to download/build qpdf on its own. See the documentation.
This might not be of much help, but the change in question should be contained here: https://github.com/pikepdf/pikepdf/compare/377891f..e3ac85a. There isn’t too many changes to go through.
I was hoping to install from specific commits until finding the PR responsible, but building with
pip install git+https://github.com/pikepdf/pikepdf.git@377891f0ebaf86c6ba221c2b25e3e07dc9fe1296fails. Any tips on how to make it pass?It fails with:
Is
PointerHolder.hhnot checked into source control?