def text_direct(self): # Fixme: versus text structured_text_options = mupdf.StructuredTextOptions() c_buffer = mupdf.new_buffer_from_page(self._context, self._c_page, structured_text_options) py_buffer = mupdf.string_from_buffer(self._context, c_buffer) mupdf.drop_buffer(self._context, c_buffer) return mupdf.decode_utf8(py_buffer)
def _to_text(self, scale=1, rotation=0): """ Return a :obj:`.TextPage` instance. """ mediabox = self._bounding_box() transform = self._make_transform(scale, rotation) structured_text_options = mupdf.StructuredTextOptions() structured_text_page = mupdf.new_stext_page(self._context, mediabox) device = mupdf.new_stext_device(self._context, structured_text_page, structured_text_options) mupdf.run_page(self._context, self._c_page, device, transform, mupdf.NULL) # run_page(self._context, page_list, device) mupdf.close_device(self._context, device) mupdf.drop_device(self._context, device) # structured_text_page_ = mupdf.new_stext_page_from_page(self._context, self._c_page, structured_text_options) return TextPage(self, structured_text_page)