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.
Using a Qt module requires linking against the module library, either directly or through other dependencies. Several build tools have dedicated support for this, including CMake and qmake.
Use the find_package()
command to locate the needed module components in the Qt6
package:
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
As part of the free Business evaluation, we offer a free welcome call for companies, to talk about your requirements, and how the Felgo SDK & Services can help you. Just sign up and schedule your call.
Sign up now to start your free Business evaluation: