Skip to content
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 hides Path objects from macOS Preview/Quicklook/Safari #3748

Closed
mac5yver opened this issue Aug 2, 2024 · 9 comments
Closed
Labels
not a bug not a bug / user error / unable to reproduce

Comments

@mac5yver
Copy link

mac5yver commented Aug 2, 2024

Description of the bug

Path objects (paragraph rules, paragraph borders) in a PDF created by Adobe InDesign become hidden or invisible to macOS Preview, Safari, and Quicklook after applying redactions.

Preview shows all the paths of '1 source.pdf' correctly but after redaction ('3 apply redactions.pdf') none of these Path objects are visible in Preview (see 'preview.png'). The content structure of both documents appear to be the same (see 'compare content.png'), but something seems to have changed as a result of redaction. The Paths render correctly in Acrobat and Chrome on macOS.

How to reproduce the bug

I would expect that after applying redactions the Paths would continue to be visible in Preview/Quicklook but they are not.

import pymupdf
doc = pymupdf.open("1 source.pdf")
for page in doc:
    page.add_redact_annot([0, 792, 612, 600])
    page.apply_redactions()
doc.save("3 apply redactions.pdf")
doc.close()

1 source.pdf
2 redact rects.pdf
3 apply redactions.pdf

preview.png
preview

compare content.png
compare content

PyMuPDF version

1.24.9

Operating system

MacOS

Python version

3.12

@JorjMcKie
Copy link
Collaborator

Please consult the documentation of apply_redactions!
Since several versions, drawings are also removed when overlapping redactions rectangles.
In addition, text, images and drawings can be handled independently from each other in redactions applications.
To keep drawings use parameter graphics=pymupdf.PDF_REDACT_LINE_ART_NONE.

@JorjMcKie JorjMcKie added the not a bug not a bug / user error / unable to reproduce label Aug 3, 2024
@beeing
Copy link

beeing commented Aug 3, 2024

Hi, I have similar issue. Just to clarify that the "text: 1" for apply_redactions is working properly, however the text was somehow masked or so. Refer to the image from Preview app which I can still select the text and copy it out.

The only thing is the text on the left section seems to be transparent.

Untitled

The expectation is the text is fully visible as this is not part of the redacted regions.

Hope this helps. Thanks.

@mac5yver
Copy link
Author

mac5yver commented Aug 5, 2024

Please consult the documentation of apply_redactions! Since several versions, drawings are also removed when overlapping redactions rectangles. In addition, text, images and drawings can be handled independently from each other in redactions applications. To keep drawings use parameter graphics=pymupdf.PDF_REDACT_LINE_ART_NONE.

@JorjMcKie Thank you for the quick reply. I have tried the various graphics and image handling options in the apply redactions documentation, but the issue remains. Please note none of the redact rectangles overlap the path drawings that appear to be removed. (see original post attachment 2 redact rects.pdf)

Our use-case requires that we do remove overlapping text, images, and drawings.

The issue remains in these new example files created with this code:
1 source.pdf
3 PDF_REDACT_LINE_ART_NONE.pdf

import pymupdf

doc = pymupdf.open("1 source.pdf")

for page in doc:
    page.add_redact_annot([0, 792, 612, 600])
    page.apply_redactions(graphics=pymupdf.PDF_REDACT_LINE_ART_NONE)

doc.save("3 PDF_REDACT_LINE_ART_NONE.pdf")
doc.close()

redact_rects and apply_redactions

@JorjMcKie
Copy link
Collaborator

@beeing please open a separate issue - your situation is not the same.

@JorjMcKie
Copy link
Collaborator

@mac5yver - thanks for your reply. I have opened the redacted (result) file with all the PDF viewers I usually employ - and it does look perfectly ok with all of them: evince (Linux), Adobe Acrobat, PDF XChange Viwer, Nitro, Foxit reader, MuPDF.
So there is no can-do for me - especially considering that Adobe Acrobat is among them.

@mac5yver
Copy link
Author

mac5yver commented Aug 5, 2024

@JorjMcKie Thanks for your time. We regularly employ macOS Preview as a PDF viewer, but do also have access to Acrobat. We'll just have to find a way to ensure the redacted PDFs are never opened or printed from Preview or Safari, since the apparent result is incorrect.

@beeing
Copy link

beeing commented Aug 5, 2024

@beeing please open a separate issue - your situation is not the same.

Sure, I've created in #3751. Thank you!

@yuhuang-cst
Copy link

yuhuang-cst commented Aug 16, 2024

@mac5yver - thanks for your reply. I have opened the redacted (result) file with all the PDF viewers I usually employ - and it does look perfectly ok with all of them: evince (Linux), Adobe Acrobat, PDF XChange Viwer, Nitro, Foxit reader, MuPDF. So there is no can-do for me - especially considering that Adobe Acrobat is among them.

I encountered a similar issue with the newly generated PDF files after using the apply_redactions function. PDF readers that display the file correctly include Adobe Acrobat Reader, Chrome, and WPS. Those that display it incorrectly include Mac Preview, Safari, UPDF, and PDF Expert. If you open the file 3 apply redactions.pdf provided in this issue with the aforementioned PDF readers, you can verify this. Please take this issue seriously as this is likely caused by some wrong changes made by apply_redactions, and it affects more than just the Mac Preview PDF reader.

@jamie-lemon
Copy link
Collaborator

@yuhuang-cst Agree that this "PDF doesn't display correctly in Preview after redactions take place" is a serious issue - we will hopefully get to the bottom of it on #3751

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not a bug not a bug / user error / unable to reproduce
Projects
None yet
Development

No branches or pull requests

5 participants