Repository navigation
Call to Page.apply_redactions doesn't complete for widget annotation #1287
Description
Describe the bug (mandatory)
Page.apply_redactions() doesn't succeed or fail for the linked document; a SIGKILL is required to stop the process. I have a small set of documents that contain widget annotations which all have this same issue.
To Reproduce (mandatory)
Redact annotation positioning is not important to reproduce; the error happens when Page.apply_redactions() is called on a document containing a widget annotation.
- Download the original form here.
- Run below
import fitz
filename = './standard-form-180.pdf'
doc = fitz.Document(filename=filename)
for page in doc:
x0, y0 = (150, 120)
x1, y1 = (300, 170)
rect = fitz.Rect(x0, y0, x1, y1)
page.add_redact_annot(rect,
text='text',
fontname="helv",
fontsize=12,
align=1,
text_color=(1, 1, 1),
fill=(0, 0, 0))
page.apply_redactions()
doc.save('./out.pdf')Expected behavior (optional)
The call to C code should return a result; Page.apply_redactions() should raise an exception about the unsupported content encountered or process successfully with redact annotations included.
Screenshots (optional)
When you comment out the page.apply_redactions() and run, the cross out boxes are placed correctly, and it makes sense why this works.

Your configuration (mandatory)
- Operating system:
debian 10 - Python version:
3.9.1 - PyMuPDF version:
v1.18.19, although it happens in earlier versions too. This isn't new to the latest stable release.
Additional context (optional)
Creating a new PDF with ghostscript fixes the issue
Creating a new PDF with ghostscript removes the problematic content structurally (annotations), preserves the annotations' appearance on the page, and redacts successfully.
Widget annotations made with LaTeX work with Page.apply_redactions()
I think the issue is related to the widget annotations, but the issue doesn't happen for all widget annotations. For example, compile this LaTeX document with pdflatex and run with the code above.
\documentclass{article}
\usepackage{hyperref}
\begin{document}
% Interactive Form
\begin{Form}
\begin{tabular}{l}
\TextField{TextField:} \\\\
\CheckBox[width=1em]{CheckBox:} \\\\
\end{tabular}
\end{Form}
\end{document}So it isn't specifically the widget annotations; it possibly relates to the structure or content within the widget annotation. There seems to be a different issue where the interactive form shows through the redact annotation including the contained text, but that's something unrelated to this ticket.

Activity
[-]Page.apply_redactions doesn't return for content in document[/-][+]call to Page.apply_redactions doesn't complete for widget annotation[/+][-]call to Page.apply_redactions doesn't complete for widget annotation[/-][+]Call to Page.apply_redactions doesn't complete for widget annotation[/+]JorjMcKie commentedon Sep 24, 2021
This seems to be an long-known upstream bug. It works on my local Windows system, where I have backported the respective MuPDF fix - and it works there.
I currently cannot try it on Linux.
JorjMcKie commentedon Sep 24, 2021
Confirming: the same PyMuPDF version on Linux as on Windows does not work.
I am transferring this issue to the same pile of upstream bugs as your previous one.