Get xref object source as a string.
(self, xref, compressed=0, ascii=0)
| 8019 | return xreflen |
| 8020 | |
| 8021 | def xref_object(self, xref, compressed=0, ascii=0): |
| 8022 | """Get xref object source as a string.""" |
| 8023 | if self.is_closed: |
| 8024 | raise ValueError("document closed") |
| 8025 | if g_use_extra: |
| 8026 | ret = extra.xref_object( self.this, xref, compressed, ascii) |
| 8027 | return ret |
| 8028 | pdf = _as_pdf_document(self) |
| 8029 | xreflen = mupdf.pdf_xref_len(pdf) |
| 8030 | if not _INRANGE(xref, 1, xreflen-1) and xref != -1: |
| 8031 | raise ValueError( MSG_BAD_XREF) |
| 8032 | if xref > 0: |
| 8033 | obj = mupdf.pdf_load_object(pdf, xref) |
| 8034 | else: |
| 8035 | obj = mupdf.pdf_trailer(pdf) |
| 8036 | res = JM_object_to_buffer(mupdf.pdf_resolve_indirect(obj), compressed, ascii) |
| 8037 | text = JM_EscapeStrFromBuffer(res) |
| 8038 | return text |
| 8039 | |
| 8040 | def xref_set_key(self, xref, key, value): |
| 8041 | """Set the value of a PDF dictionary key.""" |