| 1 |
/** |
| 2 |
@mainpage The Poppler Qt6 interface library |
| 3 |
|
| 4 |
The %Poppler Qt6 interface library, libpoppler-qt6, is a library that |
| 5 |
allows Qt6 programmers to easily load and render PDF files. The |
| 6 |
%Poppler Qt6 interface library uses poppler internally to do its job, |
| 7 |
but the Qt6 programmer will never have to worry about poppler |
| 8 |
internals. |
| 9 |
|
| 10 |
|
| 11 |
@section help Current Status |
| 12 |
|
| 13 |
The %Poppler Qt6 interface library is quite stable and working. |
| 14 |
|
| 15 |
@section refimpl Example Programs |
| 16 |
|
| 17 |
Examples programs can be found in the qt6/test directory. The %Poppler |
| 18 |
Qt6 interface library is also used in the KDE's |
| 19 |
document viewer <a href="http://okular.kde.org">Okular</a>. The source files |
| 20 |
for Okular's PDF plugin (%Poppler-based) can be found on the git server |
| 21 |
of the KDE project, under |
| 22 |
<a |
| 23 |
href="http://quickgit.kde.org/?p=okular.git&a=tree&f=generators/poppler">this |
| 24 |
URL</a>. |
| 25 |
|
| 26 |
|
| 27 |
@section req How to use the Poppler Qt6 interface library in three easy steps |
| 28 |
|
| 29 |
Programmer who would like to use the %Poppler Qt6 interface library |
| 30 |
simply need to add the following line to their C++ source files: |
| 31 |
|
| 32 |
@code |
| 33 |
#include <poppler-qt6.h> |
| 34 |
@endcode |
| 35 |
|
| 36 |
|
| 37 |
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: |
| 38 |
|
| 39 |
- NimbusMonoPS-Regular.otf |
| 40 |
- NimbusMonoPS-Bold.otf |
| 41 |
- NimbusMonoPS-BoldItalic.otf |
| 42 |
- NimbusMonoPS-Italic.otf |
| 43 |
- NimbusSans-Regular.otf |
| 44 |
- NimbusSans-Bold.otf |
| 45 |
- NimbusSans-BoldItalic.otf |
| 46 |
- NimbusSans-Italic.otf |
| 47 |
- StandardSymbolsPS.otf |
| 48 |
- NimbusRoman-Bold.otf |
| 49 |
- imbusRoman-BoldItalic.otf |
| 50 |
- NimbusRoman-Italic.otf |
| 51 |
- NimbusRoman-Regular.otf |
| 52 |
- D050000L.otf |
| 53 |
|
| 54 |
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. |
| 55 |
|
| 56 |
A PDF document can then be loaded as follows: |
| 57 |
@code |
| 58 |
QString filename; |
| 59 |
|
| 60 |
std::unique_ptr<Poppler::Document> document = Poppler::Document::load(filename); |
| 61 |
if (!document || document->isLocked()) { |
| 62 |
|
| 63 |
// ... error message .... |
| 64 |
|
| 65 |
return; |
| 66 |
} |
| 67 |
@endcode |
| 68 |
|
| 69 |
Pages can be rendered to QImages with the following commands: |
| 70 |
|
| 71 |
@code |
| 72 |
// Paranoid safety check |
| 73 |
if (!document) { |
| 74 |
// ... error message ... |
| 75 |
return; |
| 76 |
} |
| 77 |
|
| 78 |
// Access page of the PDF file |
| 79 |
std::unique_ptr<Poppler::Page> pdfPage = document->page(pageNumber); // Document starts at page 0 |
| 80 |
if (!pdfPage) { |
| 81 |
// ... error message ... |
| 82 |
return; |
| 83 |
} |
| 84 |
|
| 85 |
// Generate a QImage of the rendered page |
| 86 |
QImage image = pdfPage->renderToImage(xres, yres, x, y, width, height); |
| 87 |
if (image.isNull()) { |
| 88 |
// ... error message ... |
| 89 |
return; |
| 90 |
} |
| 91 |
|
| 92 |
// ... use image ... |
| 93 |
|
| 94 |
// after the usage, the page must be deleted |
| 95 |
@endcode |
| 96 |
|
| 97 |
Finally, don't forget to destroy the document: |
| 98 |
|
| 99 |
@code |
| 100 |
delete document; |
| 101 |
@endcode |
| 102 |
*/ |
| 103 |
|