Make use of the new text export function of the generator.

svn path=/trunk/playground/graphics/okular/; revision=556944
This commit is contained in:
Pino Toscano 2006-07-01 23:43:35 +00:00
parent b3a4b27956
commit f574dc37e6
2 changed files with 29 additions and 0 deletions

View file

@ -9,8 +9,10 @@
***************************************************************************/
// qt/kde includes
#include <qfile.h>
#include <qimage.h>
#include <qregexp.h>
#include <qtextstream.h>
#include <kauthorized.h>
#include <klocale.h>
#include <kpassworddialog.h>
@ -738,6 +740,29 @@ bool PDFGenerator::reparseConfig()
}
return false;
}
bool PDFGenerator::exportToText( const QString & fileName )
{
QFile f( fileName );
if ( !f.open( QIODevice::WriteOnly ) )
return false;
QTextStream ts( &f );
int num = m_document->pages();
for ( int i = 0; i < num; ++i )
{
docLock.lock();
Poppler::Page *pp = pdfdoc->page(i);
QString text = pp->text(QRect());
docLock.unlock();
ts << text;
delete pp;
}
f.close();
return true;
}
//END Generator inherited functions
inline void append (KPDFTextPage* ktp,

View file

@ -90,6 +90,10 @@ class PDFGenerator : public Generator
// [INHERITED] reparse configuration
bool reparseConfig();
// [INHERITED] text exporting
bool canExportToText() { return true; };
bool exportToText( const QString & fileName );
private slots:
// (async related) receive data from the generator thread
void threadFinished();