File indexing completed on 2025-02-23 04:26:31
0001 /* Copyright 2015 Robert Schroll 0002 * 0003 * This file is part of Beru and is distributed under the terms of 0004 * the GPL. See the file COPYING for full details. 0005 */ 0006 0007 #ifndef PDFREADER_H 0008 #define PDFREADER_H 0009 0010 #include <QObject> 0011 //#include <QDomDocument> 0012 #include <QVariant> 0013 #include <poppler/qt5/poppler-qt5.h> 0014 #include "../qhttpserver/qhttpresponse.h" 0015 0016 class PDFReader : public QObject 0017 { 0018 Q_OBJECT 0019 Q_PROPERTY(QString hash READ hash) 0020 Q_PROPERTY(QString title READ title) 0021 Q_PROPERTY(int width READ width WRITE setWidth) 0022 Q_PROPERTY(int height READ height WRITE setHeight) 0023 public: 0024 explicit PDFReader(QObject *parent = 0); 0025 QString hash(); 0026 QString title(); 0027 int width(); 0028 void setWidth(int value); 0029 int height(); 0030 void setHeight(int value); 0031 0032 Q_INVOKABLE bool load(const QString &filename); 0033 Q_INVOKABLE void serveBookData(QHttpResponse *response); 0034 Q_INVOKABLE void serveComponent(const QString &filename, QHttpResponse *response); 0035 Q_INVOKABLE QVariantMap getCoverInfo(int thumbsize, int fullsize); 0036 0037 Q: 0038 void contentsReady(QVariantList contents); 0039 0040 private: 0041 bool parse(); 0042 QVariantList getContents(); 0043 QVariantList parseContents(QDomElement el); 0044 void computeHash(const QString &filename); 0045 void readMetadata(); 0046 QImage renderPage(int pageNum, int maxWidth, int maxHeight); 0047 0048 Poppler::Document* pdf; 0049 QString _hash; 0050 QStringList spine; 0051 QVariantMap metadata; 0052 int _width; 0053 int _height; 0054 0055 }; 0056 0057 #endif // PDFREADER_H