MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / get_oc

Method get_oc

src/__init__.py:4900–4915  ·  view source on GitHub ↗

Return optional content object xref for an image or form xobject. Args: xref: (int) xref number of an image or form xobject.

(doc: 'Document', xref: int)

Source from the content-addressed store, hash-verified

4898 return xref
4899
4900 def get_oc(doc: 'Document', xref: int) -> int:
4901 """Return optional content object xref for an image or form xobject.
4902
4903 Args:
4904 xref: (int) xref number of an image or form xobject.
4905 """
4906 if doc.is_closed or doc.is_encrypted:
4907 raise ValueError("document close or encrypted")
4908 t, name = doc.xref_get_key(xref, "Subtype")
4909 if t != "name" or name not in ("/Image", "/Form"):
4910 raise ValueError(f"bad object type at xref {xref}")
4911 t, oc = doc.xref_get_key(xref, "OC")
4912 if t != "xref":
4913 return 0
4914 rc = int(oc.replace("0 R", ""))
4915 return rc
4916
4917 def get_ocgs(self):
4918 """Show existing optional content groups."""

Callers

nothing calls this directly

Calls 1

xref_get_keyMethod · 0.80

Tested by

no test coverage detected