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)
| 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.""" |
nothing calls this directly
no test coverage detected