summaryrefslogtreecommitdiff
path: root/qt4/tests/poppler-attachments.cpp
blob: 04f175579ddb037160edc8a813528d1a3d7b693f (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
#include <QtCore/QtCore>
#include <iostream>

#include <poppler-qt4.h>

int main( int argc, char **argv )
{
    QCoreApplication a( argc, argv );               // QApplication required!

    if (!( argc == 2 ))
    {
	qWarning() << "usage: poppler-attachments filename";
	exit(1);
    }
  
    Poppler::Document *doc = Poppler::Document::load(argv[1]);
    if (!doc)
    {
	qWarning() << "doc not loaded";
	exit(1);
    }

    if (doc->hasEmbeddedFiles()) {
	std::cout << "Embedded files: " << std::endl;
	foreach(Poppler::EmbeddedFile *file, doc->embeddedFiles()) {
	    std::cout << "    " << qPrintable(file->name()) << std::endl;
	    std::cout << "    desc:" << qPrintable(file->description()) << std::endl;
	    QByteArray data = file->data();
	    std::cout << "       data: " << data.constData() << std::endl;
	}
	
    } else {
	std::cout << "There are no embedded document at the top level" << std::endl;
    }
  
}