def to_pixmap(self,
                  rotation=0,
                  resolution=72,
                  width=None, height=None, fit=False,
                  antialiasing_level=8,
                  ):

        transform, bounding_box = self._transform_bounding_box(rotation,
                                                               resolution,
                                                               width, height, fit)

        width, height = mupdf.rect_width_height(bounding_box)
        np_array = np.zeros((height, width, 4), dtype=np.uint8)
        color_space = mupdf.device_rgb(self._context)
        use_alpha = True
        pixmap = mupdf.new_pixmap_with_bbox_and_data(self._context,
                                                     color_space,
                                                     bounding_box,
                                                     mupdf.NULL,
                                                     use_alpha,
                                                     mupdf.np_array_uint8_ptr(np_array))
        mupdf.clear_pixmap_with_value(self._context, pixmap, 255) # 0xff

        device = mupdf.new_draw_device(self._context, mupdf.NULL, pixmap)
        mupdf.set_aa_level(self._context, antialiasing_level)
        mupdf.run_page(self._context, self._c_page, device, transform, mupdf.NULL)
        mupdf.close_device(self._context, device)
        mupdf.drop_device(self._context, device)
        mupdf.drop_pixmap(self._context, pixmap)

        return np_array
    def _make_display_list(self, no_cache=False):

        # Fixme: use it

        self._page_list = mupdf.new_display_list(self._context, mupdf.NULL)
        device = mupdf.new_list_device(self._context, page_list)
        if no_cache:
            mupdf.enable_device_hints(self._context, device, mupdf.FZ_NO_CACHE)
        mupdf.run_page_contents(self._context, page, device, mupdf.identity, mupdf.NULL)
        mupdf.close_device(self._context, device)
        mupdf.drop_device(self._context, device)
    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)