mirror of
https://invent.kde.org/graphics/okular
synced 2024-09-19 16:01:41 +00:00
Make use of the new text export function of the generator.
svn path=/trunk/playground/graphics/okular/; revision=556944
This commit is contained in:
parent
b3a4b27956
commit
f574dc37e6
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue