The Qt PDF module contains classes and functions for rendering PDF documents. The QPdfDocument class loads a PDF document and renders pages from it according to the options provided by the QPdfDocumentRenderOptions class. The 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 Viewer Example 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, and 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 Image, 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.
find_package() command to locate the needed module components in the
find_package(Qt6 REQUIRED COMPONENTS Pdf) target_link_libraries(mytarget Qt6::Pdf)
See also the Build with CMake overview.
To link against the module, add this line to your qmake project file:
QT += pdf
© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.