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

Method _get_optional_content

src/__init__.py:9932–9953  ·  view source on GitHub ↗
(self, oc: OptInt)

Source from the content-addressed store, hash-verified

9930 return mupdf.pdf_count_q_balance_outparams_fn(pdf, res, cont)
9931
9932 def _get_optional_content(self, oc: OptInt) -> OptStr:
9933 if oc is None or oc == 0:
9934 return None
9935 doc = self.parent
9936 check = doc.xref_object(oc, compressed=True)
9937 if not ("/Type/OCG" in check or "/Type/OCMD" in check):
9938 #log( 'raising "bad optional content"')
9939 raise ValueError("bad optional content: 'oc'")
9940 #log( 'Looking at self._get_resource_properties()')
9941 props = {}
9942 for p, x in self._get_resource_properties():
9943 props[x] = p
9944 if oc in props.keys():
9945 return props[oc]
9946 i = 0
9947 mc = f"MC{i:d}"
9948 while mc in props.values():
9949 i += 1
9950 mc = f"MC{i:d}"
9951 self._set_resource_property(mc, oc)
9952 #log( 'returning {mc=}')
9953 return mc
9954
9955 def _get_resource_properties(self):
9956 '''

Callers 7

insert_textMethod · 0.80
insert_textboxMethod · 0.80
finishMethod · 0.80
write_textMethod · 0.80
insert_textMethod · 0.80
insert_textboxMethod · 0.80
finishMethod · 0.80

Calls 3

xref_objectMethod · 0.80

Tested by

no test coverage detected