MCPcopy Index your code
hub / github.com/pymupdf/PyMuPDF / update_stream

Method update_stream

src/__init__.py:7791–7807  ·  view source on GitHub ↗

Replace xref stream part.

(self, xref=0, stream=None, new=1, compress=1)

Source from the content-addressed store, hash-verified

7789 JM_refresh_links( _as_pdf_page(page))
7790
7791 def update_stream(self, xref=0, stream=None, new=1, compress=1):
7792 """Replace xref stream part."""
7793 if self.is_closed or self.is_encrypted:
7794 raise ValueError("document closed or encrypted")
7795 pdf = _as_pdf_document(self)
7796 xreflen = mupdf.pdf_xref_len(pdf)
7797 if xref < 1 or xref > xreflen:
7798 raise ValueError( MSG_BAD_XREF)
7799 # get the object
7800 obj = mupdf.pdf_new_indirect(pdf, xref, 0)
7801 if not mupdf.pdf_is_dict(obj):
7802 raise ValueError( MSG_IS_NO_DICT)
7803 res = JM_BufferFromBytes(stream)
7804 if not res.m_internal:
7805 raise TypeError( MSG_BAD_BUFFER)
7806 JM_update_stream(pdf, obj, res, compress)
7807 pdf.dirty = 1
7808
7809 @property
7810 def version_count(self):

Callers 11

scrubMethod · 0.80
xref_copyMethod · 0.80
replace_imageMethod · 0.80
commitMethod · 0.80
page_rotation_resetFunction · 0.80
replace_imageFunction · 0.80
commitMethod · 0.80
scrubFunction · 0.80
xref_copyFunction · 0.80
test_2556Function · 0.80
test_wrapcontentsFunction · 0.80

Calls 3

_as_pdf_documentFunction · 0.85
JM_BufferFromBytesFunction · 0.85
JM_update_streamFunction · 0.85

Tested by 2

test_2556Function · 0.64
test_wrapcontentsFunction · 0.64