OCG / Deleting invisible OCGs #3567
-
Hello! I have a PDF file with only one page I got via another tool for PDF documents, and my PDF document has some OCGs. If I try to get the pixmap of the page, it is completely OK, but when I try to get an SVG image via Investigating the issue I`ve concluded that some of the clip-paths affect the appearance of the drawing that I see.
If I delete a certain clip-path in the defs section then I`ll get more visible content on the SVG image so I suppose the only reason that I get such a result is the SVG has some invisible data from some of the OCGs and since it does not being managed by the PDF I see it whether I suppose to see it or not. So my question is How to detect and delete invisible and unnecessary OCGs from my PDF document so I won`t see the difference between the SVG image and the pixmap that I got from the pymupdf Page object? It is important to notice, that the pymupdf Document object does not have any info about layers or OCGs.
Also, I used such a code
To get such info:
In conclusion, this document has some OCGs that are accessible only on the Page level. I want to preserve only visible OCGs to get the right appearance of the resulting SVG image and delete the rest. Can you give me some advice on how to do it? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Beta Was this translation helpful? Give feedback.
-
I think you detected a bug in MuPDF! for _,xref,_ in page.get_oc_items():
doc.update_object(xref, "<<>>") That's all. If you agree, I will turn this into a bug and forward the file to MuPDF's bug system. |
Beta Was this translation helpful? Give feedback.
I think you detected a bug in MuPDF!
The PDF indeed has no defined OCProperties. The existing OCGs which are referenced by the page actually must be ignored! But are not.
So I removed / disabled the OCGs and created the SVG again - and now the SVG image is equivalent to the Pixmap!
Here is the code sippet that did that. It simply takes each OCG and replaces its (anyway irrelevant) content by an empty dictionary:
That's all.
If you agree, I will turn this into a bug and forward the file to MuPDF's bug system.