/*! @file @id $Id$ */ // 1 2 3 4 5 6 7 8 // 45678901234567890123456789012345678901234567890123456789012345678901234567890 #ifndef __PLUGINFACTORY_HXX__ #define __PLUGINFACTORY_HXX__ #include #include #include #include #ifndef LOG #define LOG qDebug()<<__PRETTY_FUNCTION__ #endif #define foreach(A, B) \ auto foreach_loopvar_##A(B); \ for (auto A(foreach_loopvar_##A.begin()); A!=foreach_loopvar_##A.end(); ++A) class PluginFactory: public QWebPluginFactory { public: PluginFactory(QObject* p=0): QWebPluginFactory(p) { LOG; Plugin plugin; plugin.name = "Show PDF-Document"; plugin.description = "Plugin for PDF documents"; MimeType mime; mime.fileExtensions<<"pdf"; mime.name = "application/pdf"; mime.description = "PDF-Document"; plugin.mimeTypes<isLocked()); // output some meta-data int major = 0, minor = 0; doc->getPdfVersion( &major, &minor ); qDebug() << " PDF Version: " << qPrintable(QString::fromLatin1("%1.%2").arg(major).arg(minor)); qDebug() << " Title: " << doc->info("Title"); qDebug() << " Subject: " << doc->info("Subject"); qDebug() << " Author: " << doc->info("Author"); qDebug() << " Key words: " << doc->info("Keywords"); qDebug() << " Creator: " << doc->info("Creator"); qDebug() << " Producer: " << doc->info("Producer"); qDebug() << " Date created: " << doc->date("CreationDate").toString(); qDebug() << " Date modified: " << doc->date("ModDate").toString(); qDebug() << "Number of pages: " << doc->numPages(); qDebug() << " Linearised: " << doc->isLinearized(); qDebug() << " Encrypted: " << doc->isEncrypted(); qDebug() << " OK to print: " << doc->okToPrint(); qDebug() << " OK to copy: " << doc->okToCopy(); qDebug() << " OK to change: " << doc->okToChange(); qDebug() << "OK to add notes: " << doc->okToAddNotes(); qDebug() << " Page mode: " << doc->pageMode(); qDebug() << " Metadata: " << doc->metadata(); QStringList fontNameList; foreach(font, doc->fonts()) fontNameList += font->name(); qDebug() << " Fonts: " << fontNameList.join( ", " ); if ( doc->hasEmbeddedFiles() ) { qDebug() << "Embedded files:"; foreach(file, doc->embeddedFiles()) { qDebug() << " " << (*file)->name(); } qDebug(); } else { qDebug() << "No embedded files"; } if (doc->numPages() <= 0) { delete doc; qDebug() << "Doc has no pages"; return 0; } { std::auto_ptr page(doc->page(0)); qDebug() << "Page 1 size: " << page->pageSize().width()/72 << "inches x " << page->pageSize().height()/72 << "inches"; } bool useArthur(false); PDFDisplay* test(new PDFDisplay(doc, useArthur)); test->setWindowTitle("Poppler-Qt4 Test"); test->setShowTextRects(false); test->display(); test->show(); // QMainWindow* main(new QMainWindow); // main->setCentralWidget(test); // main->show(); return test; } return 0; } virtual QList plugins() const { LOG; return _plugins; } virtual void refreshPlugins() { LOG; } private: QList _plugins; }; #endif