diff --git a/generators/djvu/generator_djvu.cpp b/generators/djvu/generator_djvu.cpp index 2bea6be2b..eabf5019e 100644 --- a/generators/djvu/generator_djvu.cpp +++ b/generators/djvu/generator_djvu.cpp @@ -207,12 +207,10 @@ bool DjVuGenerator::print( KPrinter& printer ) tf.setSuffix( ".ps" ); if ( !tf.open() ) return false; - QString tempfilename = tf.fileName(); - tf.close(); - if ( m_djvu->exportAsPostScript( tempfilename, pageList ) ) + if ( m_djvu->exportAsPostScript( &tf, pageList ) ) { - return printer.printFiles( QStringList( tempfilename ), true ); + return printer.printFiles( QStringList( tf.fileName() ), true ); } return false; } diff --git a/generators/djvu/kdjvu.cpp b/generators/djvu/kdjvu.cpp index 4d0d5ccb9..f8f150f28 100644 --- a/generators/djvu/kdjvu.cpp +++ b/generators/djvu/kdjvu.cpp @@ -897,11 +897,25 @@ bool KDjVu::exportAsPostScript( const QString & fileName, const QList& page if ( !d->m_djvu_document || fileName.trimmed().isEmpty() || pageList.isEmpty() ) return false; - QByteArray fn = QFile::encodeName( fileName ); - FILE* f = fopen( fn.constData(), "w+" ); + QFile f( fileName ); + f.open( QIODevice::ReadWrite ); + bool ret = exportAsPostScript( &f, pageList ); + if ( ret ) + { + f.close(); + } + return ret; +} + +bool KDjVu::exportAsPostScript( QFile* file, const QList& pageList ) const +{ + if ( !d->m_djvu_document || !file || pageList.isEmpty() ) + return false; + + FILE* f = fdopen( file->handle(), "w+" ); if ( !f ) { - kDebug() << "KDjVu::exportAsPostScript(): error while opening the file"; + kDebug() << "error while getting the FILE*"; return false; } diff --git a/generators/djvu/kdjvu.h b/generators/djvu/kdjvu.h index 3564236c5..b6838cef7 100644 --- a/generators/djvu/kdjvu.h +++ b/generators/djvu/kdjvu.h @@ -20,6 +20,7 @@ #include class QDomDocument; +class QFile; /** * @brief Qt (KDE) encapsulation of the DjVuLibre @@ -258,6 +259,12 @@ class KDjVu : public QObject */ bool exportAsPostScript( const QString & fileName, const QList& pageList ) const; + /** + * Export the currently open document as PostScript file. + * \returns whether the exporting was successful + */ + bool exportAsPostScript( QFile* file, const QList& pageList ) const; + /** * Return the list of the text entities for the specified \p page, that matches the * specified \p granularity.