1 // Copyright 2011 The Emscripten Authors. All rights reserved. 2 // Emscripten is available under two separate licenses, the MIT license and the 3 // University of Illinois/NCSA Open Source License. Both these licenses can be 4 // found in the LICENSE file. 5 6 #include <QtCore/QCoreApplication> 7 #include <QtCore/QDebug> 8 9 #include <iostream> 10 11 #include <poppler-qt4.h> 12 main(int argc,char ** argv)13int main( int argc, char **argv ) 14 { 15 QCoreApplication a( argc, argv ); // QApplication required! 16 17 if (!( argc == 2 )) 18 { 19 qWarning() << "usage: poppler-texts filename"; 20 exit(1); 21 } 22 23 Poppler::Document *doc = Poppler::Document::load(argv[1]); 24 if (!doc) 25 { 26 qWarning() << "doc not loaded"; 27 exit(1); 28 } 29 30 for ( int i = 0; i < doc->numPages(); i++ ) 31 { 32 int j = 0; 33 std::cout << "*** Page " << i << std::endl; 34 std::cout << std::flush; 35 36 Poppler::Page *page = doc->page(i); 37 const QByteArray utf8str = page->text( QRectF(), Poppler::Page::RawOrderLayout ).toUtf8(); 38 std::cout << std::flush; 39 for ( j = 0; j < utf8str.size(); j++ ) 40 std::cout << utf8str[j]; 41 std::cout << std::endl; 42 delete page; 43 } 44 delete doc; 45 } 46