DisplayList#

DisplayList 是一个包含绘图命令(文本、图像等)的列表。其目的是双重的:

  1. 作为缓存机制,以减少页面解析。

  2. 作为多线程设置中的数据结构,其中一个线程解析页面,另一个线程渲染页面。此功能目前在 PyMuPDF 中不支持。

显示列表通过从页面中提取对象进行填充,通常通过执行 Page.get_displaylist()。还存在一个独立的构造函数。

通过调用其方法之一:run()get_pixmap()get_textpage(),可以“重播”列表(一次或多次)。

方法

简短描述

run()

通过设备运行显示列表。

get_pixmap()

生成一个 pixmap。

get_textpage()

生成文本页面。

rect

显示列表的媒体框。

类 API

class DisplayList#
__init__(self, mediabox)#

创建一个新的显示列表。

参数:

mediabox (Rect) – 页面矩形。

返回类型:

DisplayList

run(device, matrix, area)#

通过设备运行显示列表。设备将使用其“命令”填充显示列表(即文本提取或图像创建)。稍后,您可以多次使用该显示列表来“读取”页面,而无需从文档文件重新解析。

您通常会使用下面的专用运行方法之一——get_pixmap()get_textpage()

参数:
  • device (设备) – 设备

  • matrix (Matrix) – 要应用于显示列表内容的转换矩阵。

  • area (Rect) – 仅在此区域内可见的部分将被视为当列表通过设备运行时。

get_pixmap(matrix=pymupdf.Identity, colorspace=pymupdf.csRGB, alpha=0, clip=None)#

通过绘图设备运行显示列表并返回一个 pixmap。

参数:
  • matrix (Matrix) – 要使用的矩阵。默认是单位矩阵。

  • colorspace (Colorspace) – 所需的颜色空间。默认是 RGB。

  • alpha (int) – 确定是否包含透明通道(0,默认)。

  • clip (irect_like) – 将渲染限制为此区域与 DisplayList.rect 的交集。

返回类型:

Pixmap

返回:

显示列表的 pixmap。

get_textpage(flags)#

通过文本设备运行显示列表并返回一个文本页面。

参数:

flags (int) – 控制哪些信息被解析为文本页面。PyMuPDF 中的默认值为 3 = TEXT_PRESERVE_LIGATURES | TEXT_PRESERVE_WHITESPACE,即: ligatures 传递,空格 传递 (不转换为空格),图像 不包含 。参见 字体属性

返回类型:

TextPage

返回:

显示列表的文本页面。

rect#

包含显示列表的媒体框。如果是通过 Page.get_displaylist() 创建的,则此值将等于页面的矩形。

Type:

Rect

DisplayList is a list containing drawing commands (text, images, etc.). The intent is two-fold:

  1. as a caching-mechanism to reduce parsing of a page

  2. as a data structure in multi-threading setups, where one thread parses the page and another one renders pages. This aspect is currently not supported by PyMuPDF.

A display list is populated with objects from a page, usually by executing Page.get_displaylist(). There also exists an independent constructor.

“Replay” the list (once or many times) by invoking one of its methods run(), get_pixmap() or get_textpage().

Method

Short Description

run()

Run a display list through a device.

get_pixmap()

generate a pixmap

get_textpage()

generate a text page

rect

mediabox of the display list

Class API


本软件按原样提供,不作任何明示或暗示担保。本软件根据许可分发,除非根据该许可条款明确授权,否则不得复制、修改或分发。请参阅 artifex.com 上的许可信息,或联系 Artifex Software Inc., 39 Mesa Street, Suite 108A, San Francisco CA 94129, United States 了解更多信息。