summaryrefslogtreecommitdiff
path: root/qt5/src/Mainpage.dox
blob: 279718f006a2a533511218b897551cefd8346c79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
@mainpage The Poppler Qt5 interface library

The %Poppler Qt5 interface library, libpoppler-qt5, is a library that
allows Qt5 programmers to easily load and render PDF files. The
%Poppler Qt5 interface library uses poppler internally to do its job,
but the Qt5 programmer will never have to worry about poppler
internals.


@section help Current Status

The %Poppler Qt5 interface library is in developement.

@section refimpl Example Programs

Examples programs can be found in the qt5/test directory. The %Poppler
Qt5 interface library is also used in the KDE's
document viewer <a href="http://okular.kde.org">Okular</a>. The source files
for Okular's PDF plugin (%Poppler-based) can be found on the git server
of the KDE project, under
<a
href="http://quickgit.kde.org/?p=okular.git&a=tree&f=generators/poppler">this
URL</a>.


@section req How to use the Poppler Qt5 interface library in three easy steps

Programmer who would like to use the %Poppler Qt5 interface library
simply need to add the following line to their C++ source files:

@code
#include <poppler-qt5.h>
@endcode

A PDF document can then be loaded as follows:
@code
QString filename;

Poppler::Document* document = Poppler::Document::load(filename);
if (!document || document->isLocked()) {

  // ... error message ....

  delete document;
  return;
}
@endcode

Pages can be rendered to QImages with the following commands:

@code
// Paranoid safety check
if (document == 0) {
  // ... error message ...
  return;
}

// Access page of the PDF file
Poppler::Page* pdfPage = document->page(pageNumber);  // Document starts at page 0
if (pdfPage == 0) {
  // ... error message ...
  return;
}

// Generate a QImage of the rendered page
QImage image = pdfPage->renderToImage(xres, yres, x, y, width, height);
if (image.isNull()) {
  // ... error message ...
  return;
}

// ... use image ...

// after the usage, the page must be deleted
delete pdfPage;
@endcode

Finally, don't forget to destroy the document:

@code
delete document;
@endcode
 */