Debian Codegraph @

qt5/tests/stress-poppler-qt5.cpp

raw
1 #include <QtCore/QDebug>
2 #include <QtCore/QDir>
3 #include <QtCore/QElapsedTimer>
4 #include <QtWidgets/QApplication>
5 #include <QtGui/QImage>
6
7 #include <iostream>
8
9 #include <poppler-qt5.h>
10
11 int main(int argc, char **argv)
12 {
13 QApplication a(argc, argv); // QApplication required!
14
15 Q_UNUSED(argc);
16 Q_UNUSED(argv);
17
18 QElapsedTimer t;
19 t.start();
20 QDir dbDir(QStringLiteral("./pdfdb"));
21 if (!dbDir.exists()) {
22 qWarning() << "Database directory does not exist";
23 }
24
25 QStringList excludeSubDirs;
26 excludeSubDirs << QStringLiteral("000048") << QStringLiteral("000607");
27
28 const QStringList dirs = dbDir.entryList(QStringList() << QStringLiteral("0000*"), QDir::Dirs);
29 Q_FOREACH (const QString &subdir, dirs) {
30 if (excludeSubDirs.contains(subdir)) {
31 // then skip it
32 } else {
33 QString path = QStringLiteral("./pdfdb/") + subdir + QStringLiteral("/data.pdf");
34 std::cout << "Doing " << path.toLatin1().data() << " :";
35 Poppler::Document *doc = Poppler::Document::load(path);
36 if (!doc) {
37 qWarning() << "doc not loaded";
38 } else {
39 auto pdfVersion = doc->getPdfVersion();
40 Q_UNUSED(pdfVersion);
41 doc->info(QStringLiteral("Title"));
42 doc->info(QStringLiteral("Subject"));
43 doc->info(QStringLiteral("Author"));
44 doc->info(QStringLiteral("Keywords"));
45 doc->info(QStringLiteral("Creator"));
46 doc->info(QStringLiteral("Producer"));
47 doc->date(QStringLiteral("CreationDate")).toString();
48 doc->date(QStringLiteral("ModDate")).toString();
49 doc->numPages();
50 doc->isLinearized();
51 doc->isEncrypted();
52 doc->okToPrint();
53 doc->okToCopy();
54 doc->okToChange();
55 doc->okToAddNotes();
56 doc->pageMode();
57
58 for (int index = 0; index < doc->numPages(); ++index) {
59 Poppler::Page *page = doc->page(index);
60 page->renderToImage();
61 page->pageSize();
62 page->orientation();
63 delete page;
64 std::cout << ".";
65 std::cout.flush();
66 }
67 std::cout << std::endl;
68 delete doc;
69 }
70 }
71 }
72
73 std::cout << "Elapsed time: " << (t.elapsed() / 1000) << std::endl;
74 }