1#include <QtCore/QCoreApplication>
2#include <QtCore/QDebug>
3
4#include <iostream>
5
6#include <poppler-qt6.h>
7
8int main(int argc, char **argv)
9{
10 QCoreApplication a(argc, argv); // QApplication required!
11
12 if (!(argc == 2)) {
13 qWarning() << "usage: poppler-attachments filename";
14 exit(status: 1);
15 }
16
17 std::unique_ptr<Poppler::Document> doc = Poppler::Document::load(filePath: argv[1]);
18 if (!doc) {
19 qWarning() << "doc not loaded";
20 exit(status: 1);
21 }
22
23 if (doc->hasEmbeddedFiles()) {
24 std::cout << "Embedded files: " << std::endl;
25 foreach (Poppler::EmbeddedFile *file, doc->embeddedFiles()) {
26 std::cout << " " << qPrintable(file->name()) << std::endl;
27 std::cout << " desc:" << qPrintable(file->description()) << std::endl;
28 QByteArray data = file->data();
29 std::cout << " data: " << data.constData() << std::endl;
30 }
31
32 } else {
33 std::cout << "There are no embedded document at the top level" << std::endl;
34 }
35}
36

source code of poppler/qt6/tests/poppler-attachments.cpp