-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
apply_redactions moves some unredacted text #3278
Comments
Sorry - I was wrong: got confused by the first two
|
In this case, the PDF resulting from a PDF-to-PDF conversion will not cause a problem. So you can use this approach is you need an immediate circumvention: import fitz
source_doc = fitz.open("source.pdf")
pdfdata = source_doc.convert_to_pdf() # make a PDF/PDF conversion
# this will issue some error messages: obviously, some fonts contain errors.
source_doc = fitz.open("pdf", pdfdata) # re-open source after conversion
dst_doc = fitz.open()
dst_doc.insert_pdf(source_doc, 0, 0)
redaction_coords = [
(507.3806485, 35.06467372292002, 552.9736259804001, 24.838430185399943),
(212.5271666879999, 137.43544772292012, 258.12014416840003, 127.20920418540004),
(212.527166688, 129.4908031440001, 258.1201441684001, 139.2412260440001),
]
page = dst_doc.load_page(0)
for coords in redaction_coords:
if fitz.Rect(coords).is_empty:
print(f"normalizing empty rect {coords=}")
coords = tuple(fitz.Rect(coords).normalize())
redaction = page.add_redact_annot(
coords,
text=" ",
fill=(0.5, 0.5, 0.5), # grey
)
page.draw_rect(coords, color=(1, 0, 0))
page._apply_redactions(0, 0)
dst_doc.save("result.pdf")
dst_doc.close() |
Issue number in MuPDF's issue system: https://bugs.ghostscript.com/show_bug.cgi?id=707673. |
@JorjMcKie UPDATE: I don't think |
|
What happens if the conversion fails? |
An exception is raised. There also is the risk of incomplete / distorted output. |
@JorjMcKie do you need our customer details to fill in on the MuPDF issue so it gets the corresponding priority? |
Yes, please provide it if available. |
Receive the customer id - thank you! |
Fixed in 1.24.1. |
Description of the bug
Before:
After:
source.pdf
result_annotated.pdf
Notes:
Preview.app
to (re-) print the PDF with "scale to fit" turned on.How to reproduce the bug
PyMuPDF version
1.23.26
Operating system
MacOS
Python version
3.11
The text was updated successfully, but these errors were encountered: