Qt PDF

Qt PDF 模块包含用于渲染 PDF 文档的类和函数。 QPdfDocument class loads a PDF document and renders pages from it according to the options provided by the QPdfDocumentRenderOptions 类。 QPdfPageRenderer class manages a queue that collects all render requests. The QPdfPageNavigator class handles the navigation through a PDF document. The QPdfSearchModel class searches for a string and holds the search results. The QPdfBookmarkModel class holds the table of contents, if present. The QPdfLinkModel holds information about hyperlinks on a page. The QPdfView widget is a complete PDF viewer, and the PDF 查看器 Widget 范例 shows how to use it.

For Qt Quick applications, three kinds of full-featured viewer components are provided. PdfMultiPageView should be your first choice for the most common user experience: flicking through the pages in the entire document. PdfScrollablePageView shows one page at a time, with scrolling; and PdfPageView shows one full page at a time, without scrolling.

The full-featured viewer components are composed of lower-level QML components that can be used separately if you need to write a more customized PDF viewing application: PdfDocument , PdfPageImage , PdfPageNavigator , PdfSelection , PdfSearchModel , PdfLinkModel ,和 PdfBookmarkModel .

If you only need to render page images, without features such as text selection, search and navigation, this module includes a QImageIOHandler plugin that treats PDF as a scalable image format , similar to SVG . You can simply use 图像 , and set the currentFrame property to the page index that you wish to display. If the PDF file does not render its own background, the image has a transparent background.

使用模块

使用 Qt 模块要求直接或透过其它依赖链接到模块库。一些构建工具为此有贡献支持,包括 CMake and qmake .

构建采用 CMake

使用 find_package() 命令去定位所需模块组件,在 Qt6 包:

find_package(Qt6 REQUIRED COMPONENTS Pdf)
target_link_libraries(mytarget Qt6::Pdf)
					

另请参阅 构建采用 CMake 概述。

采用 qmake 构建

要链接到模块,添加此行到 qmake 工程文件:

QT += pdf
					

范例

API 参考

文章和指南

  • {Qt PDF Platform Notes} {Platform Notes}

许可和归属

Qt PDF 在商业许可下是可用的来自 Qt 公司 。此外,它是可用的根据 GNU LGPL (次一般公共许可) 第 3 版 ,或 GNU GPL (一般公共许可) 第 2 版 。见 Qt PDF 许可 进一步了解此模块的有关细节。