| 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-qt6.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 |
std::unique_ptr<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 |
std::unique_ptr<Poppler::Page> page = doc->page(index); |
| 60 |
page->renderToImage(); |
| 61 |
page->pageSize(); |
| 62 |
page->orientation(); |
| 63 |
std::cout << "."; |
| 64 |
std::cout.flush(); |
| 65 |
} |
| 66 |
std::cout << std::endl; |
| 67 |
} |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
std::cout << "Elapsed time: " << (t.elapsed() / 1000) << std::endl; |
| 72 |
} |