void PDFDisplay::display() { if (doc) { Poppler::Page *page = doc->getPage(currentPage); if (page) { delete pixmap; page->renderToPixmap(&pixmap, -1, -1, -1, -1); delete page; update(); } } else { printf("doc not loaded\n"); } }
int main( int argc, char **argv ) { QApplication a( argc, argv ); // QApplication required! if ( argc < 2 || (argc == 3 && strcmp(argv[2], "-extract") != 0) || argc > 3) { // use argument as file name printf("usage: test-poppler-qt filename [-extract]\n"); exit(1); } Poppler::Document *doc = Poppler::Document::load(argv[1]); if (!doc) { printf("doc not loaded\n"); exit(1); } if (argc == 2) { PDFDisplay test( doc ); // create picture display a.setMainWidget( &test); // set main widget test.setCaption("Poppler-Qt Test"); test.show(); // show it return a.exec(); // start event loop } else { Poppler::Page *page = doc->getPage(0); QLabel *l = new QLabel(page->getText(Poppler::Rectangle()), 0); l->show(); a.setMainWidget(l); // set main widget delete page; delete doc; return a.exec(); } }