Bug 707824

Summary: Conversion to SVG respects invalid OCGs
Product: MuPDF Reporter: Jorj <jorj.x.mckie>
Component: mupdfAssignee: Tor Andersson <tor.andersson>
Status: IN_PROGRESS ---    
Severity: major CC: robin.watts
Priority: P2    
Version: unspecified   
Hardware: All   
OS: All   
Customer: Word Size: ---
Attachments: Minimized example.

Description Jorj 2024-06-12 10:58:16 UTC
In contrast to page rendering, SVG conversion does not make sure whether any OCGs are valid at all.

PyMuPDF Discussion item: https://github.com/pymupdf/PyMuPDF/discussions/3567
File link: https://github.com/user-attachments/files/15791552/dwe1_2.pdf

How to reproduce:

mutool draw -o test.svg dwe1_2.pdf

Compare to:

mutool draw -o test.png dwe1_2.pdf

Note:
The page refers to dozens of OCGs in its /Properties. But there exists no /OCProperties in the file - so all of the OCGs must be treated as non-existent, like it happens in rendering.
Comment 1 Robin Watts 2024-06-14 10:02:18 UTC
I have a fix in review:

https://cgit.ghostscript.com/cgi-bin/cgit.cgi/user/robin/mupdf.git/commit/?h=so&id=8a01ae1ca85902adae87fde06e58af9de301a02e

The issueis not the /OCProperties not existing, it's a bad interaction between layers and clips in the generated SVG file.
Comment 2 Robin Watts 2024-06-14 14:31:38 UTC
Tor isn't keen on my fix, because it can split layers into more groups that are strictly needed. We have therefore agreed to park my fix for a couple of weeks to see if he can find a formulation he likes better.
Comment 3 Tor Andersson 2024-06-28 16:51:10 UTC
Created attachment 25767 [details]
Minimized example.