blob: da7970d521f3af08ff02b10eef6dd04bb230b0dc [file] [log] [blame]
@mainpage The Poppler Qt6 interface library
The %Poppler Qt6 interface library, libpoppler-qt6, is a library that
allows Qt6 programmers to easily load and render PDF files. The
%Poppler Qt6 interface library uses poppler internally to do its job,
but the Qt6 programmer will never have to worry about poppler
@section help Current Status
The %Poppler Qt6 interface library is quite stable and working.
@section refimpl Example Programs
Examples programs can be found in the qt6/test directory. The %Poppler
Qt6 interface library is also used in the KDE's
document viewer <a href="">Okular</a>. The source files
for Okular's PDF plugin (%Poppler-based) can be found on the git server
of the KDE project, under
@section req How to use the Poppler Qt6 interface library in three easy steps
Programmer who would like to use the %Poppler Qt6 interface library
simply need to add the following line to their C++ source files:
#include <poppler-qt6.h>
For using the Qt6 interface on Android, there is an additional step - you must place the following font files in the assets/share/fonts directory of the Android APK:
- NimbusMonoPS-Regular.otf
- NimbusMonoPS-Bold.otf
- NimbusMonoPS-BoldItalic.otf
- NimbusMonoPS-Italic.otf
- NimbusSans-Regular.otf
- NimbusSans-Bold.otf
- NimbusSans-BoldItalic.otf
- NimbusSans-Italic.otf
- StandardSymbolsPS.otf
- NimbusRoman-Bold.otf
- imbusRoman-BoldItalic.otf
- NimbusRoman-Italic.otf
- NimbusRoman-Regular.otf
- D050000L.otf
These are used as substitute fonts for the base-14 fonts, and this step is required in order to reliably display documents with unembedded fonts. You can easily find these font files included within GhostScript.
A PDF document can then be loaded as follows:
QString filename;
Poppler::Document* document = Poppler::Document::load(filename);
if (!document || document->isLocked()) {
// ... error message ....
delete document;
Pages can be rendered to QImages with the following commands:
// Paranoid safety check
if (document == 0) {
// ... error message ...
// Access page of the PDF file
Poppler::Page* pdfPage = document->page(pageNumber); // Document starts at page 0
if (pdfPage == 0) {
// ... error message ...
// Generate a QImage of the rendered page
QImage image = pdfPage->renderToImage(xres, yres, x, y, width, height);
if (image.isNull()) {
// ... error message ...
// ... use image ...
// after the usage, the page must be deleted
delete pdfPage;
Finally, don't forget to destroy the document:
delete document;