Bug 707824 - Conversion to SVG respects invalid OCGs
Summary: Conversion to SVG respects invalid OCGs
Status: IN_PROGRESS
Alias: None
Product: MuPDF
Classification: Unclassified
Component: mupdf (show other bugs)
Version: unspecified
Hardware: All All
: P2 major
Assignee: Tor Andersson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-12 10:58 UTC by Jorj
Modified: 2024-06-28 16:51 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
Minimized example. (10.96 KB, application/pdf)
2024-06-28 16:51 UTC, Tor Andersson
Details

Note You need to log in before you can comment on or make changes to this bug.
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.