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

Method _extractText

src/__init__.py:16390–16409  ·  view source on GitHub ↗
(self, format_)

Source from the content-addressed store, hash-verified

16388 self.parent = None
16389
16390 def _extractText(self, format_):
16391 this_tpage = self.this
16392 res = mupdf.fz_new_buffer(1024)
16393 out = mupdf.FzOutput( res)
16394 # fixme: mupdfwrap.py thinks fz_output is not copyable, possibly
16395 # because there is no .refs member visible and no fz_keep_output() fn,
16396 # although there is an fz_drop_output(). So mupdf.fz_new_output_with_buffer()
16397 # doesn't convert the returned fz_output* into a mupdf.FzOutput.
16398 #out = mupdf.FzOutput(out)
16399 if format_ == 1:
16400 mupdf.fz_print_stext_page_as_html(out, this_tpage, 0)
16401 elif format_ == 3:
16402 mupdf.fz_print_stext_page_as_xml(out, this_tpage, 0)
16403 elif format_ == 4:
16404 mupdf.fz_print_stext_page_as_xhtml(out, this_tpage, 0)
16405 else:
16406 JM_print_stext_page_as_text(res, this_tpage)
16407 out.fz_close_output()
16408 text = JM_EscapeStrFromBuffer(res)
16409 return text
16410
16411 def _getNewBlockList(self, page_dict, raw):
16412 JM_make_textpage_dict(self.this, page_dict, raw)

Callers 4

extractHTMLMethod · 0.95
extractTextMethod · 0.95
extractXHTMLMethod · 0.95
extractXMLMethod · 0.95

Calls 2

JM_EscapeStrFromBufferFunction · 0.85

Tested by

no test coverage detected