DisplayList#
DisplayList 是一个包含绘图命令(文本、图像等)的列表。其目的是双重的:
作为缓存机制,以减少页面解析。
作为多线程设置中的数据结构,其中一个线程解析页面,另一个线程渲染页面。此功能目前在 PyMuPDF 中不支持。
显示列表通过从页面中提取对象进行填充,通常通过执行 Page.get_displaylist()
。还存在一个独立的构造函数。
通过调用其方法之一:run()
、get_pixmap()
或 get_textpage()
,可以“重播”列表(一次或多次)。
方法 |
简短描述 |
---|---|
通过设备运行显示列表。 |
|
生成一个 pixmap。 |
|
生成文本页面。 |
|
显示列表的媒体框。 |
类 API
- class DisplayList#
-
- run(device, matrix, area)#
通过设备运行显示列表。设备将使用其“命令”填充显示列表(即文本提取或图像创建)。稍后,您可以多次使用该显示列表来“读取”页面,而无需从文档文件重新解析。
您通常会使用下面的专用运行方法之一——
get_pixmap()
或get_textpage()
。
- 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。
- get_textpage(flags)#
通过文本设备运行显示列表并返回一个文本页面。
- rect#
包含显示列表的媒体框。如果是通过
Page.get_displaylist()
创建的,则此值将等于页面的矩形。- Type:
DisplayList is a list containing drawing commands (text, images, etc.). The intent is two-fold:
as a caching-mechanism to reduce parsing of a page
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 a display list through a device. |
|
generate a pixmap |
|
generate a text page |
|
mediabox of the display list |
Class API