├── .gitignore ├── PulasJs ├── example │ └── full.html ├── gulpfile.js └── pulas.js ├── PulasQt ├── Pulas.ico ├── Pulas.pro ├── Pulas.qrc ├── Pulas.rc ├── client.cpp ├── client.h ├── clientmanager.cpp ├── clientmanager.h ├── constant.h ├── images │ └── icon.png ├── main.cpp ├── maindialog.cpp ├── maindialog.h ├── maindialog.ui ├── pdf.cpp ├── pdf.h ├── printer.cpp └── printer.h ├── README.md └── external_libs └── poppler ├── include └── poppler │ └── qt5 │ ├── poppler-annotation.h │ ├── poppler-export.h │ ├── poppler-form.h │ ├── poppler-link.h │ ├── poppler-media.h │ ├── poppler-optcontent.h │ ├── poppler-page-transition.h │ └── poppler-qt5.h └── lib ├── libpoppler-qt5.dll └── libpoppler.dll /.gitignore: -------------------------------------------------------------------------------- 1 | PulasJs/node_modules/ 2 | PulasQt/Pulas.pro.* 3 | build-Pulas* 4 | -------------------------------------------------------------------------------- /PulasJs/example/full.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Pulas Full Example 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |
13 |
14 |
Status Connection to Pulas app
15 |
16 | Not Connected - Make sure the Pulas Qt App is running 17 |
18 |
19 |
20 |
Setting Printer
21 |
22 |
23 |
24 | Default Printer 25 |
26 |
27 |

-

28 |
29 |
30 |
31 |
32 | Select Printer 33 |
34 |
35 | 37 |
38 |
39 |
40 |
41 | Setting 42 |
43 |
44 | 45 |
46 |
47 | 48 |
49 |
50 |
51 |
52 |
53 |
54 |
Print
55 |
56 | html / raw command 57 | 58 |
59 |
60 | 61 |
62 |
63 | 64 |
65 |
66 | 67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
Print PDF File
75 |
76 | 77 |
78 |
79 | 80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 | 194 | 195 | -------------------------------------------------------------------------------- /PulasJs/gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var uglify = require('gulp-uglify'); 3 | 4 | gulp.task('build', function() { 5 | gulp.src('pulas.js') 6 | .pipe(uglify()) 7 | .pipe(gulp.dest('./dist/')) 8 | }); -------------------------------------------------------------------------------- /PulasJs/pulas.js: -------------------------------------------------------------------------------- 1 | 2 | const MSG_UNKNOWN = 0, MSG_LIST_PRINT = 1, MSG_SELECT_PRINT = 2, MSG_GET_DEFAULT_PRINT = 3, 3 | MSG_GET_CURRENT_PRINT = 4, MSG_SETTING_PRINT = 5, MSG_PRINT = 6, MSG_GET_SUPPORTED_RESOLUTION = 7, 4 | MSG_PRINT_PDF_FILE = 8; 5 | 6 | window.Pulas = function() { 7 | this.port = 1963; 8 | this.host = 'localhost'; 9 | this.available = false; 10 | this._callback = {}; 11 | this._queue = []; 12 | this._processing = false; 13 | this._connectionCallback = null; 14 | } 15 | 16 | Pulas.prototype = { 17 | isAvailable: function() { 18 | return this.available; 19 | }, 20 | connect: function(callback) { 21 | this.ws = new WebSocket('ws://' + this.host + ':' + this.port); 22 | this.ws.onopen = this._onopen.bind(this); 23 | this.ws.onclose = this._onclose.bind(this); 24 | this.ws.onmessage = this._onmessage.bind(this); 25 | if(typeof callback != 'undefined') 26 | this._connectionCallback = callback; 27 | }, 28 | _onopen: function() { 29 | this.available = true; 30 | this._shiftQueue(); 31 | if(this._connectionCallback != null && typeof this._connectionCallback == 'function') 32 | this._connectionCallback('opened'); 33 | }, 34 | _onclose: function() { 35 | this.available = false; 36 | if(this._connectionCallback != null && typeof this._connectionCallback == 'function') 37 | this._connectionCallback('closed'); 38 | }, 39 | _onmessage: function(msg) { 40 | var d = JSON.parse(msg.data); 41 | if(d.token in this._callback) { 42 | if(typeof this._callback[d.token] == 'function') { 43 | this._callback[d.token](d); 44 | } 45 | delete this._callback[d.token]; 46 | } 47 | this._processing = false; 48 | this._shiftQueue(); 49 | }, 50 | _shiftQueue: function() { 51 | if(this._queue.length > 0) { 52 | var obj = this._queue.shift(); 53 | this._send(obj.data, obj.callback); 54 | } 55 | }, 56 | _send: function(data, callback) { 57 | if(this.ws.readyState == 0 || this._processing) { 58 | this._queue.push({data: data, callback: callback}); 59 | return; 60 | } else if(this.ws.readyState == 2 || this.ws.readyState == 3) { 61 | return; 62 | } 63 | var token = (new Date()).getTime(); 64 | data.token = token; 65 | this._processing = true; 66 | this.ws.send(JSON.stringify(data)); 67 | if(typeof callback == 'function') { 68 | this._callback[token] = callback; 69 | } 70 | }, 71 | getPrinterList: function(callback) { 72 | this._send({type: MSG_LIST_PRINT}, callback); 73 | }, 74 | selectPrint: function(printName, callback) { 75 | this._send({type: MSG_SELECT_PRINT, print: printName}, callback); 76 | }, 77 | getDefaultPrinter: function(callback) { 78 | this._send({type: MSG_GET_DEFAULT_PRINT}, callback); 79 | }, 80 | getCurrentPrinter: function(callback) { 81 | this._send({type: MSG_GET_CURRENT_PRINT}, callback); 82 | }, 83 | getSupportedResolution: function(callback) { 84 | this._send({type: MSG_GET_SUPPORTED_RESOLUTION}, callback); 85 | }, 86 | /* 87 | * available setting object : 88 | * papersize: A4, A5, Letter 89 | * margin: {top, bottom, left, right} 90 | * unit: mm, inch 91 | * orientation: portrait, landscape 92 | */ 93 | settingPrinter: function(setting, callback) { 94 | this._send({type: MSG_SETTING_PRINT, setting: setting}, callback); 95 | }, 96 | printHtml: function(html, callback) { 97 | this._send({type: MSG_PRINT, data: {data: html}}, callback); 98 | }, 99 | printHtmlToPdf: function(html, callback) { 100 | this._send({type: MSG_PRINT, data: {data: html, printoutput: "pdf"}}, callback); 101 | }, 102 | printHtmlToPdfAndDownload: function(html) { 103 | var that = this; 104 | this._send({type: MSG_PRINT, data: {data: html, printoutput: "pdf"}}, 105 | function(data) { that._downloadPdf(data.data); }); 106 | }, 107 | printRaw: function(data, callback) { 108 | this._send({type: MSG_PRINT, data: {data: data, printtype: "escp"}}, callback); 109 | }, 110 | _downloadPdf: function(data) { 111 | window.open('data:application/pdf;base64,' + data, '_blank'); 112 | }, 113 | printPdfFile: function(data, config, callback) { 114 | var _config = { 115 | size: 'actualsize', 116 | halign: 'center', 117 | valign: 'middle' 118 | }; 119 | var _c = config || _config; 120 | _c['data'] = data; 121 | this._send({type: MSG_PRINT_PDF_FILE, data: _c}, callback); 122 | } 123 | } -------------------------------------------------------------------------------- /PulasQt/Pulas.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qzind/pulas/65f54bb78b067daf219c691ecf8129277961d1f9/PulasQt/Pulas.ico -------------------------------------------------------------------------------- /PulasQt/Pulas.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2016-06-23T14:10:03 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui websockets network printsupport webkitwidgets 8 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 9 | 10 | TARGET = Pulas 11 | TEMPLATE = app 12 | 13 | SOURCES += main.cpp\ 14 | maindialog.cpp \ 15 | clientmanager.cpp \ 16 | client.cpp \ 17 | printer.cpp \ 18 | pdf.cpp 19 | 20 | HEADERS += maindialog.h \ 21 | constant.h \ 22 | clientmanager.h \ 23 | client.h \ 24 | printer.h \ 25 | pdf.h 26 | 27 | FORMS += maindialog.ui 28 | 29 | win32:RC_FILE = Pulas.rc 30 | RESOURCES += Pulas.qrc 31 | 32 | LIBS += -lKernel32 -lwinspool 33 | 34 | win32: LIBS += -L$$PWD/../external_libs/poppler/lib/ -llibpoppler-qt5 35 | 36 | INCLUDEPATH += $$PWD/../external_libs/poppler/include 37 | DEPENDPATH += $$PWD/../external_libs/poppler/include 38 | -------------------------------------------------------------------------------- /PulasQt/Pulas.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/icon.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /PulasQt/Pulas.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "Pulas.ico" -------------------------------------------------------------------------------- /PulasQt/client.cpp: -------------------------------------------------------------------------------- 1 | #include "client.h" 2 | #include "constant.h" 3 | #include "printer.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | Client::Client(QWebSocket *sock, QObject *parent) : 11 | QObject(parent), 12 | mSocket(sock), 13 | mPrinter(new Printer(this)) 14 | { 15 | connect(mSocket, SIGNAL(disconnected()), SLOT(disconnected())); 16 | connect(mSocket, SIGNAL(textMessageReceived(QString)), SLOT(textMessageRecieved(QString))); 17 | connect(mSocket, SIGNAL(binaryMessageReceived(QByteArray)), SLOT(binaryMessageRecieved(QByteArray))); 18 | } 19 | 20 | void Client::shutdown() 21 | { 22 | mSocket->close(); 23 | emit aboutToClose(); 24 | deleteLater(); 25 | } 26 | 27 | void Client::answer(int type, const QVariant &data, double token) 28 | { 29 | QVariantMap m; 30 | m["type"] = QVariant(type); 31 | m["data"] = data; 32 | m["token"] = QVariant(token); 33 | mSocket->sendTextMessage(QJsonDocument::fromVariant(QVariant(m)).toJson(QJsonDocument::Compact)); 34 | } 35 | 36 | void Client::disconnected() 37 | { 38 | shutdown(); 39 | } 40 | 41 | void Client::textMessageRecieved(const QString &msg) 42 | { 43 | //message will always be json 44 | QJsonParseError parseError; 45 | QJsonDocument doc = QJsonDocument::fromJson(msg.toUtf8(), &parseError); 46 | if(parseError.error != QJsonParseError::NoError) 47 | return; 48 | 49 | const QVariantMap json = doc.object().toVariantMap(); 50 | int type = json.value("type", QVariant(MSG_TYPE::MSG_UNKNOWN)).toInt(); 51 | double token = json.value("token", QVariant(0.0f)).toDouble(); 52 | QVariant v; 53 | switch(type) { 54 | case MSG_TYPE::MSG_LIST_PRINT : 55 | { 56 | v = mPrinter->getListPrinter(); 57 | } break; 58 | case MSG_TYPE::MSG_GET_DEFAULT_PRINT: 59 | { 60 | v = mPrinter->getDefaultPrinterName(); 61 | } break; 62 | case MSG_TYPE::MSG_SELECT_PRINT: 63 | { 64 | v = mPrinter->setPrinter(json.value("print", mPrinter->getDefaultPrinterName()).toString()); 65 | } break; 66 | case MSG_TYPE::MSG_GET_CURRENT_PRINT: 67 | { 68 | v = mPrinter->getCurrentPrinter(); 69 | } break; 70 | case MSG_TYPE::MSG_SETTING_PRINT: 71 | { 72 | v = mPrinter->settingPrinter(json.value("setting", QVariant())); 73 | } break; 74 | case MSG_TYPE::MSG_PRINT: 75 | { 76 | v = mPrinter->print(json.value("data", QVariant())); 77 | } break; 78 | case MSG_TYPE::MSG_GET_SUPPORTED_RESOLUTION: 79 | { 80 | v = mPrinter->getSupportedResolution(); 81 | } break; 82 | case MSG_TYPE::MSG_PRINT_PDF_FILE: 83 | { 84 | v = mPrinter->printPdf(json.value("data")); 85 | } break; 86 | } 87 | answer(type, v, token); 88 | } 89 | 90 | void Client::binaryMessageRecieved(const QByteArray &msg) 91 | { 92 | Q_UNUSED(msg); 93 | } 94 | 95 | -------------------------------------------------------------------------------- /PulasQt/client.h: -------------------------------------------------------------------------------- 1 | #ifndef CLIENT_H 2 | #define CLIENT_H 3 | 4 | #include 5 | 6 | class QWebSocket; 7 | class Printer; 8 | 9 | class Client : public QObject 10 | { 11 | Q_OBJECT 12 | public: 13 | Client(QWebSocket *sock, QObject *parent = 0); 14 | void shutdown(); 15 | 16 | private: 17 | QWebSocket *mSocket; 18 | Printer *mPrinter; 19 | 20 | void answer(int type, const QVariant &data, double token); 21 | 22 | signals: 23 | void aboutToClose(); 24 | 25 | private slots: 26 | void disconnected(); 27 | void textMessageRecieved(const QString &msg); 28 | void binaryMessageRecieved(const QByteArray &msg); 29 | }; 30 | 31 | #endif // CLIENT_H 32 | -------------------------------------------------------------------------------- /PulasQt/clientmanager.cpp: -------------------------------------------------------------------------------- 1 | #include "clientmanager.h" 2 | #include "client.h" 3 | 4 | #include 5 | #include 6 | 7 | ClientManager::ClientManager(QObject *parent) : QObject(parent) 8 | { 9 | } 10 | 11 | void ClientManager::addNewClient(QWebSocket *sock) 12 | { 13 | Client *c = new Client(sock, this); 14 | mClientList.push_back(c); 15 | connect(c, SIGNAL(aboutToClose()), SLOT(clientClosed())); 16 | } 17 | 18 | void ClientManager::shutdown() 19 | { 20 | foreach (Client *c, mClientList) { 21 | c->shutdown(); 22 | } 23 | } 24 | 25 | void ClientManager::clientClosed() 26 | { 27 | Client *c = static_cast(QObject::sender()); 28 | mClientList.removeOne(c); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /PulasQt/clientmanager.h: -------------------------------------------------------------------------------- 1 | #ifndef CLIENTMANAGER_H 2 | #define CLIENTMANAGER_H 3 | 4 | #include 5 | #include 6 | 7 | class QWebSocket; 8 | class Client; 9 | 10 | class ClientManager : public QObject 11 | { 12 | Q_OBJECT 13 | public: 14 | ClientManager(QObject *parent = 0); 15 | void addNewClient(QWebSocket *sock); 16 | void shutdown(); 17 | 18 | private: 19 | QList mClientList; 20 | 21 | private slots: 22 | void clientClosed(); 23 | }; 24 | 25 | #endif // CLIENTMANAGER_H 26 | -------------------------------------------------------------------------------- /PulasQt/constant.h: -------------------------------------------------------------------------------- 1 | #ifndef CONSTANT 2 | #define CONSTANT 3 | 4 | namespace SERVER { 5 | const quint16 port = 1963; 6 | } 7 | 8 | namespace MSG_TYPE { 9 | enum MSG_TYPE { 10 | MSG_UNKNOWN = 0, 11 | MSG_LIST_PRINT, 12 | MSG_SELECT_PRINT, 13 | MSG_GET_DEFAULT_PRINT, 14 | MSG_GET_CURRENT_PRINT, 15 | MSG_SETTING_PRINT, 16 | MSG_PRINT, 17 | MSG_GET_SUPPORTED_RESOLUTION, 18 | MSG_PRINT_PDF_FILE 19 | }; 20 | } 21 | 22 | const int TIMEOUT = 5 * 60 * 1000; 23 | 24 | #endif // CONSTANT 25 | 26 | -------------------------------------------------------------------------------- /PulasQt/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qzind/pulas/65f54bb78b067daf219c691ecf8129277961d1f9/PulasQt/images/icon.png -------------------------------------------------------------------------------- /PulasQt/main.cpp: -------------------------------------------------------------------------------- 1 | #include "maindialog.h" 2 | #include 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | bool isHide = false; 9 | a.setApplicationName("Pulas"); 10 | a.setApplicationDisplayName("Pulas"); 11 | a.setApplicationVersion("0.2"); 12 | 13 | //check the argument for hiding 14 | if(argc == 2) { 15 | QString arg(argv[1]); 16 | if(!arg.compare("hide") || !arg.compare("--hide")) 17 | isHide = true; 18 | } 19 | 20 | MainDialog w; 21 | if(!isHide) 22 | w.show(); 23 | else 24 | w.showTray(); 25 | 26 | return a.exec(); 27 | } 28 | -------------------------------------------------------------------------------- /PulasQt/maindialog.cpp: -------------------------------------------------------------------------------- 1 | #include "maindialog.h" 2 | #include "ui_maindialog.h" 3 | #include "constant.h" 4 | #include "clientmanager.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "pdf.h" 14 | #include 15 | #include 16 | #include 17 | 18 | MainDialog::MainDialog(QWidget *parent) : 19 | QDialog(parent), 20 | ui(new Ui::MainDialog), 21 | mServer(new QWebSocketServer("Pulas Server", QWebSocketServer::NonSecureMode, this)), 22 | mClientManager(new ClientManager(this)), 23 | mTray(new QSystemTrayIcon(this)) 24 | { 25 | ui->setupUi(this); 26 | connect(mServer, SIGNAL(newConnection()), SLOT(newConnection())); 27 | //directly run the server 28 | if (runServer()) 29 | ui->labelInfo->setText("is running ..."); 30 | else 31 | ui->labelInfo->setText("is failed to run!!!"); 32 | 33 | setWindowTitle("Pulas - Javascript direct printing"); 34 | 35 | connect(ui->pushAboutQt, SIGNAL(clicked(bool)), SLOT(aboutQtClicked())); 36 | connect(ui->pushQuit, SIGNAL(clicked(bool)), SLOT(quitClicked())); 37 | 38 | mTray->setIcon(QIcon(":/images/icon.png")); 39 | connect(mTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(trayActivated(QSystemTrayIcon::ActivationReason))); 40 | QPixmap px(":/images/icon.png"); 41 | ui->image->setPixmap(px.scaledToHeight(150)); 42 | ui->labelVersion->setText("Version " + QApplication::applicationVersion()); 43 | } 44 | 45 | MainDialog::~MainDialog() 46 | { 47 | delete ui; 48 | } 49 | 50 | void MainDialog::closeEvent(QCloseEvent *event) 51 | { 52 | this->hide(); 53 | mTray->show(); 54 | event->ignore(); 55 | } 56 | 57 | void MainDialog::showTray() 58 | { 59 | mTray->show(); 60 | } 61 | 62 | bool MainDialog::runServer() 63 | { 64 | return mServer->listen(QHostAddress::Any, SERVER::port); 65 | } 66 | 67 | void MainDialog::newConnection() 68 | { 69 | QWebSocket *sock = mServer->nextPendingConnection(); 70 | while(sock) { 71 | mClientManager->addNewClient(sock); 72 | sock = mServer->nextPendingConnection(); 73 | } 74 | } 75 | 76 | void MainDialog::aboutQtClicked() 77 | { 78 | QMessageBox::aboutQt(this); 79 | } 80 | 81 | void MainDialog::quitClicked() 82 | { 83 | qApp->exit(); 84 | } 85 | 86 | void MainDialog::trayActivated(QSystemTrayIcon::ActivationReason reason) 87 | { 88 | Q_UNUSED(reason) 89 | this->show(); 90 | } 91 | -------------------------------------------------------------------------------- /PulasQt/maindialog.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINDIALOG_H 2 | #define MAINDIALOG_H 3 | 4 | #include 5 | #include 6 | 7 | class QWebSocketServer; 8 | class ClientManager; 9 | 10 | namespace Ui { 11 | class MainDialog; 12 | } 13 | 14 | class MainDialog : public QDialog 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit MainDialog(QWidget *parent = 0); 20 | ~MainDialog(); 21 | void closeEvent(QCloseEvent * event); 22 | void showTray(); 23 | 24 | private: 25 | Ui::MainDialog *ui; 26 | QWebSocketServer *mServer; 27 | ClientManager *mClientManager; 28 | QSystemTrayIcon *mTray; 29 | 30 | private slots: 31 | bool runServer(); 32 | void newConnection(); 33 | void aboutQtClicked(); 34 | void quitClicked(); 35 | void trayActivated(QSystemTrayIcon::ActivationReason reason); 36 | }; 37 | 38 | #endif // MAINDIALOG_H 39 | -------------------------------------------------------------------------------- /PulasQt/maindialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 279 11 | 12 | 13 | 14 | MainDialog 15 | 16 | 17 | 18 | 19 | 20 | 21 | 16777215 22 | 16777215 23 | 24 | 25 | 26 | 27 | 28 | 29 | Qt::AlignCenter 30 | 31 | 32 | 33 | 34 | 35 | 36 | 10 37 | 38 | 39 | 0 40 | 41 | 42 | 43 | 44 | Version 0.1 45 | 46 | 47 | Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 48 | 49 | 50 | 51 | 52 | 53 | 54 | is initializing ... 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Pulas is using Poppler library for reading PDF 64 | 65 | 66 | Qt::AlignCenter 67 | 68 | 69 | 70 | 71 | 72 | 73 | Qt::Vertical 74 | 75 | 76 | 77 | 20 78 | 40 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | Qt::Horizontal 89 | 90 | 91 | 92 | 40 93 | 20 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | About Qt 102 | 103 | 104 | 105 | 106 | 107 | 108 | Quit 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /PulasQt/pdf.cpp: -------------------------------------------------------------------------------- 1 | #include "pdf.h" 2 | #include "poppler/qt5/poppler-qt5.h" 3 | #include 4 | #include 5 | 6 | Pdf::Pdf(QObject *parent) : 7 | QObject(parent), 8 | mDocument(NULL) 9 | { 10 | 11 | } 12 | 13 | bool Pdf::load(const QString &str) 14 | { 15 | if(mDocument) 16 | delete mDocument; 17 | 18 | const QByteArray &ba = QByteArray::fromBase64(str.toUtf8()); 19 | const QByteArray ow; 20 | const QByteArray uw; 21 | mDocument = Poppler::Document::loadFromData(ba, ow, uw); 22 | if(!mDocument && mDocument->isLocked()) 23 | return false; 24 | mDocument->setRenderBackend(Poppler::Document::ArthurBackend); 25 | return true; 26 | } 27 | 28 | int Pdf::getNumPage() 29 | { 30 | if(mDocument) 31 | return mDocument->numPages(); 32 | return 0; 33 | } 34 | 35 | QImage Pdf::getImage(int page) 36 | { 37 | Poppler::Page *p = getPage(page); 38 | if(p) 39 | return p->renderToImage(); 40 | return QImage(); 41 | } 42 | 43 | bool Pdf::paint(int page, QPainter *painter, double res, int x, int y) 44 | { 45 | Poppler::Page *p = getPage(page); 46 | if(p) 47 | return p->renderToPainter(painter, res, res, x, y); 48 | return false; 49 | } 50 | 51 | QSizeF Pdf::getPageSize(int page) 52 | { 53 | Poppler::Page *p = getPage(page); 54 | if(p) 55 | return p->pageSizeF(); 56 | return QSizeF(); 57 | } 58 | 59 | Poppler::Page *Pdf::getPage(int page) 60 | { 61 | if(!mDocument) 62 | return NULL; 63 | if(page >= getNumPage() || page < 0) 64 | return NULL; 65 | return mDocument->page(page); 66 | } 67 | -------------------------------------------------------------------------------- /PulasQt/pdf.h: -------------------------------------------------------------------------------- 1 | #ifndef PDF_H 2 | #define PDF_H 3 | 4 | #include 5 | 6 | class QPainter; 7 | namespace Poppler { 8 | class Document; 9 | class Page; 10 | } 11 | 12 | class Pdf : public QObject 13 | { 14 | Q_OBJECT 15 | public: 16 | Pdf(QObject *parent = 0); 17 | bool load(const QString &str); 18 | int getNumPage(); 19 | QImage getImage(int page); 20 | bool paint(int page, QPainter *painter, double res, int x, int y); 21 | QSizeF getPageSize(int page); 22 | 23 | private: 24 | Poppler::Document *mDocument; 25 | 26 | Poppler::Page *getPage(int page); 27 | }; 28 | 29 | #endif // PDF_H 30 | -------------------------------------------------------------------------------- /PulasQt/printer.cpp: -------------------------------------------------------------------------------- 1 | #include "printer.h" 2 | #include "constant.h" 3 | #include "pdf.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | Printer::Printer(QObject *parent) : 17 | QObject(parent), 18 | mPrinter(new QPrinter(QPrinterInfo::defaultPrinter())), 19 | mIsPaperCustomSize(false) 20 | { 21 | mDefaultMargin = 20; 22 | mPaperSize = QPrinter::A4; 23 | mUnit = QPrinter::Millimeter; 24 | mMargin = QMarginsF(mDefaultMargin, mDefaultMargin, mDefaultMargin, mDefaultMargin); 25 | mOrientation = QPrinter::Portrait; 26 | mResolution = -1; 27 | mColorMode = QPrinter::Color; 28 | mPageOrder = QPrinter::FirstPageFirst; 29 | initMap(); 30 | applySetting(); 31 | } 32 | 33 | QVariant Printer::getListPrinter() 34 | { 35 | QStringList list = QPrinterInfo::availablePrinterNames(); 36 | QVariantList ret; 37 | foreach (const QString &str, list) { 38 | ret.append(QVariant(str)); 39 | } 40 | return QVariant(ret); 41 | } 42 | 43 | QVariant Printer::getDefaultPrinterName() 44 | { 45 | return QVariant(QPrinterInfo::defaultPrinterName()); 46 | } 47 | 48 | QVariant Printer::setPrinter(const QString &name) 49 | { 50 | mPrinter->setPrinterName(name); 51 | return QVariant(true); 52 | } 53 | 54 | QVariant Printer::getCurrentPrinter() 55 | { 56 | return QVariant(mPrinter->printerName()); 57 | } 58 | 59 | QVariant Printer::settingPrinter(const QVariant &setting) 60 | { 61 | const QVariantMap &m = qvariant_cast(setting); 62 | //check the paper 63 | if(m.contains("papersize")) { 64 | if(m.value("papersize").type() == QVariant::String) { 65 | mPaperSize = mPaperSizeMap.value(m.value("paper").toString(), QPrinter::A4); 66 | mIsPaperCustomSize = false; 67 | } else if(m.value("papersize").canConvert()) { 68 | const QVariantMap &vm = qvariant_cast(m.value("papersize")); 69 | mIsPaperCustomSize = true; 70 | mPaperCustomSize.setWidth(vm.value("width", QVariant(0.0f)).toFloat()); 71 | mPaperCustomSize.setHeight(vm.value("height", QVariant(0.0f)).toFloat()); 72 | } 73 | } 74 | //check unit 75 | if(m.contains("unit")) { 76 | mUnit = mUnitMap.value(m.value("unit").toString(), QPrinter::Millimeter); 77 | } 78 | //check margin 79 | if(m.contains("margin")) { 80 | const QVariantMap &mg = qvariant_cast(m.value("margin")); 81 | mMargin.setTop(mg.value("top", QVariant(mDefaultMargin)).toDouble()); 82 | mMargin.setRight(mg.value("right", QVariant(mDefaultMargin)).toDouble()); 83 | mMargin.setBottom(mg.value("bottom", QVariant(mDefaultMargin)).toDouble()); 84 | mMargin.setLeft(mg.value("left", QVariant(mDefaultMargin)).toDouble()); 85 | } 86 | //check orientation 87 | if(m.contains("orientation")) { 88 | mOrientation = mOrientationMap.value(m.value("orientation").toString(), QPrinter::Portrait); 89 | } 90 | //resolution 91 | if(m.contains("resolution")) { 92 | mResolution = m.value("resolution").toInt(); 93 | } 94 | //color mode 95 | if(m.contains("colormode")) { 96 | const QString &cm = m.value("colormode").toString(); 97 | if(!cm.compare("grayscale")) 98 | mColorMode = QPrinter::GrayScale; 99 | else if(!cm.compare("color")) 100 | mColorMode = QPrinter::Color; 101 | } 102 | //page order 103 | if(m.contains("pageorder")) { 104 | const QString &po = m.value("pageorder").toString(); 105 | if(!po.compare("firsttolast")) 106 | mPageOrder = QPrinter::FirstPageFirst; 107 | else if(!po.compare("lasttofirst")) 108 | mPageOrder = QPrinter::LastPageFirst; 109 | } 110 | applySetting(); 111 | return QVariant(true); 112 | } 113 | 114 | QVariant Printer::print(const QVariant &data) 115 | { 116 | const QVariantMap &m = qvariant_cast(data); 117 | int type = HTML; 118 | if(m.value("printtype").toString().compare("escp") == 0) { 119 | type = ESCP_COMMAND; 120 | } 121 | int output = NATIVE; 122 | if(m.value("printoutput").toString().compare("pdf") == 0) { 123 | QTemporaryFile temp; 124 | if(temp.open()) 125 | mPdfFileName = temp.fileName(); 126 | output = PDF; 127 | mPrinter->setOutputFormat(QPrinter::PdfFormat); 128 | mPrinter->setOutputFileName(mPdfFileName); 129 | } 130 | if(type == HTML) { 131 | QTemporaryFile temp; 132 | QString n; 133 | if(temp.open()) { 134 | n = temp.fileName() + ".html"; 135 | } 136 | QFile f(n); 137 | if(f.open(QFile::WriteOnly)) { 138 | QTextStream s(&f); 139 | s << m.value("data").toString(); 140 | f.close(); 141 | } 142 | QWebPage wp; 143 | wp.mainFrame()->load(QUrl("file:///" + n)); 144 | waitLoad(wp.mainFrame()); 145 | wp.mainFrame()->print(mPrinter); 146 | } else { 147 | directPrint(m.value("data").toString()); 148 | return QVariant(true); 149 | } 150 | if(output == PDF) { 151 | //read file 152 | QFile f(mPdfFileName); 153 | if(f.open(QFile::ReadOnly)) { 154 | QByteArray ba = f.readAll().toBase64(); 155 | return QVariant(QString(ba)); 156 | } 157 | return QVariant(false); 158 | } else { 159 | return QVariant(true); 160 | } 161 | } 162 | 163 | QVariant Printer::getSupportedResolution() 164 | { 165 | QList l = mPrinter->supportedResolutions(); 166 | QVariantList ret; 167 | foreach (const int &v, l) { 168 | ret.append(QVariant(v)); 169 | } 170 | return QVariant(ret); 171 | } 172 | 173 | QVariant Printer::printPdf(const QVariant &data) 174 | { 175 | const QVariantMap &json = qvariant_cast(data); 176 | //printing size : actualsize, fitwidth, fitheight, fitauto 177 | //printing position horizontal : left, center, right 178 | //printing position vertical : top, middle, bottom 179 | QString size = "actualsize"; 180 | QString hpos = "center"; 181 | QString vpos = "top"; 182 | qreal res = mPrinter->resolution(); 183 | mPrinter->setFullPage(true); 184 | mPrinter->setPageMargins(0, 0, 0, 0, mUnit); 185 | QMarginsF oldMargin = mMargin; 186 | int offx = 0; 187 | int offy = 0; 188 | const QRectF &paperRect = mPrinter->paperRect(QPrinter::Point); 189 | if(json.contains("size")) { 190 | size = json.value("size").toString(); 191 | } 192 | if(json.contains("halign")) { 193 | hpos = json.value("halign").toString(); 194 | } 195 | if(json.contains("valign")) { 196 | vpos = json.value("valign").toString(); 197 | } 198 | //load the pdf 199 | Pdf pdf; 200 | QPainter painter; 201 | if(!pdf.load(json.value("data").toString()) || !painter.begin(mPrinter)) { 202 | mPrinter->setPageMargins(oldMargin.left(), oldMargin.top(), oldMargin.right(), oldMargin.bottom(), mUnit); 203 | mPrinter->setFullPage(false); 204 | return QVariant(false); 205 | } 206 | for(int i = 0; i < pdf.getNumPage(); i++) { 207 | const QSizeF &pageSize = pdf.getPageSize(i); 208 | qreal scale = 1.0f; 209 | if(!size.compare("fitwidth")) { 210 | scale = paperRect.size().width() / pageSize.width(); 211 | } else if(!size.compare("fitheight")) { 212 | scale = paperRect.size().height() / pageSize.height(); 213 | } else if(!size.compare("fitauto")) { 214 | if(paperRect.size().width() / pageSize.width() < paperRect.size().height() / pageSize.height()) { 215 | scale = paperRect.size().width() / pageSize.width(); 216 | } else { 217 | scale = paperRect.size().height() / pageSize.height(); 218 | } 219 | } 220 | if(!hpos.compare("center")) { 221 | offx = (int)((paperRect.size().width() - (scale * pageSize.width())) / 2); 222 | } else if(!hpos.compare("right")) { 223 | offx = (int)(paperRect.size().width() - (scale * pageSize.width())); 224 | } 225 | if(!vpos.compare("middle")) { 226 | offy = (int)((paperRect.size().height() - (scale * pageSize.height())) / 2); 227 | } else if(!vpos.compare("bottom")) { 228 | offy = (int)(paperRect.size().height() - (scale * pageSize.height())); 229 | } 230 | //convert from point to pixel 231 | offx = offx * 4 / 3; 232 | offy = offy * 4 / 3; 233 | pdf.paint(i, &painter, res * scale, -offx, -offy); 234 | if(i != pdf.getNumPage() - 1) 235 | mPrinter->newPage(); 236 | } 237 | painter.end(); 238 | mPrinter->setPageMargins(oldMargin.left(), oldMargin.top(), oldMargin.right(), oldMargin.bottom(), mUnit); 239 | mPrinter->setFullPage(false); 240 | return QVariant(true); 241 | } 242 | 243 | void Printer::applySetting() 244 | { 245 | if(mIsPaperCustomSize) { 246 | if(mPaperCustomSize.height() > 0.0f && mPaperCustomSize.width() > 0.0f) 247 | mPrinter->setPaperSize(mPaperCustomSize, mUnit); 248 | } else { 249 | mPrinter->setPageSize(mPaperSize); 250 | } 251 | mPrinter->setPageMargins(mMargin.left(), mMargin.top(), mMargin.right(), mMargin.bottom(), mUnit); 252 | mPrinter->setOrientation(mOrientation); 253 | if(mResolution > 0) 254 | mPrinter->setResolution(mResolution); 255 | mPrinter->setColorMode(mColorMode); 256 | mPrinter->setPageOrder(mPageOrder); 257 | } 258 | 259 | void Printer::initMap() 260 | { 261 | mUnitMap.insert("mm", QPrinter::Millimeter); 262 | mUnitMap.insert("inch", QPrinter::Inch); 263 | mPaperSizeMap.insert("A4", QPrinter::A4); 264 | mPaperSizeMap.insert("A5", QPrinter::A5); 265 | mPaperSizeMap.insert("Letter", QPrinter::Letter); 266 | mOrientationMap.insert("portrait", QPrinter::Portrait); 267 | mOrientationMap.insert("landscape", QPrinter::Landscape); 268 | } 269 | 270 | bool Printer::waitLoad(QWebFrame *f) 271 | { 272 | QEventLoop loopLoad; 273 | QTimer timer; 274 | timer.setSingleShot(true); 275 | timer.start(TIMEOUT); 276 | QObject::connect(f, SIGNAL(loadFinished(bool)), &loopLoad, SLOT(quit())); 277 | QObject::connect(&timer, SIGNAL(timeout()), &loopLoad, SLOT(quit())); 278 | loopLoad.exec(); 279 | return true; 280 | } 281 | 282 | void Printer::directPrint(const QString &str) 283 | { 284 | const QString pName = mPrinter->printerName(); 285 | wchar_t printerName[128]; 286 | pName.toWCharArray(printerName); 287 | printerName[pName.length()] = '\0'; 288 | LPBYTE lpData; 289 | QByteArray ba = str.toUtf8(); 290 | lpData = (unsigned char*)(ba.data()); 291 | DWORD dwCount = ba.length(); 292 | 293 | DOC_INFO_1 docInfo; 294 | wchar_t docName[16], dataType[8]; 295 | wcscpy_s(docName, 100, L"Pulas Document"); 296 | wcscpy_s(dataType, 100, L"RAW"); 297 | docInfo.pOutputFile = NULL; 298 | docInfo.pDocName = docName; 299 | docInfo.pDatatype = dataType; 300 | 301 | BOOL bStatus = FALSE; 302 | HANDLE hPrinter = NULL; 303 | DWORD dwPrtJob = 0L; 304 | DWORD dwBytesWritten = 0L; 305 | 306 | bStatus = OpenPrinterW(printerName, &hPrinter, NULL); 307 | if(bStatus) { 308 | 309 | dwPrtJob = StartDocPrinterW ( 310 | hPrinter, 311 | 1, 312 | (LPBYTE)&docInfo); 313 | 314 | if (dwPrtJob > 0) { 315 | // Send the data to the printer. 316 | bStatus = WritePrinter ( 317 | hPrinter, 318 | lpData, 319 | dwCount, 320 | &dwBytesWritten); 321 | } 322 | 323 | EndDocPrinter (hPrinter); 324 | 325 | // Close the printer handle. 326 | bStatus = ClosePrinter(hPrinter); 327 | } 328 | } 329 | -------------------------------------------------------------------------------- /PulasQt/printer.h: -------------------------------------------------------------------------------- 1 | #ifndef PRINTER_H 2 | #define PRINTER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class QWebFrame; 9 | 10 | class Printer : public QObject 11 | { 12 | Q_OBJECT 13 | public: 14 | enum PrintType { 15 | HTML, 16 | ESCP_COMMAND 17 | }; 18 | enum PrintOutput { 19 | NATIVE, 20 | PDF 21 | }; 22 | 23 | Printer(QObject *parent = 0); 24 | QVariant getListPrinter(); 25 | QVariant getDefaultPrinterName(); 26 | QVariant setPrinter(const QString &name); 27 | QVariant getCurrentPrinter(); 28 | QVariant settingPrinter(const QVariant &setting); 29 | QVariant print(const QVariant &data); 30 | QVariant getSupportedResolution(); 31 | QVariant printPdf(const QVariant &data); 32 | 33 | private: 34 | qreal mDefaultMargin; 35 | QString mPdfFileName; 36 | QPrinter *mPrinter; 37 | QPrinter::PaperSize mPaperSize; 38 | QPrinter::Unit mUnit; 39 | QMarginsF mMargin; 40 | QSizeF mPaperCustomSize; 41 | bool mIsPaperCustomSize; 42 | QPrinter::Orientation mOrientation; 43 | int mResolution; 44 | QPrinter::ColorMode mColorMode; 45 | QPrinter::PageOrder mPageOrder; 46 | QMap mUnitMap; 47 | QMap mPaperSizeMap; 48 | QMap mOrientationMap; 49 | 50 | void applySetting(); 51 | void initMap(); 52 | bool waitLoad(QWebFrame *f); 53 | void directPrint(const QString &str); 54 | }; 55 | 56 | #endif // PRINTER_H 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pulas 2 | 3 | Pulas is a Qt application and Javascript library that allow to print directly from Javascript (on your browser) to the printer without open any printing dialog. The application is using WebKit for rendering the content of html. So, it can contain live html means that it will able to render image that has link to live website. And it able to print any html or html5 to pdf. 4 | 5 | ### Features 6 | - fully html and css compatible (also the js inside it) 7 | - select and configure printer from the javascript 8 | - print to pdf and download to the browser 9 | - print raw (example sending ESC/P command to dot matrix) 10 | 11 | ### Binary Download 12 | - Please go to [pulas.lekapin.com](http://pulas.lekapin.com) 13 | 14 | ### Get started 15 | - Download the binary package 16 | - Run the pulasQt/pulas.exe and make sure to allow access network. 17 | - Open pulasJS/example/full.html (make sure you have internet connection) 18 | 19 | ### Documentation 20 | - check here [wiki](https://github.com/apinprastya/pulas/wiki) 21 | 22 | ### Todos 23 | - [x] build binary that ready to use by user 24 | - [x] documentation how to use it 25 | - [x] example html js 26 | - [x] build javascript using gulp for optimizing 27 | - [x] print from pdf 28 | - [ ] any suggestion? 29 | 30 | ### License 31 | - PulasQt is under GPL 32 | - PulasJS is under LGPL 33 | 34 | ### Author 35 | - apin (apin.klas@gmail.com) 36 | 37 | tags: html5 to pdf, javascript printing, web direct printing 38 | -------------------------------------------------------------------------------- /external_libs/poppler/include/poppler/qt5/poppler-annotation.h: -------------------------------------------------------------------------------- 1 | /* poppler-annotation.h: qt interface to poppler 2 | * Copyright (C) 2006-2008, 2012, 2013 Albert Astals Cid 3 | * Copyright (C) 2006, 2008 Pino Toscano 4 | * Copyright (C) 2007, Brad Hards 5 | * Copyright (C) 2010, Philip Lorenz 6 | * Copyright (C) 2012, 2015, Tobias Koenig 7 | * Copyright (C) 2012, Guillermo A. Amaral B. 8 | * Copyright (C) 2012, 2013 Fabio D'Urso 9 | * Copyright (C) 2013, Anthony Granger 10 | * Adapting code from 11 | * Copyright (C) 2004 by Enrico Ros 12 | * 13 | * This program is free software; you can redistribute it and/or modify 14 | * it under the terms of the GNU General Public License as published by 15 | * the Free Software Foundation; either version 2, or (at your option) 16 | * any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | * GNU General Public License for more details. 22 | * 23 | * You should have received a copy of the GNU General Public License 24 | * along with this program; if not, write to the Free Software 25 | * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 26 | */ 27 | 28 | #ifndef _POPPLER_ANNOTATION_H_ 29 | #define _POPPLER_ANNOTATION_H_ 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include "poppler-export.h" 43 | 44 | namespace Poppler { 45 | 46 | class Annotation; 47 | class AnnotationPrivate; 48 | class TextAnnotationPrivate; 49 | class LineAnnotationPrivate; 50 | class GeomAnnotationPrivate; 51 | class HighlightAnnotationPrivate; 52 | class StampAnnotationPrivate; 53 | class InkAnnotationPrivate; 54 | class LinkAnnotationPrivate; 55 | class CaretAnnotationPrivate; 56 | class FileAttachmentAnnotationPrivate; 57 | class SoundAnnotationPrivate; 58 | class MovieAnnotationPrivate; 59 | class ScreenAnnotationPrivate; 60 | class WidgetAnnotationPrivate; 61 | class RichMediaAnnotationPrivate; 62 | class EmbeddedFile; 63 | class Link; 64 | class SoundObject; 65 | class MovieObject; 66 | class LinkRendition; 67 | class Page; 68 | 69 | /** 70 | * \short Helper class for (recursive) Annotation retrieval/storage. 71 | * 72 | */ 73 | class POPPLER_QT5_EXPORT AnnotationUtils 74 | { 75 | public: 76 | /** 77 | * Restore an Annotation (with revisions if needed) from the DOM 78 | * element \p annElement. 79 | * \returns a pointer to the complete Annotation or 0 if element is 80 | * invalid. 81 | */ 82 | static Annotation * createAnnotation( const QDomElement & annElement ); 83 | 84 | /** 85 | * Save the Annotation \p ann as a child of \p annElement taking 86 | * care of saving all revisions if \p ann has any. 87 | */ 88 | static void storeAnnotation( const Annotation * ann, 89 | QDomElement & annElement, QDomDocument & document ); 90 | 91 | /** 92 | * Returns an element called \p name from the direct children of 93 | * \p parentNode or a null element if not found. 94 | */ 95 | static QDomElement findChildElement( const QDomNode & parentNode, 96 | const QString & name ); 97 | }; 98 | 99 | 100 | /** 101 | * \short Annotation class holding properties shared by all annotations. 102 | * 103 | * An Annotation is an object (text note, highlight, sound, popup window, ..) 104 | * contained by a Page in the document. 105 | * 106 | * \warning Different Annotation objects might point to the same annotation. 107 | * 108 | * \section annotCreation How to add annotations 109 | * 110 | * Create an Annotation object of the desired subclass (for example 111 | * TextAnnotation) and set its properties: 112 | * @code 113 | * Poppler::TextAnnotation* myann = new Poppler::TextAnnotation(Poppler::TextAnnotation::InPlace); 114 | * myann->setBoundary(QRectF(0.1, 0.1, 0.2, 0.2)); // normalized coordinates: (0,0) is top-left, (1,1) is bottom-right 115 | * myann->setContents("Hello, world!"); 116 | * @endcode 117 | * \note Always set a boundary rectangle, or nothing will be shown! 118 | * 119 | * Obtain a pointer to the Page where you want to add the annotation (refer to 120 | * \ref req for instructions) and add the annotation: 121 | * @code 122 | * Poppler::Page* mypage = ...; 123 | * mypage->addAnnotation(myann); 124 | * @endcode 125 | * 126 | * You can keep on editing the annotation after it has been added to the page: 127 | * @code 128 | * myann->setContents("World, hello!"); // Let's change text... 129 | * myann->setAuthor("Your name here"); // ...and set an author too 130 | * @endcode 131 | * 132 | * When you're done with editing the annotation, you must destroy the Annotation 133 | * object: 134 | * @code 135 | * delete myann; 136 | * @endcode 137 | * 138 | * Use the PDFConverter class to save the modified document. 139 | * 140 | * \section annotFixedRotation FixedRotation flag specifics 141 | * 142 | * According to the PDF specification, annotations whose 143 | * Annotation::FixedRotation flag is set must always be shown in their original 144 | * orientation, no matter what the current rendering rotation or the page's 145 | * Page::orientation() values are. In comparison with regular annotations, such 146 | * annotations should therefore be transformed by an extra rotation at rendering 147 | * time to "undo" such context-related rotations, which is equal to 148 | * -(rendering_rotation + page_orientation). The rotation pivot 149 | * is the top-left corner of the boundary rectangle. 150 | * 151 | * In practice, %Poppler's \ref Page::renderToImage only "unrotates" the 152 | * page orientation, and does not unrotate the rendering rotation. 153 | * This ensures consistent renderings at different Page::Rotation values: 154 | * annotations are always positioned as if they were being positioned at the 155 | * default page orientation. 156 | * 157 | * Just like regular annotations, %Poppler Qt4 exposes normalized coordinates 158 | * relative to the page's default orientation. However, behind the scenes, the 159 | * coordinate system is different and %Poppler transparently transforms each 160 | * shape. If you never call either Annotation::setFlags or 161 | * Annotation::setBoundary, you don't need to worry about this; but if you do 162 | * call them, then you need to adhere to the following rules: 163 | * - Whenever you toggle the Annotation::FixedRotation flag, you must 164 | * set again the boundary rectangle first, and then you must set 165 | * again any other geometry-related property. 166 | * - Whenever you modify the boundary rectangle of an annotation whose 167 | * Annotation::FixedRotation flag is set, you must set again any other 168 | * geometry-related property. 169 | * 170 | * These two rules are necessary to make %Poppler's transparent coordinate 171 | * conversion work properly. 172 | */ 173 | class POPPLER_QT5_EXPORT Annotation 174 | { 175 | friend class AnnotationUtils; 176 | friend class LinkMovie; 177 | friend class LinkRendition; 178 | 179 | public: 180 | // enum definitions 181 | /** 182 | * Annotation subclasses 183 | * 184 | * \sa subType() 185 | */ 186 | // WARNING!!! oKular uses that very same values so if you change them notify the author! 187 | enum SubType 188 | { 189 | AText = 1, ///< TextAnnotation 190 | ALine = 2, ///< LineAnnotation 191 | AGeom = 3, ///< GeomAnnotation 192 | AHighlight = 4, ///< HighlightAnnotation 193 | AStamp = 5, ///< StampAnnotation 194 | AInk = 6, ///< InkAnnotation 195 | ALink = 7, ///< LinkAnnotation 196 | ACaret = 8, ///< CaretAnnotation 197 | AFileAttachment = 9, ///< FileAttachmentAnnotation 198 | ASound = 10, ///< SoundAnnotation 199 | AMovie = 11, ///< MovieAnnotation 200 | AScreen = 12, ///< ScreenAnnotation \since 0.20 201 | AWidget = 13, ///< WidgetAnnotation \since 0.22 202 | ARichMedia = 14, ///< RichMediaAnnotation \since 0.36 203 | A_BASE = 0 204 | }; 205 | 206 | /** 207 | * Annotation flags 208 | * 209 | * They can be OR'd together (e.g. Annotation::FixedRotation | Annotation::DenyPrint). 210 | * 211 | * \sa flags(), setFlags(int) 212 | */ 213 | // NOTE: Only flags that are known to work are documented 214 | enum Flag 215 | { 216 | Hidden = 1, ///< Do not display or print the annotation 217 | FixedSize = 2, 218 | FixedRotation = 4, ///< Do not rotate the annotation according to page orientation and rendering rotation \warning Extra care is needed with this flag: see \ref annotFixedRotation 219 | DenyPrint = 8, ///< Do not print the annotation 220 | DenyWrite = 16, 221 | DenyDelete = 32, 222 | ToggleHidingOnMouse = 64, 223 | External = 128 224 | }; 225 | 226 | enum LineStyle { Solid = 1, Dashed = 2, Beveled = 4, Inset = 8, Underline = 16 }; 227 | enum LineEffect { NoEffect = 1, Cloudy = 2}; 228 | enum RevScope { Root = 0 /** \since 0.20 */, Reply = 1, Group = 2, Delete = 4 }; 229 | enum RevType { None = 1, Marked = 2, Unmarked = 4, Accepted = 8, Rejected = 16, Cancelled = 32, Completed = 64 }; 230 | 231 | /** 232 | * Returns the author of the annotation. 233 | */ 234 | QString author() const; 235 | /** 236 | * Sets a new author for the annotation. 237 | */ 238 | void setAuthor( const QString &author ); 239 | 240 | QString contents() const; 241 | void setContents( const QString &contents ); 242 | 243 | /** 244 | * Returns the unique name (ID) of the annotation. 245 | */ 246 | QString uniqueName() const; 247 | /** 248 | * Sets a new unique name for the annotation. 249 | * 250 | * \note no check of the new uniqueName is done 251 | */ 252 | void setUniqueName( const QString &uniqueName ); 253 | 254 | QDateTime modificationDate() const; 255 | void setModificationDate( const QDateTime &date ); 256 | 257 | QDateTime creationDate() const; 258 | void setCreationDate( const QDateTime &date ); 259 | 260 | /** 261 | * Returns this annotation's flags 262 | * 263 | * \sa Flag, setFlags(int) 264 | */ 265 | int flags() const; 266 | /** 267 | * Sets this annotation's flags 268 | * 269 | * \sa Flag, flags(), \ref annotFixedRotation 270 | */ 271 | void setFlags( int flags ); 272 | 273 | /** 274 | * Returns this annotation's boundary rectangle in normalized coordinates 275 | * 276 | * \sa setBoundary(const QRectF&) 277 | */ 278 | QRectF boundary() const; 279 | /** 280 | * Sets this annotation's boundary rectangle 281 | * 282 | * The boundary rectangle is the smallest rectangle that contains the 283 | * annotation. 284 | * 285 | * \warning This property is mandatory: you must always set this. 286 | * 287 | * \sa boundary(), \ref annotFixedRotation 288 | */ 289 | void setBoundary( const QRectF &boundary ); 290 | 291 | /** 292 | * \short Container class for Annotation style information 293 | * 294 | * \since 0.20 295 | */ 296 | class POPPLER_QT5_EXPORT Style 297 | { 298 | public: 299 | Style(); 300 | Style( const Style &other ); 301 | Style& operator=( const Style &other ); 302 | ~Style(); 303 | 304 | // appearance properties 305 | QColor color() const; // black 306 | void setColor(const QColor &color); 307 | double opacity() const; // 1.0 308 | void setOpacity(double opacity); 309 | 310 | // pen properties 311 | double width() const; // 1.0 312 | void setWidth(double width); 313 | LineStyle lineStyle() const; // LineStyle::Solid 314 | void setLineStyle(LineStyle style); 315 | double xCorners() const; // 0.0 316 | void setXCorners(double radius); 317 | double yCorners() const; // 0.0 318 | void setYCorners(double radius); 319 | const QVector& dashArray() const; // [ 3 ] 320 | void setDashArray(const QVector &array); 321 | 322 | // pen effects 323 | LineEffect lineEffect() const; // LineEffect::NoEffect 324 | void setLineEffect(LineEffect effect); 325 | double effectIntensity() const; // 1.0 326 | void setEffectIntensity(double intens); 327 | 328 | private: 329 | class Private; 330 | QSharedDataPointer d; 331 | }; 332 | 333 | /// \since 0.20 334 | Style style() const; 335 | /// \since 0.20 336 | void setStyle( const Style& style ); 337 | 338 | /** 339 | * \short Container class for Annotation pop-up window information 340 | * 341 | * \since 0.20 342 | */ 343 | class POPPLER_QT5_EXPORT Popup 344 | { 345 | public: 346 | Popup(); 347 | Popup( const Popup &other ); 348 | Popup& operator=( const Popup &other ); 349 | ~Popup(); 350 | 351 | // window state (Hidden, FixedRotation, Deny* flags allowed) 352 | int flags() const; // -1 (never initialized) -> 0 (if inited and shown) 353 | void setFlags( int flags ); 354 | 355 | // geometric properties 356 | QRectF geometry() const; // no default 357 | void setGeometry( const QRectF &geom ); 358 | 359 | // window contens/override properties 360 | QString title() const; // '' text in the titlebar (overrides author) 361 | void setTitle( const QString &title ); 362 | QString summary() const; // '' short description (displayed if not empty) 363 | void setSummary( const QString &summary ); 364 | QString text() const; // '' text for the window (overrides annot->contents) 365 | void setText( const QString &text ); 366 | 367 | private: 368 | class Private; 369 | QSharedDataPointer d; 370 | }; 371 | 372 | /// \since 0.20 373 | Popup popup() const; 374 | /// \warning Currently does nothing \since 0.20 375 | void setPopup( const Popup& popup ); 376 | 377 | /// \since 0.20 378 | RevScope revisionScope() const; // Root 379 | 380 | /// \since 0.20 381 | RevType revisionType() const; // None 382 | 383 | /** 384 | * Returns the revisions of this annotation 385 | * 386 | * \note The caller owns the returned annotations and they should 387 | * be deleted when no longer required. 388 | * 389 | * \since 0.20 390 | */ 391 | QList revisions() const; 392 | 393 | /** 394 | * The type of the annotation. 395 | */ 396 | virtual SubType subType() const = 0; 397 | 398 | /** 399 | * Destructor. 400 | */ 401 | virtual ~Annotation(); 402 | 403 | /** 404 | * Describes the flags from an annotations 'AA' dictionary. 405 | * 406 | * This flag is used by the additionalAction() method for ScreenAnnotation 407 | * and WidgetAnnotation. 408 | * 409 | * \since 0.22 410 | */ 411 | enum AdditionalActionType 412 | { 413 | CursorEnteringAction, ///< Performed when the cursor enters the annotation's active area 414 | CursorLeavingAction, ///< Performed when the cursor exists the annotation's active area 415 | MousePressedAction, ///< Performed when the mouse button is pressed inside the annotation's active area 416 | MouseReleasedAction, ///< Performed when the mouse button is released inside the annotation's active area 417 | FocusInAction, ///< Performed when the annotation receives the input focus 418 | FocusOutAction, ///< Performed when the annotation loses the input focus 419 | PageOpeningAction, ///< Performed when the page containing the annotation is opened 420 | PageClosingAction, ///< Performed when the page containing the annotation is closed 421 | PageVisibleAction, ///< Performed when the page containing the annotation becomes visible 422 | PageInvisibleAction ///< Performed when the page containing the annotation becomes invisible 423 | }; 424 | 425 | protected: 426 | /// \cond PRIVATE 427 | Annotation( AnnotationPrivate &dd ); 428 | Annotation( AnnotationPrivate &dd, const QDomNode &description ); 429 | void storeBaseAnnotationProperties( QDomNode & parentNode, QDomDocument & document ) const; 430 | Q_DECLARE_PRIVATE( Annotation ) 431 | QExplicitlySharedDataPointer d_ptr; 432 | /// \endcond 433 | 434 | private: 435 | virtual void store( QDomNode & parentNode, QDomDocument & document ) const = 0; 436 | Q_DISABLE_COPY( Annotation ) 437 | }; 438 | 439 | /** 440 | * \short Annotation containing text. 441 | * 442 | * A text annotation is an object showing some text directly on the page, or 443 | * linked to the contents using an icon shown on a page. 444 | */ 445 | class POPPLER_QT5_EXPORT TextAnnotation : public Annotation 446 | { 447 | friend class AnnotationUtils; 448 | friend class AnnotationPrivate; 449 | 450 | public: 451 | // local enums 452 | enum TextType { Linked, InPlace }; 453 | enum InplaceIntent { Unknown, Callout, TypeWriter }; 454 | 455 | TextAnnotation( TextType type ); 456 | virtual ~TextAnnotation(); 457 | virtual SubType subType() const; 458 | 459 | /** 460 | The type of text annotation represented by this object 461 | */ 462 | TextType textType() const; 463 | 464 | /** 465 | The name of the icon for this text annotation. 466 | 467 | Standard names for text annotation icons are: 468 | - Comment 469 | - Help 470 | - Insert 471 | - Key 472 | - NewParagraph 473 | - Note (this is the default icon to use) 474 | - Paragraph 475 | */ 476 | QString textIcon() const; 477 | 478 | /** 479 | Set the name of the icon to use for this text annotation. 480 | 481 | \sa textIcon for the list of standard names 482 | */ 483 | void setTextIcon( const QString &icon ); 484 | 485 | QFont textFont() const; 486 | void setTextFont( const QFont &font ); 487 | 488 | int inplaceAlign() const; 489 | void setInplaceAlign( int align ); 490 | 491 | QPointF calloutPoint( int id ) const; 492 | /// \since 0.20 493 | QVector calloutPoints() const; 494 | /// \since 0.20 495 | void setCalloutPoints( const QVector &points ); 496 | 497 | InplaceIntent inplaceIntent() const; 498 | void setInplaceIntent( InplaceIntent intent ); 499 | 500 | private: 501 | TextAnnotation( const QDomNode &node ); 502 | TextAnnotation( TextAnnotationPrivate &dd ); 503 | virtual void store( QDomNode &parentNode, QDomDocument &document ) const; 504 | void setTextType( TextType type ); 505 | Q_DECLARE_PRIVATE( TextAnnotation ) 506 | Q_DISABLE_COPY( TextAnnotation ) 507 | }; 508 | 509 | /** 510 | * \short Polygon/polyline annotation. 511 | * 512 | * This annotation represents a polygon (or polyline) to be drawn on a page. 513 | */ 514 | class POPPLER_QT5_EXPORT LineAnnotation : public Annotation 515 | { 516 | friend class AnnotationUtils; 517 | friend class AnnotationPrivate; 518 | 519 | public: 520 | // local enums 521 | /// \since 0.20 522 | enum LineType { StraightLine, Polyline }; 523 | enum TermStyle { Square, Circle, Diamond, OpenArrow, ClosedArrow, None, 524 | Butt, ROpenArrow, RClosedArrow, Slash }; 525 | enum LineIntent { Unknown, Arrow, Dimension, PolygonCloud }; 526 | 527 | /// \since 0.20 528 | LineAnnotation( LineType type ); 529 | virtual ~LineAnnotation(); 530 | virtual SubType subType() const; 531 | 532 | /// \since 0.20 533 | LineType lineType() const; 534 | 535 | QLinkedList linePoints() const; 536 | void setLinePoints( const QLinkedList &points ); 537 | 538 | TermStyle lineStartStyle() const; 539 | void setLineStartStyle( TermStyle style ); 540 | 541 | TermStyle lineEndStyle() const; 542 | void setLineEndStyle( TermStyle style ); 543 | 544 | bool isLineClosed() const; 545 | void setLineClosed( bool closed ); 546 | 547 | QColor lineInnerColor() const; 548 | void setLineInnerColor( const QColor &color ); 549 | 550 | double lineLeadingForwardPoint() const; 551 | void setLineLeadingForwardPoint( double point ); 552 | 553 | double lineLeadingBackPoint() const; 554 | void setLineLeadingBackPoint( double point ); 555 | 556 | bool lineShowCaption() const; 557 | void setLineShowCaption( bool show ); 558 | 559 | LineIntent lineIntent() const; 560 | void setLineIntent( LineIntent intent ); 561 | 562 | private: 563 | LineAnnotation( const QDomNode &node ); 564 | LineAnnotation( LineAnnotationPrivate &dd ); 565 | virtual void store( QDomNode &parentNode, QDomDocument &document ) const; 566 | void setLineType( LineType type ); 567 | Q_DECLARE_PRIVATE( LineAnnotation ) 568 | Q_DISABLE_COPY( LineAnnotation ) 569 | }; 570 | 571 | /** 572 | * \short Geometric annotation. 573 | * 574 | * The geometric annotation represents a geometric figure, like a rectangle or 575 | * an ellipse. 576 | */ 577 | class POPPLER_QT5_EXPORT GeomAnnotation : public Annotation 578 | { 579 | friend class AnnotationUtils; 580 | friend class AnnotationPrivate; 581 | 582 | public: 583 | GeomAnnotation(); 584 | virtual ~GeomAnnotation(); 585 | virtual SubType subType() const; 586 | 587 | // common enums 588 | enum GeomType { InscribedSquare, InscribedCircle }; 589 | 590 | GeomType geomType() const; 591 | void setGeomType( GeomType style ); 592 | 593 | QColor geomInnerColor() const; 594 | void setGeomInnerColor( const QColor &color ); 595 | 596 | private: 597 | GeomAnnotation( const QDomNode &node ); 598 | GeomAnnotation( GeomAnnotationPrivate &dd ); 599 | virtual void store( QDomNode &parentNode, QDomDocument &document ) const; 600 | Q_DECLARE_PRIVATE( GeomAnnotation ) 601 | Q_DISABLE_COPY( GeomAnnotation ) 602 | }; 603 | 604 | /** 605 | * \short Text highlight annotation. 606 | * 607 | * The higlight annotation represents some areas of text being "highlighted". 608 | */ 609 | class POPPLER_QT5_EXPORT HighlightAnnotation : public Annotation 610 | { 611 | friend class AnnotationUtils; 612 | friend class AnnotationPrivate; 613 | 614 | public: 615 | HighlightAnnotation(); 616 | virtual ~HighlightAnnotation(); 617 | virtual SubType subType() const; 618 | 619 | /** 620 | The type of highlight 621 | */ 622 | enum HighlightType { Highlight, ///< highlighter pen style annotation 623 | Squiggly, ///< jagged or squiggly underline 624 | Underline, ///< straight line underline 625 | StrikeOut ///< straight line through-line 626 | }; 627 | 628 | /** 629 | Structure corresponding to a QuadPoints array. This matches a 630 | quadrilateral that describes the area around a word (or set of 631 | words) that are to be highlighted. 632 | */ 633 | struct Quad 634 | { 635 | QPointF points[4]; // 8 valid coords 636 | bool capStart; // false (vtx 1-4) [K] 637 | bool capEnd; // false (vtx 2-3) [K] 638 | double feather; // 0.1 (in range 0..1) [K] 639 | }; 640 | 641 | /** 642 | The type (style) of highlighting to use for this area 643 | or these areas. 644 | */ 645 | HighlightType highlightType() const; 646 | 647 | /** 648 | Set the type of highlighting to use for the given area 649 | or areas. 650 | */ 651 | void setHighlightType( HighlightType type ); 652 | 653 | /** 654 | The list of areas to highlight. 655 | */ 656 | QList< Quad > highlightQuads() const; 657 | 658 | /** 659 | Set the areas to highlight. 660 | */ 661 | void setHighlightQuads( const QList< Quad > &quads ); 662 | 663 | private: 664 | HighlightAnnotation( const QDomNode &node ); 665 | HighlightAnnotation( HighlightAnnotationPrivate &dd ); 666 | virtual void store( QDomNode &parentNode, QDomDocument &document ) const; 667 | Q_DECLARE_PRIVATE( HighlightAnnotation ) 668 | Q_DISABLE_COPY( HighlightAnnotation ) 669 | }; 670 | 671 | /** 672 | * \short Stamp annotation. 673 | * 674 | * A simple annotation drawing a stamp on a page. 675 | */ 676 | class POPPLER_QT5_EXPORT StampAnnotation : public Annotation 677 | { 678 | friend class AnnotationUtils; 679 | friend class AnnotationPrivate; 680 | 681 | public: 682 | StampAnnotation(); 683 | virtual ~StampAnnotation(); 684 | virtual SubType subType() const; 685 | 686 | /** 687 | The name of the icon for this stamp annotation. 688 | 689 | Standard names for stamp annotation icons are: 690 | - Approved 691 | - AsIs 692 | - Confidential 693 | - Departmental 694 | - Draft (this is the default icon type) 695 | - Experimental 696 | - Expired 697 | - Final 698 | - ForComment 699 | - ForPublicRelease 700 | - NotApproved 701 | - NotForPublicRelease 702 | - Sold 703 | - TopSecret 704 | */ 705 | QString stampIconName() const; 706 | 707 | /** 708 | Set the icon type for this stamp annotation. 709 | 710 | \sa stampIconName for the list of standard icon names 711 | */ 712 | void setStampIconName( const QString &name ); 713 | 714 | private: 715 | StampAnnotation( const QDomNode &node ); 716 | StampAnnotation( StampAnnotationPrivate &dd ); 717 | virtual void store( QDomNode &parentNode, QDomDocument &document ) const; 718 | Q_DECLARE_PRIVATE( StampAnnotation ) 719 | Q_DISABLE_COPY( StampAnnotation ) 720 | }; 721 | 722 | /** 723 | * \short Ink Annotation. 724 | * 725 | * Annotation representing an ink path on a page. 726 | */ 727 | class POPPLER_QT5_EXPORT InkAnnotation : public Annotation 728 | { 729 | friend class AnnotationUtils; 730 | friend class AnnotationPrivate; 731 | 732 | public: 733 | InkAnnotation(); 734 | virtual ~InkAnnotation(); 735 | virtual SubType subType() const; 736 | 737 | QList< QLinkedList > inkPaths() const; 738 | void setInkPaths( const QList< QLinkedList > &paths ); 739 | 740 | private: 741 | InkAnnotation( const QDomNode &node ); 742 | virtual void store( QDomNode &parentNode, QDomDocument &document ) const; 743 | InkAnnotation(InkAnnotationPrivate &dd); 744 | Q_DECLARE_PRIVATE( InkAnnotation ) 745 | Q_DISABLE_COPY( InkAnnotation ) 746 | }; 747 | 748 | class POPPLER_QT5_EXPORT LinkAnnotation : public Annotation 749 | { 750 | friend class AnnotationUtils; 751 | friend class AnnotationPrivate; 752 | 753 | public: 754 | virtual ~LinkAnnotation(); 755 | virtual SubType subType() const; 756 | 757 | // local enums 758 | enum HighlightMode { None, Invert, Outline, Push }; 759 | 760 | /** \since 0.20 */ 761 | Link* linkDestination() const; 762 | void setLinkDestination( Link *link ); 763 | 764 | HighlightMode linkHighlightMode() const; 765 | void setLinkHighlightMode( HighlightMode mode ); 766 | 767 | QPointF linkRegionPoint( int id ) const; 768 | void setLinkRegionPoint( int id, const QPointF &point ); 769 | 770 | private: 771 | LinkAnnotation(); 772 | LinkAnnotation( const QDomNode &node ); 773 | LinkAnnotation( LinkAnnotationPrivate &dd ); 774 | virtual void store( QDomNode &parentNode, QDomDocument &document ) const; 775 | Q_DECLARE_PRIVATE( LinkAnnotation ) 776 | Q_DISABLE_COPY( LinkAnnotation ) 777 | }; 778 | 779 | /** 780 | * \short Caret annotation. 781 | * 782 | * The caret annotation represents a symbol to indicate the presence of text. 783 | */ 784 | class POPPLER_QT5_EXPORT CaretAnnotation : public Annotation 785 | { 786 | friend class AnnotationUtils; 787 | friend class AnnotationPrivate; 788 | 789 | public: 790 | CaretAnnotation(); 791 | virtual ~CaretAnnotation(); 792 | virtual SubType subType() const; 793 | 794 | /** 795 | * The symbols for the caret annotation. 796 | */ 797 | enum CaretSymbol { None, P }; 798 | 799 | CaretSymbol caretSymbol() const; 800 | void setCaretSymbol( CaretSymbol symbol ); 801 | 802 | private: 803 | CaretAnnotation( const QDomNode &node ); 804 | CaretAnnotation( CaretAnnotationPrivate &dd ); 805 | virtual void store( QDomNode &parentNode, QDomDocument &document ) const; 806 | Q_DECLARE_PRIVATE( CaretAnnotation ) 807 | Q_DISABLE_COPY( CaretAnnotation ) 808 | }; 809 | 810 | /** 811 | * \short File attachment annotation. 812 | * 813 | * The file attachment annotation represents a file embedded in the document. 814 | * 815 | * \since 0.10 816 | */ 817 | class POPPLER_QT5_EXPORT FileAttachmentAnnotation : public Annotation 818 | { 819 | friend class AnnotationPrivate; 820 | 821 | public: 822 | virtual ~FileAttachmentAnnotation(); 823 | virtual SubType subType() const; 824 | 825 | /** 826 | * Returns the name of the icon of this annotation. 827 | */ 828 | QString fileIconName() const; 829 | /** 830 | * Sets a new name for the icon of this annotation. 831 | */ 832 | void setFileIconName( const QString &icon ); 833 | 834 | /** 835 | * Returns the EmbeddedFile of this annotation. 836 | */ 837 | EmbeddedFile* embeddedFile() const; 838 | /** 839 | * Sets a new EmbeddedFile for this annotation. 840 | * 841 | * \note FileAttachmentAnnotation takes ownership of the object 842 | */ 843 | void setEmbeddedFile( EmbeddedFile *ef ); 844 | 845 | private: 846 | FileAttachmentAnnotation(); 847 | FileAttachmentAnnotation( const QDomNode &node ); 848 | FileAttachmentAnnotation( FileAttachmentAnnotationPrivate &dd ); 849 | virtual void store( QDomNode &parentNode, QDomDocument &document ) const; 850 | Q_DECLARE_PRIVATE( FileAttachmentAnnotation ) 851 | Q_DISABLE_COPY( FileAttachmentAnnotation ) 852 | }; 853 | 854 | /** 855 | * \short Sound annotation. 856 | * 857 | * The sound annotation represents a sound to be played when activated. 858 | * 859 | * \since 0.10 860 | */ 861 | class POPPLER_QT5_EXPORT SoundAnnotation : public Annotation 862 | { 863 | friend class AnnotationPrivate; 864 | 865 | public: 866 | virtual ~SoundAnnotation(); 867 | virtual SubType subType() const; 868 | 869 | /** 870 | * Returns the name of the icon of this annotation. 871 | */ 872 | QString soundIconName() const; 873 | /** 874 | * Sets a new name for the icon of this annotation. 875 | */ 876 | void setSoundIconName( const QString &icon ); 877 | 878 | /** 879 | * Returns the SoundObject of this annotation. 880 | */ 881 | SoundObject* sound() const; 882 | /** 883 | * Sets a new SoundObject for this annotation. 884 | * 885 | * \note SoundAnnotation takes ownership of the object 886 | */ 887 | void setSound( SoundObject *ef ); 888 | 889 | private: 890 | SoundAnnotation(); 891 | SoundAnnotation( const QDomNode &node ); 892 | SoundAnnotation( SoundAnnotationPrivate &dd ); 893 | virtual void store( QDomNode &parentNode, QDomDocument &document ) const; 894 | Q_DECLARE_PRIVATE( SoundAnnotation ) 895 | Q_DISABLE_COPY( SoundAnnotation ) 896 | }; 897 | 898 | /** 899 | * \short Movie annotation. 900 | * 901 | * The movie annotation represents a movie to be played when activated. 902 | * 903 | * \since 0.10 904 | */ 905 | class POPPLER_QT5_EXPORT MovieAnnotation : public Annotation 906 | { 907 | friend class AnnotationPrivate; 908 | 909 | public: 910 | virtual ~MovieAnnotation(); 911 | virtual SubType subType() const; 912 | 913 | /** 914 | * Returns the MovieObject of this annotation. 915 | */ 916 | MovieObject* movie() const; 917 | /** 918 | * Sets a new MovieObject for this annotation. 919 | * 920 | * \note MovieAnnotation takes ownership of the object 921 | */ 922 | void setMovie( MovieObject *movie ); 923 | 924 | /** 925 | * Returns the title of the movie of this annotation. 926 | */ 927 | QString movieTitle() const; 928 | /** 929 | * Sets a new title for the movie of this annotation. 930 | */ 931 | void setMovieTitle( const QString &title ); 932 | 933 | private: 934 | MovieAnnotation(); 935 | MovieAnnotation( const QDomNode &node ); 936 | MovieAnnotation( MovieAnnotationPrivate &dd ); 937 | virtual void store( QDomNode &parentNode, QDomDocument &document ) const; 938 | Q_DECLARE_PRIVATE( MovieAnnotation ) 939 | Q_DISABLE_COPY( MovieAnnotation ) 940 | }; 941 | 942 | /** 943 | * \short Screen annotation. 944 | * 945 | * The screen annotation represents a screen to be played when activated. 946 | * 947 | * \since 0.20 948 | */ 949 | class POPPLER_QT5_EXPORT ScreenAnnotation : public Annotation 950 | { 951 | friend class AnnotationPrivate; 952 | 953 | public: 954 | virtual ~ScreenAnnotation(); 955 | 956 | virtual SubType subType() const; 957 | 958 | /** 959 | * Returns the LinkRendition of this annotation. 960 | */ 961 | LinkRendition* action() const; 962 | 963 | /** 964 | * Sets a new LinkRendition for this annotation. 965 | * 966 | * \note ScreenAnnotation takes ownership of the object 967 | */ 968 | void setAction( LinkRendition *action ); 969 | 970 | /** 971 | * Returns the title of the screen of this annotation. 972 | */ 973 | QString screenTitle() const; 974 | 975 | /** 976 | * Sets a new title for the screen of this annotation. 977 | */ 978 | void setScreenTitle( const QString &title ); 979 | 980 | /** 981 | * Returns the additional action of the given @p type fo the annotation or 982 | * @c 0 if no action has been defined. 983 | * 984 | * \since 0.22 985 | */ 986 | Link* additionalAction( AdditionalActionType type ) const; 987 | 988 | private: 989 | ScreenAnnotation(); 990 | ScreenAnnotation( ScreenAnnotationPrivate &dd ); 991 | virtual void store( QDomNode &parentNode, QDomDocument &document ) const; // stub 992 | Q_DECLARE_PRIVATE( ScreenAnnotation ) 993 | Q_DISABLE_COPY( ScreenAnnotation ) 994 | }; 995 | 996 | /** 997 | * \short Widget annotation. 998 | * 999 | * The widget annotation represents a widget (form field) on a page. 1000 | * 1001 | * \note This class is just provided for consistency of the annotation API, 1002 | * use the FormField classes to get all the form-related information. 1003 | * 1004 | * \since 0.22 1005 | */ 1006 | class POPPLER_QT5_EXPORT WidgetAnnotation : public Annotation 1007 | { 1008 | friend class AnnotationPrivate; 1009 | 1010 | public: 1011 | virtual ~WidgetAnnotation(); 1012 | 1013 | virtual SubType subType() const; 1014 | 1015 | /** 1016 | * Returns the additional action of the given @p type fo the annotation or 1017 | * @c 0 if no action has been defined. 1018 | * 1019 | * \since 0.22 1020 | */ 1021 | Link* additionalAction( AdditionalActionType type ) const; 1022 | 1023 | private: 1024 | WidgetAnnotation(); 1025 | WidgetAnnotation( WidgetAnnotationPrivate &dd ); 1026 | virtual void store( QDomNode &parentNode, QDomDocument &document ) const; // stub 1027 | Q_DECLARE_PRIVATE( WidgetAnnotation ) 1028 | Q_DISABLE_COPY( WidgetAnnotation ) 1029 | }; 1030 | 1031 | /** 1032 | * \short RichMedia annotation. 1033 | * 1034 | * The RichMedia annotation represents a video or sound on a page. 1035 | * 1036 | * \since 0.36 1037 | */ 1038 | class POPPLER_QT5_EXPORT RichMediaAnnotation : public Annotation 1039 | { 1040 | friend class AnnotationPrivate; 1041 | 1042 | public: 1043 | virtual ~RichMediaAnnotation(); 1044 | 1045 | virtual SubType subType() const; 1046 | 1047 | /** 1048 | * The params object of a RichMediaAnnotation::Instance object. 1049 | * 1050 | * The params object provides media specific parameters, to play 1051 | * back the media inside the PDF viewer. 1052 | * 1053 | * At the moment only parameters for flash player are supported. 1054 | */ 1055 | class POPPLER_QT5_EXPORT Params 1056 | { 1057 | friend class AnnotationPrivate; 1058 | 1059 | public: 1060 | Params(); 1061 | ~Params(); 1062 | 1063 | /** 1064 | * Returns the parameters for the flash player. 1065 | */ 1066 | QString flashVars() const; 1067 | 1068 | private: 1069 | void setFlashVars( const QString &flashVars ); 1070 | 1071 | class Private; 1072 | QScopedPointer d; 1073 | }; 1074 | 1075 | /** 1076 | * The instance object of a RichMediaAnnotation::Configuration object. 1077 | * 1078 | * The instance object represents one media object, that should be shown 1079 | * on the page. It has a media type and a Params object, to define the 1080 | * media specific parameters. 1081 | */ 1082 | class POPPLER_QT5_EXPORT Instance 1083 | { 1084 | friend class AnnotationPrivate; 1085 | 1086 | public: 1087 | /** 1088 | * Describes the media type of the instance. 1089 | */ 1090 | enum Type 1091 | { 1092 | Type3D, ///< A 3D media file. 1093 | TypeFlash, ///< A Flash media file. 1094 | TypeSound, ///< A sound media file. 1095 | TypeVideo ///< A video media file. 1096 | }; 1097 | 1098 | Instance(); 1099 | ~Instance(); 1100 | 1101 | /** 1102 | * Returns the media type of the instance. 1103 | */ 1104 | Type type() const; 1105 | 1106 | /** 1107 | * Returns the params object of the instance or @c 0 if it doesn't exist. 1108 | */ 1109 | RichMediaAnnotation::Params* params() const; 1110 | 1111 | private: 1112 | void setType( Type type ); 1113 | void setParams( RichMediaAnnotation::Params *params ); 1114 | 1115 | class Private; 1116 | QScopedPointer d; 1117 | }; 1118 | 1119 | /** 1120 | * The configuration object of a RichMediaAnnotation::Content object. 1121 | * 1122 | * The configuration object provides access to the various Instance objects 1123 | * of the rich media annotation. 1124 | */ 1125 | class POPPLER_QT5_EXPORT Configuration 1126 | { 1127 | friend class AnnotationPrivate; 1128 | 1129 | public: 1130 | /** 1131 | * Describes the media type of the configuration. 1132 | */ 1133 | enum Type 1134 | { 1135 | Type3D, ///< A 3D media file. 1136 | TypeFlash, ///< A Flash media file. 1137 | TypeSound, ///< A sound media file. 1138 | TypeVideo ///< A video media file. 1139 | }; 1140 | 1141 | Configuration(); 1142 | ~Configuration(); 1143 | 1144 | /** 1145 | * Returns the media type of the configuration. 1146 | */ 1147 | Type type() const; 1148 | 1149 | /** 1150 | * Returns the name of the configuration. 1151 | */ 1152 | QString name() const; 1153 | 1154 | /** 1155 | * Returns the list of Instance objects of the configuration. 1156 | */ 1157 | QList< RichMediaAnnotation::Instance* > instances() const; 1158 | 1159 | private: 1160 | void setType( Type type ); 1161 | void setName( const QString &name ); 1162 | void setInstances( const QList< RichMediaAnnotation::Instance* > &instances ); 1163 | 1164 | class Private; 1165 | QScopedPointer d; 1166 | }; 1167 | 1168 | /** 1169 | * The asset object of a RichMediaAnnotation::Content object. 1170 | * 1171 | * The asset object provides a mapping between identifier name, as 1172 | * used in the flash vars string of RichMediaAnnotation::Params, and the 1173 | * associated file spec object. 1174 | */ 1175 | class POPPLER_QT5_EXPORT Asset 1176 | { 1177 | friend class AnnotationPrivate; 1178 | 1179 | public: 1180 | Asset(); 1181 | ~Asset(); 1182 | 1183 | /** 1184 | * Returns the identifier name of the asset. 1185 | */ 1186 | QString name() const; 1187 | 1188 | /** 1189 | * Returns the embedded file the asset points to. 1190 | */ 1191 | EmbeddedFile* embeddedFile() const; 1192 | 1193 | private: 1194 | void setName( const QString &name ); 1195 | void setEmbeddedFile( EmbeddedFile *embeddedFile ); 1196 | 1197 | class Private; 1198 | QScopedPointer d; 1199 | }; 1200 | 1201 | /** 1202 | * The content object of a RichMediaAnnotation. 1203 | * 1204 | * The content object provides access to the list of configurations 1205 | * and assets of the rich media annotation. 1206 | */ 1207 | class POPPLER_QT5_EXPORT Content 1208 | { 1209 | friend class AnnotationPrivate; 1210 | 1211 | public: 1212 | Content(); 1213 | ~Content(); 1214 | 1215 | /** 1216 | * Returns the list of configuration objects of the content object. 1217 | */ 1218 | QList< RichMediaAnnotation::Configuration* > configurations() const; 1219 | 1220 | /** 1221 | * Returns the list of asset objects of the content object. 1222 | */ 1223 | QList< RichMediaAnnotation::Asset* > assets() const; 1224 | 1225 | private: 1226 | void setConfigurations( const QList< RichMediaAnnotation::Configuration* > &configurations ); 1227 | void setAssets( const QList< RichMediaAnnotation::Asset* > &assets ); 1228 | 1229 | class Private; 1230 | QScopedPointer d; 1231 | }; 1232 | 1233 | /** 1234 | * The activation object of the RichMediaAnnotation::Settings object. 1235 | * 1236 | * The activation object is a wrapper around the settings for the activation 1237 | * state. At the moment it provides only the activation condition. 1238 | */ 1239 | class POPPLER_QT5_EXPORT Activation 1240 | { 1241 | friend class AnnotationPrivate; 1242 | 1243 | public: 1244 | /** 1245 | * Describes the condition for activating the rich media. 1246 | */ 1247 | enum Condition { 1248 | PageOpened, ///< Activate when page is opened. 1249 | PageVisible, ///< Activate when page becomes visible. 1250 | UserAction ///< Activate when user interacts with the annotation. 1251 | }; 1252 | 1253 | Activation(); 1254 | ~Activation(); 1255 | 1256 | /** 1257 | * Returns the activation condition. 1258 | */ 1259 | Condition condition() const; 1260 | 1261 | private: 1262 | void setCondition( Condition condition ); 1263 | 1264 | class Private; 1265 | QScopedPointer d; 1266 | }; 1267 | 1268 | /** 1269 | * The deactivation object of the RichMediaAnnotation::Settings object. 1270 | * 1271 | * The deactivation object is a wrapper around the settings for the deactivation 1272 | * state. At the moment it provides only the deactivation condition. 1273 | */ 1274 | class POPPLER_QT5_EXPORT Deactivation 1275 | { 1276 | friend class AnnotationPrivate; 1277 | 1278 | public: 1279 | /** 1280 | * Describes the condition for deactivating the rich media. 1281 | */ 1282 | enum Condition { 1283 | PageClosed, ///< Deactivate when page is closed. 1284 | PageInvisible, ///< Deactivate when page becomes invisible. 1285 | UserAction ///< Deactivate when user interacts with the annotation. 1286 | }; 1287 | 1288 | Deactivation(); 1289 | ~Deactivation(); 1290 | 1291 | /** 1292 | * Returns the deactivation condition. 1293 | */ 1294 | Condition condition() const; 1295 | 1296 | private: 1297 | void setCondition( Condition condition ); 1298 | 1299 | class Private; 1300 | QScopedPointer d; 1301 | }; 1302 | 1303 | /** 1304 | * The settings object of a RichMediaAnnotation. 1305 | * 1306 | * The settings object provides access to the configuration objects 1307 | * for annotation activation and deactivation. 1308 | */ 1309 | class POPPLER_QT5_EXPORT Settings 1310 | { 1311 | friend class AnnotationPrivate; 1312 | 1313 | public: 1314 | Settings(); 1315 | ~Settings(); 1316 | 1317 | /** 1318 | * Returns the Activation object of the settings object or @c 0 if it doesn't exist. 1319 | */ 1320 | RichMediaAnnotation::Activation* activation() const; 1321 | 1322 | /** 1323 | * Returns the Deactivation object of the settings object or @c 0 if it doesn't exist. 1324 | */ 1325 | RichMediaAnnotation::Deactivation* deactivation() const; 1326 | 1327 | private: 1328 | void setActivation( RichMediaAnnotation::Activation *activation ); 1329 | void setDeactivation( RichMediaAnnotation::Deactivation *deactivation ); 1330 | 1331 | class Private; 1332 | QScopedPointer d; 1333 | }; 1334 | 1335 | /** 1336 | * Returns the Settings object of the rich media annotation or @c 0 if it doesn't exist. 1337 | */ 1338 | RichMediaAnnotation::Settings* settings() const; 1339 | 1340 | /** 1341 | * Returns the Content object of the rich media annotation or @c 0 if it doesn't exist. 1342 | */ 1343 | RichMediaAnnotation::Content* content() const; 1344 | 1345 | private: 1346 | void setSettings( RichMediaAnnotation::Settings *settings ); 1347 | void setContent( RichMediaAnnotation::Content *content ); 1348 | 1349 | RichMediaAnnotation(); 1350 | RichMediaAnnotation( const QDomNode &node ); 1351 | RichMediaAnnotation( RichMediaAnnotationPrivate &dd ); 1352 | virtual void store( QDomNode &parentNode, QDomDocument &document ) const; 1353 | Q_DECLARE_PRIVATE( RichMediaAnnotation ) 1354 | Q_DISABLE_COPY( RichMediaAnnotation ) 1355 | }; 1356 | 1357 | } 1358 | 1359 | #endif 1360 | -------------------------------------------------------------------------------- /external_libs/poppler/include/poppler/qt5/poppler-export.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is used to set the poppler_qt5_EXPORT macros right. 3 | * This is needed for setting the visibility on windows, it will have no effect on other platforms. 4 | */ 5 | #if defined(_WIN32) 6 | # define _POPPLER_QT5_LIB_EXPORT __declspec(dllexport) 7 | # define _POPPLER_QT5_LIB_IMPORT __declspec(dllimport) 8 | #elif defined(__GNUC__) 9 | # define _POPPLER_QT5_LIB_EXPORT __attribute__((visibility("default"))) 10 | # define _POPPLER_QT5_LIB_IMPORT 11 | #else 12 | # define _POPPLER_QT5_LIB_EXPORT 13 | # define _POPPLER_QT5_LIB_IMPORT 14 | #endif 15 | 16 | #ifdef poppler_qt5_EXPORTS 17 | # define POPPLER_QT5_EXPORT _POPPLER_QT5_LIB_EXPORT 18 | #else 19 | # define POPPLER_QT5_EXPORT _POPPLER_QT5_LIB_IMPORT 20 | #endif 21 | -------------------------------------------------------------------------------- /external_libs/poppler/include/poppler/qt5/poppler-form.h: -------------------------------------------------------------------------------- 1 | /* poppler-form.h: qt interface to poppler 2 | * Copyright (C) 2007-2008, Pino Toscano 3 | * Copyright (C) 2008, 2011, Albert Astals Cid 4 | * Copyright (C) 2012, Adam Reichold 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifndef _POPPLER_QT5_FORM_H_ 22 | #define _POPPLER_QT5_FORM_H_ 23 | 24 | #include 25 | #include 26 | #include "poppler-export.h" 27 | 28 | class Page; 29 | class FormWidget; 30 | class FormWidgetButton; 31 | class FormWidgetText; 32 | class FormWidgetChoice; 33 | 34 | namespace Poppler { 35 | 36 | class DocumentData; 37 | class Link; 38 | 39 | class FormFieldData; 40 | /** 41 | The base class representing a form field. 42 | 43 | \since 0.6 44 | */ 45 | class POPPLER_QT5_EXPORT FormField { 46 | public: 47 | 48 | /** 49 | The different types of form field. 50 | */ 51 | enum FormType { 52 | FormButton, ///< A button field. See \ref Poppler::FormFieldButton::ButtonType "ButtonType" 53 | FormText, ///< A text field. See \ref Poppler::FormFieldText::TextType "TextType" 54 | FormChoice, ///< A single choice field. See \ref Poppler::FormFieldChoice::ChoiceType "ChoiceType" 55 | FormSignature ///< A signature field. 56 | }; 57 | 58 | virtual ~FormField(); 59 | 60 | /** 61 | The type of the field. 62 | */ 63 | virtual FormType type() const = 0; 64 | 65 | /** 66 | \return The size of the field, in normalized coordinates, i.e. 67 | [0..1] with regard to the dimensions (cropbox) of the page 68 | */ 69 | QRectF rect() const; 70 | 71 | /** 72 | The ID of the field. 73 | */ 74 | int id() const; 75 | 76 | /** 77 | The internal name of the field. 78 | */ 79 | QString name() const; 80 | 81 | /** 82 | The internal fully qualified name of the field. 83 | \since 0.18 84 | */ 85 | QString fullyQualifiedName() const; 86 | 87 | /** 88 | The name of the field to be used in user interface (eg messages to 89 | the user). 90 | */ 91 | QString uiName() const; 92 | 93 | /** 94 | Whether this form field is read-only. 95 | */ 96 | bool isReadOnly() const; 97 | 98 | /** 99 | Whether this form field is visible. 100 | */ 101 | bool isVisible() const; 102 | 103 | /** 104 | The activation action of this form field. 105 | 106 | \note It may be null. 107 | */ 108 | Link* activationAction() const; 109 | 110 | protected: 111 | /// \cond PRIVATE 112 | FormField(FormFieldData &dd); 113 | 114 | FormFieldData *m_formData; 115 | /// \endcond 116 | 117 | private: 118 | Q_DISABLE_COPY(FormField) 119 | }; 120 | 121 | /** 122 | A form field that represents a "button". 123 | 124 | \since 0.8 125 | */ 126 | class POPPLER_QT5_EXPORT FormFieldButton : public FormField { 127 | public: 128 | 129 | /** 130 | * The types of button field. 131 | */ 132 | enum ButtonType 133 | { 134 | Push, ///< A simple push button. 135 | CheckBox, ///< A check box. 136 | Radio ///< A radio button. 137 | }; 138 | 139 | /// \cond PRIVATE 140 | FormFieldButton(DocumentData *doc, ::Page *p, ::FormWidgetButton *w); 141 | /// \endcond 142 | virtual ~FormFieldButton(); 143 | 144 | virtual FormType type() const; 145 | 146 | /** 147 | The particular type of the button field. 148 | */ 149 | ButtonType buttonType() const; 150 | 151 | /** 152 | * The caption to be used for the button. 153 | */ 154 | QString caption() const; 155 | 156 | /** 157 | The state of the button. 158 | */ 159 | bool state() const; 160 | 161 | /** 162 | Sets the state of the button to the new \p state . 163 | */ 164 | void setState( bool state ); 165 | 166 | /** 167 | The list with the IDs of siblings (ie, buttons belonging to the same 168 | group as the current one. 169 | 170 | Valid only for \ref Radio buttons, an empty list otherwise. 171 | */ 172 | QList siblings() const; 173 | 174 | private: 175 | Q_DISABLE_COPY(FormFieldButton) 176 | }; 177 | 178 | /** 179 | A form field that represents a text input. 180 | 181 | \since 0.6 182 | */ 183 | class POPPLER_QT5_EXPORT FormFieldText : public FormField { 184 | public: 185 | 186 | /** 187 | The particular type of this text field. 188 | */ 189 | enum TextType { 190 | Normal, ///< A simple singleline text field. 191 | Multiline, ///< A multiline text field. 192 | FileSelect ///< An input field to select the path of a file on disk. 193 | }; 194 | 195 | /// \cond PRIVATE 196 | FormFieldText(DocumentData *doc, ::Page *p, ::FormWidgetText *w); 197 | /// \endcond 198 | virtual ~FormFieldText(); 199 | 200 | virtual FormType type() const; 201 | 202 | /** 203 | The text type of the text field. 204 | */ 205 | TextType textType() const; 206 | 207 | /** 208 | The text associated with the text field. 209 | */ 210 | QString text() const; 211 | 212 | /** 213 | Sets the text associated with the text field to the specified 214 | \p text. 215 | */ 216 | void setText( const QString& text ); 217 | 218 | /** 219 | Whether this text field is a password input, eg its text \b must be 220 | replaced with asterisks. 221 | 222 | Always false for \ref FileSelect text fields. 223 | */ 224 | bool isPassword() const; 225 | 226 | /** 227 | Whether this text field should allow rich text. 228 | */ 229 | bool isRichText() const; 230 | 231 | /** 232 | The maximum length for the text of this field, or -1 if not set. 233 | */ 234 | int maximumLength() const; 235 | 236 | /** 237 | The horizontal alignment for the text of this text field. 238 | */ 239 | Qt::Alignment textAlignment() const; 240 | 241 | /** 242 | Whether the text inserted manually in the field (where possible) 243 | can be spell-checked. 244 | */ 245 | bool canBeSpellChecked() const; 246 | 247 | private: 248 | Q_DISABLE_COPY(FormFieldText) 249 | }; 250 | 251 | /** 252 | A form field that represents a choice field. 253 | 254 | \since 0.6 255 | */ 256 | class POPPLER_QT5_EXPORT FormFieldChoice : public FormField { 257 | public: 258 | 259 | /** 260 | The particular type of this choice field. 261 | */ 262 | enum ChoiceType { 263 | ComboBox, ///< A simple singleline text field. 264 | ListBox ///< A multiline text field. 265 | }; 266 | 267 | /// \cond PRIVATE 268 | FormFieldChoice(DocumentData *doc, ::Page *p, ::FormWidgetChoice *w); 269 | /// \endcond 270 | virtual ~FormFieldChoice(); 271 | 272 | virtual FormType type() const; 273 | 274 | /** 275 | The choice type of the choice field. 276 | */ 277 | ChoiceType choiceType() const; 278 | 279 | /** 280 | The possible choices of the choice field. 281 | */ 282 | QStringList choices() const; 283 | 284 | /** 285 | Whether this FormFieldChoice::ComboBox is editable, i.e. the user 286 | can type in a custom value. 287 | 288 | Always false for the other types of choices. 289 | */ 290 | bool isEditable() const; 291 | 292 | /** 293 | Whether more than one choice of this FormFieldChoice::ListBox 294 | can be selected at the same time. 295 | 296 | Always false for the other types of choices. 297 | */ 298 | bool multiSelect() const; 299 | 300 | /** 301 | The currently selected choices. 302 | */ 303 | QList currentChoices() const; 304 | 305 | /** 306 | Sets the selected choices to \p choice. 307 | */ 308 | void setCurrentChoices( const QList &choice ); 309 | 310 | /** 311 | The text entered into an editable combo box choice field. Otherwise a null string. 312 | 313 | \since 0.22 314 | */ 315 | QString editChoice() const; 316 | 317 | /** 318 | Sets the text entered into an editable combo box choice field. Otherwise does nothing. 319 | 320 | \since 0.22 321 | */ 322 | void setEditChoice(const QString& text); 323 | 324 | /** 325 | The horizontal alignment for the text of this text field. 326 | */ 327 | Qt::Alignment textAlignment() const; 328 | 329 | /** 330 | Whether the text inserted manually in the field (where possible) 331 | can be spell-checked. 332 | 333 | Returns false if the field is not an editable text field. 334 | */ 335 | bool canBeSpellChecked() const; 336 | 337 | private: 338 | Q_DISABLE_COPY(FormFieldChoice) 339 | }; 340 | 341 | } 342 | 343 | #endif 344 | -------------------------------------------------------------------------------- /external_libs/poppler/include/poppler/qt5/poppler-link.h: -------------------------------------------------------------------------------- 1 | /* poppler-link.h: qt interface to poppler 2 | * Copyright (C) 2006, 2013, Albert Astals Cid 3 | * Copyright (C) 2007-2008, 2010, Pino Toscano 4 | * Copyright (C) 2010, 2012, Guillermo Amaral 5 | * Copyright (C) 2012, Tobias Koenig 6 | * Copyright (C) 2013, Anthony Granger 7 | * Adapting code from 8 | * Copyright (C) 2004 by Enrico Ros 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2, or (at your option) 13 | * any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 23 | */ 24 | 25 | #ifndef _POPPLER_LINK_H_ 26 | #define _POPPLER_LINK_H_ 27 | 28 | #include 29 | #include 30 | #include 31 | #include "poppler-export.h" 32 | 33 | struct Ref; 34 | class MediaRendition; 35 | 36 | namespace Poppler { 37 | 38 | class LinkPrivate; 39 | class LinkGotoPrivate; 40 | class LinkExecutePrivate; 41 | class LinkBrowsePrivate; 42 | class LinkActionPrivate; 43 | class LinkSoundPrivate; 44 | class LinkJavaScriptPrivate; 45 | class LinkMoviePrivate; 46 | class LinkDestinationData; 47 | class LinkDestinationPrivate; 48 | class LinkRenditionPrivate; 49 | class MediaRendition; 50 | class SoundObject; 51 | 52 | /** 53 | * \short A destination. 54 | * 55 | * The LinkDestination class represent a "destination" (in terms of visual 56 | * viewport to be displayed) for \link Poppler::LinkGoto GoTo\endlink links, 57 | * and items in the table of contents (TOC) of a document. 58 | * 59 | * Coordinates are in 0..1 range 60 | */ 61 | class POPPLER_QT5_EXPORT LinkDestination 62 | { 63 | public: 64 | /** 65 | * The possible kind of "viewport destination". 66 | */ 67 | enum Kind 68 | { 69 | /** 70 | * The new viewport is specified in terms of: 71 | * - possibile new left coordinate (see isChangeLeft() ) 72 | * - possibile new top coordinate (see isChangeTop() ) 73 | * - possibile new zoom level (see isChangeZoom() ) 74 | */ 75 | destXYZ = 1, 76 | destFit = 2, 77 | destFitH = 3, 78 | destFitV = 4, 79 | destFitR = 5, 80 | destFitB = 6, 81 | destFitBH = 7, 82 | destFitBV = 8 83 | }; 84 | 85 | /// \cond PRIVATE 86 | LinkDestination(const LinkDestinationData &data); 87 | LinkDestination(const QString &description); 88 | /// \endcond 89 | /** 90 | * Copy constructor. 91 | */ 92 | LinkDestination(const LinkDestination &other); 93 | /** 94 | * Destructor. 95 | */ 96 | ~LinkDestination(); 97 | 98 | // Accessors. 99 | /** 100 | * The kind of destination. 101 | */ 102 | Kind kind() const; 103 | /** 104 | * Which page is the target of this destination. 105 | * 106 | * \note this number is 1-based, so for a 5 pages document the 107 | * valid page numbers go from 1 to 5 (both included). 108 | */ 109 | int pageNumber() const; 110 | /** 111 | * The new left for the viewport of the target page, in case 112 | * it is specified to be changed (see isChangeLeft() ) 113 | */ 114 | double left() const; 115 | double bottom() const; 116 | double right() const; 117 | /** 118 | * The new top for the viewport of the target page, in case 119 | * it is specified to be changed (see isChangeTop() ) 120 | */ 121 | double top() const; 122 | double zoom() const; 123 | /** 124 | * Whether the left of the viewport on the target page should 125 | * be changed. 126 | * 127 | * \see left() 128 | */ 129 | bool isChangeLeft() const; 130 | /** 131 | * Whether the top of the viewport on the target page should 132 | * be changed. 133 | * 134 | * \see top() 135 | */ 136 | bool isChangeTop() const; 137 | /** 138 | * Whether the zoom level should be changed. 139 | * 140 | * \see zoom() 141 | */ 142 | bool isChangeZoom() const; 143 | 144 | /** 145 | * Return a string repesentation of this destination. 146 | */ 147 | QString toString() const; 148 | 149 | /** 150 | * Return the name of this destination. 151 | * 152 | * \since 0.12 153 | */ 154 | QString destinationName() const; 155 | 156 | /** 157 | * Assignment operator. 158 | */ 159 | LinkDestination& operator=(const LinkDestination &other); 160 | 161 | private: 162 | QSharedDataPointer< LinkDestinationPrivate > d; 163 | }; 164 | 165 | /** 166 | * \short Encapsulates data that describes a link. 167 | * 168 | * This is the base class for links. It makes mandatory for inherited 169 | * kind of links to reimplement the linkType() method and return the type of 170 | * the link described by the reimplemented class. 171 | */ 172 | class POPPLER_QT5_EXPORT Link 173 | { 174 | public: 175 | /// \cond PRIVATE 176 | Link( const QRectF &linkArea ); 177 | /// \endcond 178 | 179 | /** 180 | * The possible kinds of link. 181 | * 182 | * Inherited classes must return an unique identifier 183 | */ 184 | enum LinkType 185 | { 186 | None, ///< Unknown link 187 | Goto, ///< A "Go To" link 188 | Execute, ///< A command to be executed 189 | Browse, ///< An URL to be browsed (eg "http://poppler.freedesktop.org") 190 | Action, ///< A "standard" action to be executed in the viewer 191 | Sound, ///< A link representing a sound to be played 192 | Movie, ///< An action to be executed on a movie 193 | Rendition, ///< A rendition link \since 0.20 194 | JavaScript ///< A JavaScript code to be interpreted \since 0.10 195 | }; 196 | 197 | /** 198 | * The type of this link. 199 | */ 200 | virtual LinkType linkType() const; 201 | 202 | /** 203 | * Destructor. 204 | */ 205 | virtual ~Link(); 206 | 207 | /** 208 | * The area of a Page where the link should be active. 209 | * 210 | * \note this can be a null rect, in this case the link represents 211 | * a general action. The area is given in 0..1 range 212 | */ 213 | QRectF linkArea() const; 214 | 215 | protected: 216 | /// \cond PRIVATE 217 | Link( LinkPrivate &dd ); 218 | Q_DECLARE_PRIVATE( Link ) 219 | LinkPrivate *d_ptr; 220 | /// \endcond 221 | 222 | private: 223 | Q_DISABLE_COPY( Link ) 224 | }; 225 | 226 | 227 | /** 228 | * \brief Viewport reaching request. 229 | * 230 | * With a LinkGoto link, the document requests the specified viewport to be 231 | * reached (aka, displayed in a viewer). Furthermore, if a file name is specified, 232 | * then the destination refers to that document (and not to the document the 233 | * current LinkGoto belongs to). 234 | */ 235 | class POPPLER_QT5_EXPORT LinkGoto : public Link 236 | { 237 | public: 238 | /** 239 | * Create a new Goto link. 240 | * 241 | * \param linkArea the active area of the link 242 | * \param extFileName if not empty, the file name to be open 243 | * \param destination the destination to be reached 244 | */ 245 | LinkGoto( const QRectF &linkArea, QString extFileName, const LinkDestination & destination ); 246 | /** 247 | * Destructor. 248 | */ 249 | ~LinkGoto(); 250 | 251 | /** 252 | * Whether the destination is in an external document 253 | * (i.e. not the current document) 254 | */ 255 | bool isExternal() const; 256 | // query for goto parameters 257 | /** 258 | * The file name of the document the destination() refers to, 259 | * or an empty string in case it refers to the current document. 260 | */ 261 | QString fileName() const; 262 | /** 263 | * The destination to reach. 264 | */ 265 | LinkDestination destination() const; 266 | LinkType linkType() const; 267 | 268 | private: 269 | Q_DECLARE_PRIVATE( LinkGoto ) 270 | Q_DISABLE_COPY( LinkGoto ) 271 | }; 272 | 273 | /** 274 | * \brief Generic execution request. 275 | * 276 | * The LinkExecute link represent a "file name" execution request. The result 277 | * depends on the \link fileName() file name\endlink: 278 | * - if it is a document, then it is requested to be open 279 | * - otherwise, it represents an executable to be run with the specified parameters 280 | */ 281 | class POPPLER_QT5_EXPORT LinkExecute : public Link 282 | { 283 | public: 284 | /** 285 | * The file name to be executed 286 | */ 287 | QString fileName() const; 288 | /** 289 | * The parameters for the command. 290 | */ 291 | QString parameters() const; 292 | 293 | /** 294 | * Create a new Execute link. 295 | * 296 | * \param linkArea the active area of the link 297 | * \param file the file name to be open, or the program to be execute 298 | * \param params the parameters for the program to execute 299 | */ 300 | LinkExecute( const QRectF &linkArea, const QString & file, const QString & params ); 301 | /** 302 | * Destructor. 303 | */ 304 | ~LinkExecute(); 305 | LinkType linkType() const; 306 | 307 | private: 308 | Q_DECLARE_PRIVATE( LinkExecute ) 309 | Q_DISABLE_COPY( LinkExecute ) 310 | }; 311 | 312 | /** 313 | * \brief An URL to browse. 314 | * 315 | * The LinkBrowse link holds a URL (eg 'http://poppler.freedesktop.org', 316 | * 'mailto:john@some.org', etc) to be open. 317 | * 318 | * The format of the URL is specified by RFC 2396 (http://www.ietf.org/rfc/rfc2396.txt) 319 | */ 320 | class POPPLER_QT5_EXPORT LinkBrowse : public Link 321 | { 322 | public: 323 | /** 324 | * The URL to open 325 | */ 326 | QString url() const; 327 | 328 | /** 329 | * Create a new browse link. 330 | * 331 | * \param linkArea the active area of the link 332 | * \param url the URL to be open 333 | */ 334 | LinkBrowse( const QRectF &linkArea, const QString &url ); 335 | /** 336 | * Destructor. 337 | */ 338 | ~LinkBrowse(); 339 | LinkType linkType() const; 340 | 341 | private: 342 | Q_DECLARE_PRIVATE( LinkBrowse ) 343 | Q_DISABLE_COPY( LinkBrowse ) 344 | }; 345 | 346 | /** 347 | * \brief "Standard" action request. 348 | * 349 | * The LinkAction class represents a link that request a "standard" action 350 | * to be performed by the viewer on the displayed document. 351 | */ 352 | class POPPLER_QT5_EXPORT LinkAction : public Link 353 | { 354 | public: 355 | /** 356 | * The possible types of actions 357 | */ 358 | enum ActionType { PageFirst = 1, 359 | PagePrev = 2, 360 | PageNext = 3, 361 | PageLast = 4, 362 | HistoryBack = 5, 363 | HistoryForward = 6, 364 | Quit = 7, 365 | Presentation = 8, 366 | EndPresentation = 9, 367 | Find = 10, 368 | GoToPage = 11, 369 | Close = 12, 370 | Print = 13 ///< \since 0.16 371 | }; 372 | 373 | /** 374 | * The action of the current LinkAction 375 | */ 376 | ActionType actionType() const; 377 | 378 | /** 379 | * Create a new Action link, that executes a specified action 380 | * on the document. 381 | * 382 | * \param linkArea the active area of the link 383 | * \param actionType which action should be executed 384 | */ 385 | LinkAction( const QRectF &linkArea, ActionType actionType ); 386 | /** 387 | * Destructor. 388 | */ 389 | ~LinkAction(); 390 | LinkType linkType() const; 391 | 392 | private: 393 | Q_DECLARE_PRIVATE( LinkAction ) 394 | Q_DISABLE_COPY( LinkAction ) 395 | }; 396 | 397 | /** 398 | * Sound: a sound to be played. 399 | * 400 | * \since 0.6 401 | */ 402 | class POPPLER_QT5_EXPORT LinkSound : public Link 403 | { 404 | public: 405 | // create a Link_Sound 406 | LinkSound( const QRectF &linkArea, double volume, bool sync, bool repeat, bool mix, SoundObject *sound ); 407 | /** 408 | * Destructor. 409 | */ 410 | virtual ~LinkSound(); 411 | 412 | LinkType linkType() const; 413 | 414 | /** 415 | * The volume to be used when playing the sound. 416 | * 417 | * The volume is in the range [ -1, 1 ], where: 418 | * - a negative number: no volume (mute) 419 | * - 1: full volume 420 | */ 421 | double volume() const; 422 | /** 423 | * Whether the playback of the sound should be synchronous 424 | * (thus blocking, waiting for the end of the sound playback). 425 | */ 426 | bool synchronous() const; 427 | /** 428 | * Whether the sound should be played continuously (that is, 429 | * started again when it ends) 430 | */ 431 | bool repeat() const; 432 | /** 433 | * Whether the playback of this sound can be mixed with 434 | * playbacks with other sounds of the same document. 435 | * 436 | * \note When false, any other playback must be stopped before 437 | * playing the sound. 438 | */ 439 | bool mix() const; 440 | /** 441 | * The sound object to be played 442 | */ 443 | SoundObject *sound() const; 444 | 445 | private: 446 | Q_DECLARE_PRIVATE( LinkSound ) 447 | Q_DISABLE_COPY( LinkSound ) 448 | }; 449 | 450 | /** 451 | * Rendition: Rendition link. 452 | * 453 | * \since 0.20 454 | */ 455 | class POPPLER_QT5_EXPORT LinkRendition : public Link 456 | { 457 | public: 458 | /** 459 | * Describes the possible rendition actions. 460 | * 461 | * \since 0.22 462 | */ 463 | enum RenditionAction { 464 | NoRendition, 465 | PlayRendition, 466 | StopRendition, 467 | PauseRendition, 468 | ResumeRendition 469 | }; 470 | 471 | /** 472 | * Create a new rendition link. 473 | * 474 | * \param linkArea the active area of the link 475 | * \param rendition the media rendition object. Ownership is taken 476 | * \param operation the numeric operation (action) (@see ::LinkRendition::RenditionOperation) 477 | * \param script the java script code 478 | * \param annotationReference the object reference of the screen annotation associated with this rendition action 479 | * \since 0.22 480 | */ 481 | LinkRendition( const QRectF &linkArea, ::MediaRendition *rendition, int operation, const QString &script, const Ref &annotationReference ); 482 | 483 | /** 484 | * Destructor. 485 | */ 486 | virtual ~LinkRendition(); 487 | 488 | LinkType linkType() const; 489 | 490 | /** 491 | * Returns the media rendition object if the redition provides one, @c 0 otherwise 492 | */ 493 | MediaRendition *rendition() const; 494 | 495 | /** 496 | * Returns the action that should be executed if a rendition object is provided. 497 | * 498 | * \since 0.22 499 | */ 500 | RenditionAction action() const; 501 | 502 | /** 503 | * The JS code that shall be executed or an empty string. 504 | * 505 | * \since 0.22 506 | */ 507 | QString script() const; 508 | 509 | /** 510 | * Returns whether the given @p annotation is the referenced screen annotation for this rendition @p link. 511 | * 512 | * \since 0.22 513 | */ 514 | bool isReferencedAnnotation( const ScreenAnnotation *annotation ) const; 515 | 516 | private: 517 | Q_DECLARE_PRIVATE( LinkRendition ) 518 | Q_DISABLE_COPY( LinkRendition ) 519 | }; 520 | 521 | /** 522 | * JavaScript: a JavaScript code to be interpreted. 523 | * 524 | * \since 0.10 525 | */ 526 | class POPPLER_QT5_EXPORT LinkJavaScript : public Link 527 | { 528 | public: 529 | /** 530 | * Create a new JavaScript link. 531 | * 532 | * \param linkArea the active area of the link 533 | * \param js the JS code to be interpreted 534 | */ 535 | LinkJavaScript( const QRectF &linkArea, const QString &js ); 536 | /** 537 | * Destructor. 538 | */ 539 | virtual ~LinkJavaScript(); 540 | 541 | LinkType linkType() const; 542 | 543 | /** 544 | * The JS code 545 | */ 546 | QString script() const; 547 | 548 | private: 549 | Q_DECLARE_PRIVATE( LinkJavaScript ) 550 | Q_DISABLE_COPY( LinkJavaScript ) 551 | }; 552 | 553 | /** 554 | * Movie: a movie to be played. 555 | * 556 | * \since 0.20 557 | */ 558 | class POPPLER_QT5_EXPORT LinkMovie : public Link 559 | { 560 | public: 561 | /** 562 | * Describes the operation to be performed on the movie. 563 | */ 564 | enum Operation { Play, 565 | Stop, 566 | Pause, 567 | Resume 568 | }; 569 | 570 | /** 571 | * Create a new Movie link. 572 | * 573 | * \param linkArea the active area of the link 574 | * \param operation the operation to be performed on the movie 575 | * \param annotationTitle the title of the movie annotation identifying the movie to be played 576 | * \param annotationReference the object reference of the movie annotation identifying the movie to be played 577 | * 578 | * Note: This constructor is supposed to be used by Poppler::Page only. 579 | */ 580 | LinkMovie( const QRectF &linkArea, Operation operation, const QString &annotationTitle, const Ref &annotationReference ); 581 | /** 582 | * Destructor. 583 | */ 584 | ~LinkMovie(); 585 | LinkType linkType() const; 586 | /** 587 | * Returns the operation to be performed on the movie. 588 | */ 589 | Operation operation() const; 590 | /** 591 | * Returns whether the given @p annotation is the referenced movie annotation for this movie @p link. 592 | */ 593 | bool isReferencedAnnotation( const MovieAnnotation *annotation ) const; 594 | 595 | private: 596 | Q_DECLARE_PRIVATE( LinkMovie ) 597 | Q_DISABLE_COPY( LinkMovie ) 598 | }; 599 | 600 | } 601 | 602 | #endif 603 | -------------------------------------------------------------------------------- /external_libs/poppler/include/poppler/qt5/poppler-media.h: -------------------------------------------------------------------------------- 1 | /* poppler-media.h: qt interface to poppler 2 | * Copyright (C) 2012 Guillermo A. Amaral B. 3 | * Copyright (C) 2012, 2013 Albert Astals Cid 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2, or (at your option) 8 | * any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef __POPPLER_MEDIARENDITION_H__ 21 | #define __POPPLER_MEDIARENDITION_H__ 22 | 23 | #include "poppler-export.h" 24 | 25 | #include 26 | #include 27 | 28 | class MediaRendition; 29 | class QIODevice; 30 | 31 | namespace Poppler 32 | { 33 | class MediaRenditionPrivate; 34 | 35 | /** 36 | Qt wrapper for MediaRendition. 37 | 38 | \since 0.20 39 | */ 40 | class POPPLER_QT5_EXPORT MediaRendition { 41 | public: 42 | /** 43 | Constructs a MediaRendition. Takes ownership of the passed rendition 44 | */ 45 | MediaRendition(::MediaRendition *rendition); 46 | ~MediaRendition(); 47 | 48 | /** 49 | Check if wrapper is holding a valid rendition object. 50 | */ 51 | bool isValid() const; 52 | 53 | /** 54 | Returns content type. 55 | */ 56 | QString contentType() const; 57 | 58 | /** 59 | Returns file name. 60 | */ 61 | QString fileName() const; 62 | 63 | /** 64 | Returns true if media is embedded. 65 | */ 66 | bool isEmbedded() const; 67 | 68 | /** 69 | Returns data buffer. 70 | */ 71 | QByteArray data() const; 72 | 73 | /** 74 | Convenience accessor for auto-play parameter. 75 | */ 76 | bool autoPlay() const; 77 | 78 | /** 79 | Convenience accessor for show controls parameter. 80 | */ 81 | bool showControls() const; 82 | 83 | /** 84 | Convenience accessor for repeat count parameter. 85 | */ 86 | float repeatCount() const; 87 | 88 | /** 89 | Convenience accessor for size parameter. 90 | */ 91 | QSize size() const; 92 | 93 | private: 94 | Q_DECLARE_PRIVATE( MediaRendition ) 95 | MediaRenditionPrivate *d_ptr; 96 | Q_DISABLE_COPY( MediaRendition ) 97 | }; 98 | } 99 | 100 | #endif /* __POPPLER_MEDIARENDITION_H__ */ 101 | -------------------------------------------------------------------------------- /external_libs/poppler/include/poppler/qt5/poppler-optcontent.h: -------------------------------------------------------------------------------- 1 | /* poppler-optcontent.h: qt interface to poppler 2 | * 3 | * Copyright (C) 2007, Brad Hards 4 | * Copyright (C) 2008, Pino Toscano 5 | * Copyright (C) 2013, Anthony Granger 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2, or (at your option) 10 | * any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef POPPLER_OPTCONTENT_H 23 | #define POPPLER_OPTCONTENT_H 24 | 25 | #include 26 | 27 | #include "poppler-export.h" 28 | 29 | class OCGs; 30 | 31 | namespace Poppler 32 | { 33 | class Document; 34 | class OptContentModelPrivate; 35 | 36 | /** 37 | * \brief Model for optional content 38 | * 39 | * OptContentModel is an item model representing the optional content items 40 | * that can be found in PDF documents. 41 | * 42 | * The model offers a mostly read-only display of the data, allowing to 43 | * enable/disable some contents setting the Qt::CheckStateRole data role. 44 | * 45 | * \since 0.8 46 | */ 47 | class POPPLER_QT5_EXPORT OptContentModel : public QAbstractItemModel 48 | { 49 | friend class Document; 50 | 51 | Q_OBJECT 52 | 53 | public: 54 | virtual ~OptContentModel(); 55 | 56 | QModelIndex index(int row, int column, const QModelIndex &parent) const; 57 | QModelIndex parent(const QModelIndex &child) const; 58 | 59 | int rowCount(const QModelIndex &parent = QModelIndex()) const; 60 | int columnCount(const QModelIndex &parent) const; 61 | 62 | QVariant data(const QModelIndex &index, int role) const; 63 | virtual bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); 64 | 65 | Qt::ItemFlags flags ( const QModelIndex & index ) const; 66 | 67 | virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; 68 | 69 | private: 70 | OptContentModel( OCGs *optContent, QObject *parent = 0); 71 | 72 | friend class OptContentModelPrivate; 73 | OptContentModelPrivate *d; 74 | }; 75 | } 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /external_libs/poppler/include/poppler/qt5/poppler-page-transition.h: -------------------------------------------------------------------------------- 1 | /* PageTransition.h 2 | * Copyright (C) 2005, Net Integration Technologies, Inc. 3 | * Copyright (C) 2005, Brad Hards 4 | * Copyright (C) 2015, Arseniy Lartsev 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2, or (at your option) 9 | * any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifndef __PAGETRANSITION_X_H__ 22 | #define __PAGETRANSITION_X_H__ 23 | 24 | #include "poppler-export.h" 25 | 26 | #include 27 | 28 | namespace Poppler { 29 | 30 | class PageTransitionParams; 31 | class PageTransitionData; 32 | 33 | /** 34 | \brief Describes how a PDF file viewer shall perform the transition 35 | from one page to another 36 | 37 | In PDF files there is a way to specify if the viewer shall use 38 | certain effects to perform the transition from one page to 39 | another. This feature can be used, e.g., in a PDF-based beamer 40 | presentation. 41 | 42 | This utility class represents the transition effect, and can be 43 | used to extract the information from a PDF object. 44 | */ 45 | 46 | 47 | class POPPLER_QT5_EXPORT PageTransition { 48 | public: 49 | 50 | /** \brief transition effect that shall be used 51 | */ 52 | // if changed remember to keep in sync with PageTransition.h enum 53 | enum Type { 54 | Replace = 0, 55 | Split, 56 | Blinds, 57 | Box, 58 | Wipe, 59 | Dissolve, 60 | Glitter, 61 | Fly, 62 | Push, 63 | Cover, 64 | Uncover, 65 | Fade 66 | }; 67 | 68 | /** \brief alignment of the transition effect that shall be used 69 | */ 70 | // if changed remember to keep in sync with PageTransition.h enum 71 | enum Alignment { 72 | Horizontal = 0, 73 | Vertical 74 | }; 75 | 76 | /** \brief direction of the transition effect that shall be used 77 | */ 78 | // if changed remember to keep in sync with PageTransition.h enum 79 | enum Direction { 80 | Inward = 0, 81 | Outward 82 | }; 83 | 84 | /** \brief Construct a new PageTransition object from a page dictionary. 85 | 86 | Users of the library will rarely need to construct a 87 | PageTransition object themselves. Instead, the method 88 | Poppler::Page::transition() can be used to find out if a certain 89 | transition effect is specified. 90 | 91 | @warning In case or error, this method will print an error message to stderr, 92 | and construct a default object. 93 | 94 | @param params an object whose dictionary will be read and 95 | parsed. This must be a valid object, whose dictionaries are 96 | accessed by the constructor. The object is only accessed by this 97 | constructor, and may be deleted after the constructor returns. 98 | */ 99 | PageTransition(const PageTransitionParams ¶ms); 100 | 101 | /** \brief copy constructor */ 102 | PageTransition(const PageTransition &pt); 103 | 104 | /** 105 | Destructor 106 | */ 107 | ~PageTransition(); 108 | 109 | /** 110 | \brief Get type of the transition. 111 | */ 112 | Type type() const; 113 | 114 | /** 115 | \brief Get duration of the transition in seconds as integer 116 | 117 | \deprecated This function is left for backward compatibility, use durationReal() instead. 118 | */ 119 | Q_DECL_DEPRECATED int duration() const; 120 | 121 | /** 122 | \brief Get duration of the transition in seconds 123 | */ 124 | double durationReal() const; 125 | 126 | /** 127 | \brief Get dimension in which the transition effect occurs. 128 | */ 129 | Alignment alignment() const; 130 | 131 | /** 132 | \brief Get direction of motion of the transition effect. 133 | */ 134 | Direction direction() const; 135 | 136 | /** 137 | \brief Get direction in which the transition effect moves. 138 | */ 139 | int angle() const; 140 | 141 | /** 142 | \brief Get starting or ending scale. 143 | */ 144 | double scale() const; 145 | 146 | /** 147 | \brief Returns true if the area to be flown is rectangular and 148 | opaque. 149 | */ 150 | bool isRectangular() const; 151 | 152 | private: 153 | PageTransitionData *data; 154 | }; 155 | 156 | } 157 | 158 | #endif 159 | -------------------------------------------------------------------------------- /external_libs/poppler/include/poppler/qt5/poppler-qt5.h: -------------------------------------------------------------------------------- 1 | /* poppler-qt.h: qt interface to poppler 2 | * Copyright (C) 2005, Net Integration Technologies, Inc. 3 | * Copyright (C) 2005, 2007, Brad Hards 4 | * Copyright (C) 2005-2015, Albert Astals Cid 5 | * Copyright (C) 2005, Stefan Kebekus 6 | * Copyright (C) 2006-2011, Pino Toscano 7 | * Copyright (C) 2009 Shawn Rutledge 8 | * Copyright (C) 2010 Suzuki Toshiya 9 | * Copyright (C) 2010 Matthias Fauconneau 10 | * Copyright (C) 2011 Andreas Hartmetz 11 | * Copyright (C) 2011 Glad Deschrijver 12 | * Copyright (C) 2012, Guillermo A. Amaral B. 13 | * Copyright (C) 2012, Fabio D'Urso 14 | * Copyright (C) 2012, Tobias Koenig 15 | * Copyright (C) 2012, 2014, 2015 Adam Reichold 16 | * Copyright (C) 2012, 2013 Thomas Freitag 17 | * Copyright (C) 2013 Anthony Granger 18 | * 19 | * This program is free software; you can redistribute it and/or modify 20 | * it under the terms of the GNU General Public License as published by 21 | * the Free Software Foundation; either version 2, or (at your option) 22 | * any later version. 23 | * 24 | * This program is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | * GNU General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU General Public License 30 | * along with this program; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 32 | */ 33 | 34 | #ifndef __POPPLER_QT_H__ 35 | #define __POPPLER_QT_H__ 36 | 37 | #include "poppler-annotation.h" 38 | #include "poppler-link.h" 39 | #include "poppler-optcontent.h" 40 | #include "poppler-page-transition.h" 41 | 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include "poppler-export.h" 47 | 48 | class EmbFile; 49 | class Sound; 50 | class AnnotMovie; 51 | 52 | /** 53 | The %Poppler Qt5 binding. 54 | */ 55 | namespace Poppler { 56 | 57 | class Document; 58 | class DocumentData; 59 | 60 | class PageData; 61 | 62 | class FormField; 63 | 64 | class TextBoxData; 65 | 66 | class PDFConverter; 67 | class PSConverter; 68 | 69 | /** 70 | Debug/error function. 71 | 72 | This function type is used for debugging & error output; 73 | the first parameter is the actual message, the second is the unaltered 74 | closure argument which was passed to the setDebugErrorFunction call. 75 | 76 | \since 0.16 77 | */ 78 | typedef void (*PopplerDebugFunc)(const QString & /*message*/, const QVariant & /*closure*/); 79 | 80 | /** 81 | Set a new debug/error output function. 82 | 83 | If not set, by default error and debug messages will be sent to the 84 | Qt \p qDebug() function. 85 | 86 | \param debugFunction the new debug function 87 | \param closure user data which will be passes as-is to the debug function 88 | 89 | \since 0.16 90 | */ 91 | POPPLER_QT5_EXPORT void setDebugErrorFunction(PopplerDebugFunc debugFunction, const QVariant &closure); 92 | 93 | /** 94 | Describes the physical location of text on a document page 95 | 96 | This very simple class describes the physical location of text 97 | on the page. It consists of 98 | - a QString that contains the text 99 | - a QRectF that gives a box that describes where on the page 100 | the text is found. 101 | */ 102 | class POPPLER_QT5_EXPORT TextBox { 103 | friend class Page; 104 | public: 105 | /** 106 | The default constructor sets the \p text and the rectangle that 107 | contains the text. Coordinates for the \p bBox are in points = 108 | 1/72 of an inch. 109 | */ 110 | TextBox(const QString& text, const QRectF &bBox); 111 | /** 112 | Destructor. 113 | */ 114 | ~TextBox(); 115 | 116 | /** 117 | Returns the text of this text box 118 | */ 119 | QString text() const; 120 | 121 | /** 122 | Returns the position of the text, in point, i.e., 1/72 of 123 | an inch 124 | 125 | \since 0.8 126 | */ 127 | QRectF boundingBox() const; 128 | 129 | /** 130 | Returns the pointer to the next text box, if there is one. 131 | 132 | Otherwise, it returns a null pointer. 133 | */ 134 | TextBox *nextWord() const; 135 | 136 | /** 137 | Returns the bounding box of the \p i -th characted of the word. 138 | */ 139 | QRectF charBoundingBox(int i) const; 140 | 141 | /** 142 | Returns whether there is a space character after this text box 143 | */ 144 | bool hasSpaceAfter() const; 145 | 146 | private: 147 | Q_DISABLE_COPY(TextBox) 148 | 149 | TextBoxData *m_data; 150 | }; 151 | 152 | 153 | class FontInfoData; 154 | /** 155 | Container class for information about a font within a PDF 156 | document 157 | */ 158 | class POPPLER_QT5_EXPORT FontInfo { 159 | friend class Document; 160 | public: 161 | /** 162 | The type of font. 163 | */ 164 | enum Type { 165 | unknown, 166 | Type1, 167 | Type1C, 168 | Type1COT, 169 | Type3, 170 | TrueType, 171 | TrueTypeOT, 172 | CIDType0, 173 | CIDType0C, 174 | CIDType0COT, 175 | CIDTrueType, 176 | CIDTrueTypeOT 177 | }; 178 | 179 | /// \cond PRIVATE 180 | /** 181 | Create a new font information container. 182 | */ 183 | FontInfo(); 184 | 185 | /** 186 | Create a new font information container. 187 | */ 188 | FontInfo( const FontInfoData &fid ); 189 | /// \endcond 190 | 191 | /** 192 | Copy constructor. 193 | */ 194 | FontInfo( const FontInfo &fi ); 195 | 196 | /** 197 | Destructor. 198 | */ 199 | ~FontInfo(); 200 | 201 | /** 202 | The name of the font. Can be QString::null if the font has no name 203 | */ 204 | QString name() const; 205 | 206 | /** 207 | The path of the font file used to represent this font on this system, 208 | or a null string is the font is embedded 209 | */ 210 | QString file() const; 211 | 212 | /** 213 | Whether the font is embedded in the file, or not 214 | 215 | \return true if the font is embedded 216 | */ 217 | bool isEmbedded() const; 218 | 219 | /** 220 | Whether the font provided is only a subset of the full 221 | font or not. This only has meaning if the font is embedded. 222 | 223 | \return true if the font is only a subset 224 | */ 225 | bool isSubset() const; 226 | 227 | /** 228 | The type of font encoding 229 | 230 | \return a enumerated value corresponding to the font encoding used 231 | 232 | \sa typeName for a string equivalent 233 | */ 234 | Type type() const; 235 | 236 | /** 237 | The name of the font encoding used 238 | 239 | \note if you are looking for the name of the font (as opposed to the 240 | encoding format used), you probably want name(). 241 | 242 | \sa type for a enumeration version 243 | */ 244 | QString typeName() const; 245 | 246 | /** 247 | Standard assignment operator 248 | */ 249 | FontInfo& operator=( const FontInfo &fi ); 250 | 251 | private: 252 | FontInfoData *m_data; 253 | }; 254 | 255 | 256 | class FontIteratorData; 257 | /** 258 | Iterator for reading the fonts in a document. 259 | 260 | FontIterator provides a Java-style iterator for reading the fonts in a 261 | document. 262 | 263 | You can use it in the following way: 264 | \code 265 | Poppler::FontIterator* it = doc->newFontIterator(); 266 | while (it->hasNext()) { 267 | QList fonts = it->next(); 268 | // do something with the fonts 269 | } 270 | // after doing the job, the iterator must be freed 271 | delete it; 272 | \endcode 273 | 274 | \since 0.12 275 | */ 276 | class POPPLER_QT5_EXPORT FontIterator { 277 | friend class Document; 278 | friend class DocumentData; 279 | public: 280 | /** 281 | Destructor. 282 | */ 283 | ~FontIterator(); 284 | 285 | /** 286 | Returns the fonts of the current page and then advances the iterator 287 | to the next page. 288 | */ 289 | QList next(); 290 | 291 | /** 292 | Checks whether there is at least one more page to iterate, ie returns 293 | false when the iterator is beyond the last page. 294 | */ 295 | bool hasNext() const; 296 | 297 | /** 298 | Returns the current page where the iterator is. 299 | */ 300 | int currentPage() const; 301 | 302 | private: 303 | Q_DISABLE_COPY( FontIterator ) 304 | FontIterator( int, DocumentData *dd ); 305 | 306 | FontIteratorData *d; 307 | }; 308 | 309 | 310 | class EmbeddedFileData; 311 | /** 312 | Container class for an embedded file with a PDF document 313 | */ 314 | class POPPLER_QT5_EXPORT EmbeddedFile { 315 | friend class DocumentData; 316 | friend class AnnotationPrivate; 317 | public: 318 | /// \cond PRIVATE 319 | EmbeddedFile(EmbFile *embfile); 320 | /// \endcond 321 | 322 | /** 323 | Destructor. 324 | */ 325 | ~EmbeddedFile(); 326 | 327 | /** 328 | The name associated with the file 329 | */ 330 | QString name() const; 331 | 332 | /** 333 | The description associated with the file, if any. 334 | 335 | This will return an empty QString if there is no description element 336 | */ 337 | QString description() const; 338 | 339 | /** 340 | The size of the file. 341 | 342 | This will return < 0 if there is no size element 343 | */ 344 | int size() const; 345 | 346 | /** 347 | The modification date for the embedded file, if known. 348 | */ 349 | QDateTime modDate() const; 350 | 351 | /** 352 | The creation date for the embedded file, if known. 353 | */ 354 | QDateTime createDate() const; 355 | 356 | /** 357 | The MD5 checksum of the file. 358 | 359 | This will return an empty QByteArray if there is no checksum element. 360 | */ 361 | QByteArray checksum() const; 362 | 363 | /** 364 | The MIME type of the file, if known. 365 | 366 | \since 0.8 367 | */ 368 | QString mimeType() const; 369 | 370 | /** 371 | The data as a byte array 372 | */ 373 | QByteArray data(); 374 | 375 | /** 376 | Is the embedded file valid? 377 | 378 | \since 0.12 379 | */ 380 | bool isValid() const; 381 | 382 | /** 383 | A QDataStream for the actual data? 384 | */ 385 | //QDataStream dataStream() const; 386 | 387 | private: 388 | Q_DISABLE_COPY(EmbeddedFile) 389 | EmbeddedFile(EmbeddedFileData &dd); 390 | 391 | EmbeddedFileData *m_embeddedFile; 392 | }; 393 | 394 | 395 | /** 396 | \brief A page in a document. 397 | 398 | The Page class represents a single page within a PDF document. 399 | 400 | You cannot construct a Page directly, but you have to use the Document 401 | functions that return a new Page out of an index or a label. 402 | */ 403 | class POPPLER_QT5_EXPORT Page { 404 | friend class Document; 405 | public: 406 | /** 407 | Destructor. 408 | */ 409 | ~Page(); 410 | 411 | /** 412 | The type of rotation to apply for an operation 413 | */ 414 | enum Rotation { Rotate0 = 0, ///< Do not rotate 415 | Rotate90 = 1, ///< Rotate 90 degrees clockwise 416 | Rotate180 = 2, ///< Rotate 180 degrees 417 | Rotate270 = 3 ///< Rotate 270 degrees clockwise (90 degrees counterclockwise) 418 | }; 419 | 420 | /** 421 | The kinds of page actions 422 | */ 423 | enum PageAction { 424 | Opening, ///< The action when a page is "opened" 425 | Closing ///< The action when a page is "closed" 426 | }; 427 | 428 | /** 429 | How the text is going to be returned 430 | \since 0.16 431 | */ 432 | enum TextLayout { 433 | PhysicalLayout, ///< The text is layouted to resemble the real page layout 434 | RawOrderLayout ///< The text is returned without any type of processing 435 | }; 436 | 437 | /** 438 | Additional flags for the renderToPainter method 439 | \since 0.16 440 | */ 441 | enum PainterFlag { 442 | /** 443 | Do not save/restore the caller-owned painter. 444 | 445 | renderToPainter() by default preserves, using save() + restore(), 446 | the state of the painter specified; if this is not needed, this 447 | flag can avoid this job 448 | */ 449 | DontSaveAndRestore = 0x00000001 450 | }; 451 | Q_DECLARE_FLAGS( PainterFlags, PainterFlag ) 452 | 453 | /** 454 | Render the page to a QImage using the current 455 | \link Document::renderBackend() Document renderer\endlink. 456 | 457 | If \p x = \p y = \p w = \p h = -1, the method will automatically 458 | compute the size of the image from the horizontal and vertical 459 | resolutions specified in \p xres and \p yres. Otherwise, the 460 | method renders only a part of the page, specified by the 461 | parameters (\p x, \p y, \p w, \p h) in pixel coordinates. The returned 462 | QImage then has size (\p w, \p h), independent of the page 463 | size. 464 | 465 | \param x specifies the left x-coordinate of the box, in 466 | pixels. 467 | 468 | \param y specifies the top y-coordinate of the box, in 469 | pixels. 470 | 471 | \param w specifies the width of the box, in pixels. 472 | 473 | \param h specifies the height of the box, in pixels. 474 | 475 | \param xres horizontal resolution of the graphics device, 476 | in dots per inch 477 | 478 | \param yres vertical resolution of the graphics device, in 479 | dots per inch 480 | 481 | \param rotate how to rotate the page 482 | 483 | \warning The parameter (\p x, \p y, \p w, \p h) are not 484 | well-tested. Unusual or meaningless parameters may lead to 485 | rather unexpected results. 486 | 487 | \returns a QImage of the page, or a null image on failure. 488 | 489 | \since 0.6 490 | */ 491 | QImage renderToImage(double xres=72.0, double yres=72.0, int x=-1, int y=-1, int w=-1, int h=-1, Rotation rotate = Rotate0) const; 492 | 493 | /** 494 | Render the page to the specified QPainter using the current 495 | \link Document::renderBackend() Document renderer\endlink. 496 | 497 | If \p x = \p y = \p w = \p h = -1, the method will automatically 498 | compute the size of the page area from the horizontal and vertical 499 | resolutions specified in \p xres and \p yres. Otherwise, the 500 | method renders only a part of the page, specified by the 501 | parameters (\p x, \p y, \p w, \p h) in pixel coordinates. 502 | 503 | \param painter the painter to paint on 504 | 505 | \param x specifies the left x-coordinate of the box, in 506 | pixels. 507 | 508 | \param y specifies the top y-coordinate of the box, in 509 | pixels. 510 | 511 | \param w specifies the width of the box, in pixels. 512 | 513 | \param h specifies the height of the box, in pixels. 514 | 515 | \param xres horizontal resolution of the graphics device, 516 | in dots per inch 517 | 518 | \param yres vertical resolution of the graphics device, in 519 | dots per inch 520 | 521 | \param rotate how to rotate the page 522 | 523 | \param flags additional painter flags 524 | 525 | \warning The parameter (\p x, \p y, \p w, \p h) are not 526 | well-tested. Unusual or meaningless parameters may lead to 527 | rather unexpected results. 528 | 529 | \returns whether the painting succeeded 530 | 531 | \note This method is only supported for Arthur 532 | 533 | \since 0.16 534 | */ 535 | bool renderToPainter(QPainter* painter, double xres=72.0, double yres=72.0, int x=-1, int y=-1, int w=-1, int h=-1, 536 | Rotation rotate = Rotate0, PainterFlags flags = 0) const; 537 | 538 | /** 539 | Get the page thumbnail if it exists. 540 | 541 | \return a QImage of the thumbnail, or a null image 542 | if the PDF does not contain one for this page 543 | 544 | \since 0.12 545 | */ 546 | QImage thumbnail() const; 547 | 548 | /** 549 | Returns the text that is inside a specified rectangle 550 | 551 | \param rect the rectangle specifying the area of interest, 552 | with coordinates given in points, i.e., 1/72th of an inch. 553 | If rect is null, all text on the page is given 554 | 555 | \since 0.16 556 | **/ 557 | QString text(const QRectF &rect, TextLayout textLayout) const; 558 | 559 | /** 560 | Returns the text that is inside a specified rectangle. 561 | The text is returned using the physical layout of the page 562 | 563 | \param rect the rectangle specifying the area of interest, 564 | with coordinates given in points, i.e., 1/72th of an inch. 565 | If rect is null, all text on the page is given 566 | **/ 567 | QString text(const QRectF &rect) const; 568 | 569 | /** 570 | The starting point for a search 571 | */ 572 | enum SearchDirection { FromTop, ///< Start sorting at the top of the document 573 | NextResult, ///< Find the next result, moving "down the page" 574 | PreviousResult ///< Find the previous result, moving "up the page" 575 | }; 576 | 577 | /** 578 | The type of search to perform 579 | */ 580 | enum SearchMode { CaseSensitive, ///< Case differences cause no match in searching 581 | CaseInsensitive ///< Case differences are ignored in matching 582 | }; 583 | 584 | /** 585 | Flags to modify the search behaviour \since 0.31 586 | */ 587 | enum SearchFlag 588 | { 589 | IgnoreCase = 0x00000001, ///< Case differences are ignored 590 | WholeWords = 0x00000002 ///< Only whole words are matched 591 | }; 592 | Q_DECLARE_FLAGS( SearchFlags, SearchFlag ) 593 | 594 | /** 595 | Returns true if the specified text was found. 596 | 597 | \param text the text the search 598 | \param rectXXX in all directions is used to return where the text was found, for NextResult and PreviousResult 599 | indicates where to continue searching for 600 | \param direction in which direction do the search 601 | \param caseSensitive be case sensitive? 602 | \param rotate the rotation to apply for the search order 603 | \since 0.14 604 | **/ 605 | Q_DECL_DEPRECATED bool search(const QString &text, double &rectLeft, double &rectTop, double &rectRight, double &rectBottom, SearchDirection direction, SearchMode caseSensitive, Rotation rotate = Rotate0) const; 606 | 607 | /** 608 | Returns true if the specified text was found. 609 | 610 | \param text the text the search 611 | \param rectXXX in all directions is used to return where the text was found, for NextResult and PreviousResult 612 | indicates where to continue searching for 613 | \param direction in which direction do the search 614 | \param flags the flags to consider during matching 615 | \param rotate the rotation to apply for the search order 616 | 617 | \since 0.31 618 | **/ 619 | bool search(const QString &text, double &rectLeft, double &rectTop, double &rectRight, double &rectBottom, SearchDirection direction, SearchFlags flags = 0, Rotation rotate = Rotate0) const; 620 | 621 | /** 622 | Returns a list of all occurrences of the specified text on the page. 623 | 624 | \param text the text to search 625 | \param caseSensitive whether to be case sensitive 626 | \param rotate the rotation to apply for the search order 627 | 628 | \warning Do not use the returned QRectF as arguments of another search call because of truncation issues if qreal is defined as float. 629 | 630 | \since 0.22 631 | **/ 632 | Q_DECL_DEPRECATED QList search(const QString &text, SearchMode caseSensitive, Rotation rotate = Rotate0) const; 633 | 634 | /** 635 | Returns a list of all occurrences of the specified text on the page. 636 | 637 | \param text the text to search 638 | \param flags the flags to consider during matching 639 | \param rotate the rotation to apply for the search order 640 | 641 | \warning Do not use the returned QRectF as arguments of another search call because of truncation issues if qreal is defined as float. 642 | 643 | \since 0.31 644 | **/ 645 | QList search(const QString &text, SearchFlags flags = 0, Rotation rotate = Rotate0) const; 646 | 647 | /** 648 | Returns a list of text of the page 649 | 650 | This method returns a QList of TextBoxes that contain all 651 | the text of the page, with roughly one text word of text 652 | per TextBox item. 653 | 654 | For text written in western languages (left-to-right and 655 | up-to-down), the QList contains the text in the proper 656 | order. 657 | 658 | \note The caller owns the text boxes and they should 659 | be deleted when no longer required. 660 | 661 | \warning This method is not tested with Asian scripts 662 | */ 663 | QList textList(Rotation rotate = Rotate0) const; 664 | 665 | /** 666 | \return The dimensions (cropbox) of the page, in points (i.e. 1/72th of an inch) 667 | */ 668 | QSizeF pageSizeF() const; 669 | 670 | /** 671 | \return The dimensions (cropbox) of the page, in points (i.e. 1/72th of an inch) 672 | */ 673 | QSize pageSize() const; 674 | 675 | /** 676 | Returns the transition of this page 677 | 678 | \returns a pointer to a PageTransition structure that 679 | defines how transition to this page shall be performed. 680 | 681 | \note The PageTransition structure is owned by this page, and will 682 | automatically be destroyed when this page class is 683 | destroyed. 684 | **/ 685 | PageTransition *transition() const; 686 | 687 | /** 688 | Gets the page action specified, or NULL if there is no action. 689 | 690 | \since 0.6 691 | **/ 692 | Link *action( PageAction act ) const; 693 | 694 | /** 695 | Types of orientations that are possible 696 | */ 697 | enum Orientation { 698 | Landscape, ///< Landscape orientation (portrait, with 90 degrees clockwise rotation ) 699 | Portrait, ///< Normal portrait orientation 700 | Seascape, ///< Seascape orientation (portrait, with 270 degrees clockwise rotation) 701 | UpsideDown ///< Upside down orientation (portrait, with 180 degrees rotation) 702 | }; 703 | 704 | /** 705 | The orientation of the page 706 | */ 707 | Orientation orientation() const; 708 | 709 | /** 710 | The default CTM 711 | */ 712 | void defaultCTM(double *CTM, double dpiX, double dpiY, int rotate, bool upsideDown); 713 | 714 | /** 715 | Gets the links of the page 716 | */ 717 | QList links() const; 718 | 719 | /** 720 | Returns the annotations of the page 721 | 722 | \note If you call this method twice, you get different objects 723 | pointing to the same annotations (see Annotation). 724 | The caller owns the returned objects and they should be deleted 725 | when no longer required. 726 | */ 727 | QList annotations() const; 728 | 729 | 730 | /** 731 | Returns the annotations of the page 732 | 733 | \param subtypes the subtypes of annotations you are interested in 734 | 735 | \note If you call this method twice, you get different objects 736 | pointing to the same annotations (see Annotation). 737 | The caller owns the returned objects and they should be deleted 738 | when no longer required. 739 | 740 | \since 0.28 741 | */ 742 | QList annotations(const QSet &subtypes) const; 743 | 744 | /** 745 | Adds an annotation to the page 746 | 747 | \note Ownership of the annotation object stays with the caller, who can 748 | delete it at any time. 749 | \since 0.20 750 | */ 751 | void addAnnotation( const Annotation *ann ); 752 | 753 | /** 754 | Removes an annotation from the page and destroys the annotation object 755 | 756 | \note There mustn't be other Annotation objects pointing this annotation 757 | \since 0.20 758 | */ 759 | void removeAnnotation( const Annotation *ann ); 760 | 761 | /** 762 | Returns the form fields on the page 763 | The caller gets the ownership of the returned objects. 764 | 765 | \since 0.6 766 | */ 767 | QList formFields() const; 768 | 769 | /** 770 | Returns the page duration. That is the time, in seconds, that the page 771 | should be displayed before the presentation automatically advances to the next page. 772 | Returns < 0 if duration is not set. 773 | 774 | \since 0.6 775 | */ 776 | double duration() const; 777 | 778 | /** 779 | Returns the label of the page, or a null string is the page has no label. 780 | 781 | \since 0.6 782 | **/ 783 | QString label() const; 784 | 785 | private: 786 | Q_DISABLE_COPY(Page) 787 | 788 | Page(DocumentData *doc, int index); 789 | PageData *m_page; 790 | }; 791 | 792 | /** 793 | \brief PDF document. 794 | 795 | The Document class represents a PDF document: its pages, and all the global 796 | properties, metadata, etc. 797 | 798 | \section ownership Ownership of the returned objects 799 | 800 | All the functions that returns class pointers create new object, and the 801 | responsability of those is given to the callee. 802 | 803 | The only exception is \link Poppler::Page::transition() Page::transition()\endlink. 804 | 805 | \section document-loading Loading 806 | 807 | To get a Document, you have to load it via the load() & loadFromData() 808 | functions. 809 | 810 | In all the functions that have passwords as arguments, they \b must be Latin1 811 | encoded. If you have a password that is a UTF-8 string, you need to use 812 | QString::toLatin1() (or similar) to convert the password first. 813 | If you have a UTF-8 character array, consider converting it to a QString first 814 | (QString::fromUtf8(), or similar) before converting to Latin1 encoding. 815 | 816 | \section document-rendering Rendering 817 | 818 | To render pages of a document, you have different Document functions to set 819 | various options. 820 | 821 | \subsection document-rendering-backend Backends 822 | 823 | %Poppler offers a different backends for rendering the pages. Currently 824 | there are two backends (see #RenderBackend), but only the Splash engine works 825 | well and has been tested. 826 | 827 | The available rendering backends can be discovered via availableRenderBackends(). 828 | The current rendering backend can be changed using setRenderBackend(). 829 | Please note that setting a backend not listed in the available ones 830 | will always result in null QImage's. 831 | 832 | \section document-cms Color management support 833 | 834 | %Poppler, if compiled with this support, provides functions to handle color 835 | profiles. 836 | 837 | To know whether the %Poppler version you are using has support for color 838 | management, you can query Poppler::isCmsAvailable(). In case it is not 839 | avilable, all the color management-related functions will either do nothing 840 | or return null. 841 | */ 842 | class POPPLER_QT5_EXPORT Document { 843 | friend class Page; 844 | friend class DocumentData; 845 | 846 | public: 847 | /** 848 | The page mode 849 | */ 850 | enum PageMode { 851 | UseNone, ///< No mode - neither document outline nor thumbnail images are visible 852 | UseOutlines, ///< Document outline visible 853 | UseThumbs, ///< Thumbnail images visible 854 | FullScreen, ///< Fullscreen mode (no menubar, windows controls etc) 855 | UseOC, ///< Optional content group panel visible 856 | UseAttach ///< Attachments panel visible 857 | }; 858 | 859 | /** 860 | The page layout 861 | */ 862 | enum PageLayout { 863 | NoLayout, ///< Layout not specified 864 | SinglePage, ///< Display a single page 865 | OneColumn, ///< Display a single column of pages 866 | TwoColumnLeft, ///< Display the pages in two columns, with odd-numbered pages on the left 867 | TwoColumnRight, ///< Display the pages in two columns, with odd-numbered pages on the right 868 | TwoPageLeft, ///< Display the pages two at a time, with odd-numbered pages on the left 869 | TwoPageRight ///< Display the pages two at a time, with odd-numbered pages on the right 870 | }; 871 | 872 | /** 873 | The render backends available 874 | 875 | \since 0.6 876 | */ 877 | enum RenderBackend { 878 | SplashBackend, ///< Splash backend 879 | ArthurBackend ///< Arthur (Qt) backend 880 | }; 881 | 882 | /** 883 | The render hints available 884 | 885 | \since 0.6 886 | */ 887 | enum RenderHint { 888 | Antialiasing = 0x00000001, ///< Antialiasing for graphics 889 | TextAntialiasing = 0x00000002, ///< Antialiasing for text 890 | TextHinting = 0x00000004, ///< Hinting for text \since 0.12.1 891 | TextSlightHinting = 0x00000008, ///< Lighter hinting for text when combined with TextHinting \since 0.18 892 | OverprintPreview = 0x00000010, ///< Overprint preview \since 0.22 893 | ThinLineSolid = 0x00000020, ///< Enhance thin lines solid \since 0.24 894 | ThinLineShape = 0x00000040, ///< Enhance thin lines shape. Wins over ThinLineSolid \since 0.24 895 | IgnorePaperColor = 0x00000080 ///< Do not compose with the paper color \since 0.35 896 | }; 897 | Q_DECLARE_FLAGS( RenderHints, RenderHint ) 898 | 899 | /** 900 | Form types 901 | 902 | \since 0.22 903 | */ 904 | enum FormType { 905 | NoForm, ///< Document doesn't contain forms 906 | AcroForm, ///< AcroForm 907 | XfaForm ///< Adobe XML Forms Architecture (XFA), currently unsupported 908 | }; 909 | 910 | /** 911 | Set a color display profile for the current document. 912 | 913 | \param outputProfileA is a \c cmsHPROFILE of the LCMS library. 914 | 915 | \since 0.12 916 | */ 917 | void setColorDisplayProfile(void *outputProfileA); 918 | /** 919 | Set a color display profile for the current document. 920 | 921 | \param name is the name of the display profile to set. 922 | 923 | \since 0.12 924 | */ 925 | void setColorDisplayProfileName(const QString &name); 926 | /** 927 | Return the current RGB profile. 928 | 929 | \return a \c cmsHPROFILE of the LCMS library. 930 | 931 | \since 0.12 932 | */ 933 | void* colorRgbProfile() const; 934 | /** 935 | Return the current display profile. 936 | 937 | \return a \c cmsHPROFILE of the LCMS library. 938 | 939 | \since 0.12 940 | */ 941 | void *colorDisplayProfile() const; 942 | 943 | /** 944 | Load the document from a file on disk 945 | 946 | \param filePath the name (and path, if required) of the file to load 947 | \param ownerPassword the Latin1-encoded owner password to use in 948 | loading the file 949 | \param userPassword the Latin1-encoded user ("open") password 950 | to use in loading the file 951 | 952 | \return the loaded document, or NULL on error 953 | 954 | \note The caller owns the pointer to Document, and this should 955 | be deleted when no longer required. 956 | 957 | \warning The returning document may be locked if a password is required 958 | to open the file, and one is not provided (as the userPassword). 959 | */ 960 | static Document *load(const QString & filePath, 961 | const QByteArray &ownerPassword=QByteArray(), 962 | const QByteArray &userPassword=QByteArray()); 963 | 964 | /** 965 | Load the document from memory 966 | 967 | \param fileContents the file contents. They are copied so there is no need 968 | to keep the byte array around for the full life time of 969 | the document. 970 | \param ownerPassword the Latin1-encoded owner password to use in 971 | loading the file 972 | \param userPassword the Latin1-encoded user ("open") password 973 | to use in loading the file 974 | 975 | \return the loaded document, or NULL on error 976 | 977 | \note The caller owns the pointer to Document, and this should 978 | be deleted when no longer required. 979 | 980 | \warning The returning document may be locked if a password is required 981 | to open the file, and one is not provided (as the userPassword). 982 | 983 | \since 0.6 984 | */ 985 | static Document *loadFromData(const QByteArray &fileContents, 986 | const QByteArray &ownerPassword=QByteArray(), 987 | const QByteArray &userPassword=QByteArray()); 988 | 989 | /** 990 | Get a specified Page 991 | 992 | Note that this follows the PDF standard of being zero based - if you 993 | want the first page, then you need an index of zero. 994 | 995 | The caller gets the ownership of the returned object. 996 | 997 | \param index the page number index 998 | */ 999 | Page *page(int index) const; 1000 | 1001 | /** 1002 | \overload 1003 | 1004 | 1005 | The intent is that you can pass in a label like \c "ix" and 1006 | get the page with that label (which might be in the table of 1007 | contents), or pass in \c "1" and get the page that the user 1008 | expects (which might not be the first page, if there is a 1009 | title page and a table of contents). 1010 | 1011 | \param label the page label 1012 | */ 1013 | Page *page(const QString &label) const; 1014 | 1015 | /** 1016 | The number of pages in the document 1017 | */ 1018 | int numPages() const; 1019 | 1020 | /** 1021 | The type of mode that should be used by the application 1022 | when the document is opened. Note that while this is 1023 | called page mode, it is really viewer application mode. 1024 | */ 1025 | PageMode pageMode() const; 1026 | 1027 | /** 1028 | The layout that pages should be shown in when the document 1029 | is first opened. This basically describes how pages are 1030 | shown relative to each other. 1031 | */ 1032 | PageLayout pageLayout() const; 1033 | 1034 | /** 1035 | The predominant reading order for text as supplied by 1036 | the document's viewer preferences. 1037 | 1038 | \since 0.26 1039 | */ 1040 | Qt::LayoutDirection textDirection() const; 1041 | 1042 | /** 1043 | Provide the passwords required to unlock the document 1044 | 1045 | \param ownerPassword the Latin1-encoded owner password to use in 1046 | loading the file 1047 | \param userPassword the Latin1-encoded user ("open") password 1048 | to use in loading the file 1049 | */ 1050 | bool unlock(const QByteArray &ownerPassword, const QByteArray &userPassword); 1051 | 1052 | /** 1053 | Determine if the document is locked 1054 | */ 1055 | bool isLocked() const; 1056 | 1057 | /** 1058 | The date associated with the document 1059 | 1060 | You would use this method with something like: 1061 | \code 1062 | QDateTime created = m_doc->date("CreationDate"); 1063 | QDateTime modified = m_doc->date("ModDate"); 1064 | \endcode 1065 | 1066 | The available dates are: 1067 | - CreationDate: the date of creation of the document 1068 | - ModDate: the date of the last change in the document 1069 | 1070 | \param data the type of date that is required 1071 | */ 1072 | QDateTime date( const QString & data ) const; 1073 | 1074 | /** 1075 | Get specified information associated with the document 1076 | 1077 | You would use this method with something like: 1078 | \code 1079 | QString title = m_doc->info("Title"); 1080 | QString subject = m_doc->info("Subject"); 1081 | \endcode 1082 | 1083 | In addition to \c Title and \c Subject, other information that may 1084 | be available include \c Author, \c Keywords, \c Creator and \c Producer. 1085 | 1086 | \param data the information that is required 1087 | 1088 | \sa infoKeys() to get a list of the available keys 1089 | */ 1090 | QString info( const QString & data ) const; 1091 | 1092 | /** 1093 | Obtain a list of the available string information keys. 1094 | */ 1095 | QStringList infoKeys() const; 1096 | 1097 | /** 1098 | Test if the document is encrypted 1099 | */ 1100 | bool isEncrypted() const; 1101 | 1102 | /** 1103 | Test if the document is linearised 1104 | 1105 | In some cases, this is called "fast web view", since it 1106 | is mostly an optimisation for viewing over the Web. 1107 | */ 1108 | bool isLinearized() const; 1109 | 1110 | /** 1111 | Test if the permissions on the document allow it to be 1112 | printed 1113 | */ 1114 | bool okToPrint() const; 1115 | 1116 | /** 1117 | Test if the permissions on the document allow it to be 1118 | printed at high resolution 1119 | */ 1120 | bool okToPrintHighRes() const; 1121 | 1122 | /** 1123 | Test if the permissions on the document allow it to be 1124 | changed. 1125 | 1126 | \note depending on the type of change, it may be more 1127 | appropriate to check other properties as well. 1128 | */ 1129 | bool okToChange() const; 1130 | 1131 | /** 1132 | Test if the permissions on the document allow the 1133 | contents to be copied / extracted 1134 | */ 1135 | bool okToCopy() const; 1136 | 1137 | /** 1138 | Test if the permissions on the document allow annotations 1139 | to be added or modified, and interactive form fields (including 1140 | signature fields) to be completed. 1141 | */ 1142 | bool okToAddNotes() const; 1143 | 1144 | /** 1145 | Test if the permissions on the document allow interactive 1146 | form fields (including signature fields) to be completed. 1147 | 1148 | \note this can be true even if okToAddNotes() is false - this 1149 | means that only form completion is permitted. 1150 | */ 1151 | bool okToFillForm() const; 1152 | 1153 | /** 1154 | Test if the permissions on the document allow interactive 1155 | form fields (including signature fields) to be set, created and 1156 | modified 1157 | */ 1158 | bool okToCreateFormFields() const; 1159 | 1160 | /** 1161 | Test if the permissions on the document allow content extraction 1162 | (text and perhaps other content) for accessibility usage (eg for 1163 | a screen reader) 1164 | */ 1165 | bool okToExtractForAccessibility() const; 1166 | 1167 | /** 1168 | Test if the permissions on the document allow it to be 1169 | "assembled" - insertion, rotation and deletion of pages; 1170 | or creation of bookmarks and thumbnail images. 1171 | 1172 | \note this can be true even if okToChange() is false 1173 | */ 1174 | bool okToAssemble() const; 1175 | 1176 | /** 1177 | The version of the PDF specification that the document 1178 | conforms to 1179 | 1180 | \param major an optional pointer to a variable where store the 1181 | "major" number of the version 1182 | \param minor an optional pointer to a variable where store the 1183 | "minor" number of the version 1184 | 1185 | \since 0.12 1186 | */ 1187 | void getPdfVersion(int *major, int *minor) const; 1188 | 1189 | /** 1190 | The fonts within the PDF document. 1191 | 1192 | This is a shorthand for getting all the fonts at once. 1193 | 1194 | \note this can take a very long time to run with a large 1195 | document. You may wish to use a FontIterator if you have more 1196 | than say 20 pages 1197 | 1198 | \see newFontIterator() 1199 | */ 1200 | QList fonts() const; 1201 | 1202 | /** 1203 | Creates a new FontIterator object for font scanning. 1204 | 1205 | The new iterator can be used for reading the font information of the 1206 | document, reading page by page. 1207 | 1208 | The caller is responsible for the returned object, ie it should freed 1209 | it when no more useful. 1210 | 1211 | \param startPage the initial page from which start reading fonts 1212 | 1213 | \see fonts() 1214 | 1215 | \since 0.12 1216 | */ 1217 | FontIterator* newFontIterator( int startPage = 0 ) const; 1218 | 1219 | /** 1220 | The font data if the font is an embedded one. 1221 | 1222 | \since 0.10 1223 | */ 1224 | QByteArray fontData(const FontInfo &font) const; 1225 | 1226 | /** 1227 | The documents embedded within the PDF document. 1228 | 1229 | \note there are two types of embedded document - this call 1230 | only accesses documents that are embedded at the document level. 1231 | */ 1232 | QList embeddedFiles() const; 1233 | 1234 | /** 1235 | Whether there are any documents embedded in this PDF document. 1236 | */ 1237 | bool hasEmbeddedFiles() const; 1238 | 1239 | /** 1240 | Gets the table of contents (TOC) of the Document. 1241 | 1242 | The caller is responsable for the returned object. 1243 | 1244 | In the tree the tag name is the 'screen' name of the entry. A tag can have 1245 | attributes. Here follows the list of tag attributes with meaning: 1246 | - Destination: A string description of the referred destination 1247 | - DestinationName: A 'named reference' to the viewport 1248 | - ExternalFileName: A link to a external filename 1249 | - Open: A bool value that tells whether the subbranch of the item is open or not 1250 | 1251 | Resolving the final destination for each item can be done in the following way: 1252 | - first, checking for 'Destination': if not empty, then a LinkDestination 1253 | can be constructed straight with it 1254 | - as second step, if the 'DestinationName' is not empty, then the destination 1255 | can be resolved using linkDestination() 1256 | 1257 | Note also that if 'ExternalFileName' is not emtpy, then the destination refers 1258 | to that document (and not to the current one). 1259 | 1260 | \returns the TOC, or NULL if the Document does not have one 1261 | */ 1262 | QDomDocument *toc() const; 1263 | 1264 | /** 1265 | Tries to resolve the named destination \p name. 1266 | 1267 | \note this operation starts a search through the whole document 1268 | 1269 | \returns a new LinkDestination object if the named destination was 1270 | actually found, or NULL otherwise 1271 | */ 1272 | LinkDestination *linkDestination( const QString &name ); 1273 | 1274 | /** 1275 | Sets the paper color 1276 | 1277 | \param color the new paper color 1278 | */ 1279 | void setPaperColor(const QColor &color); 1280 | /** 1281 | The paper color 1282 | 1283 | The default color is white. 1284 | */ 1285 | QColor paperColor() const; 1286 | 1287 | /** 1288 | Sets the backend used to render the pages. 1289 | 1290 | \param backend the new rendering backend 1291 | 1292 | \since 0.6 1293 | */ 1294 | void setRenderBackend( RenderBackend backend ); 1295 | /** 1296 | The currently set render backend 1297 | 1298 | The default backend is \ref SplashBackend 1299 | 1300 | \since 0.6 1301 | */ 1302 | RenderBackend renderBackend() const; 1303 | 1304 | /** 1305 | The available rendering backends. 1306 | 1307 | \since 0.6 1308 | */ 1309 | static QSet availableRenderBackends(); 1310 | 1311 | /** 1312 | Sets the render \p hint . 1313 | 1314 | \note some hints may not be supported by some rendering backends. 1315 | 1316 | \param on whether the flag should be added or removed. 1317 | 1318 | \since 0.6 1319 | */ 1320 | void setRenderHint( RenderHint hint, bool on = true ); 1321 | /** 1322 | The currently set render hints. 1323 | 1324 | \since 0.6 1325 | */ 1326 | RenderHints renderHints() const; 1327 | 1328 | /** 1329 | Gets a new PS converter for this document. 1330 | 1331 | The caller gets the ownership of the returned converter. 1332 | 1333 | \since 0.6 1334 | */ 1335 | PSConverter *psConverter() const; 1336 | 1337 | /** 1338 | Gets a new PDF converter for this document. 1339 | 1340 | The caller gets the ownership of the returned converter. 1341 | 1342 | \since 0.8 1343 | */ 1344 | PDFConverter *pdfConverter() const; 1345 | 1346 | /** 1347 | Gets the metadata stream contents 1348 | 1349 | \since 0.6 1350 | */ 1351 | QString metadata() const; 1352 | 1353 | /** 1354 | Test whether this document has "optional content". 1355 | 1356 | Optional content is used to optionally turn on (display) 1357 | and turn off (not display) some elements of the document. 1358 | The most common use of this is for layers in design 1359 | applications, but it can be used for a range of things, 1360 | such as not including some content in printing, and 1361 | displaying content in the appropriate language. 1362 | 1363 | \since 0.8 1364 | */ 1365 | bool hasOptionalContent() const; 1366 | 1367 | /** 1368 | Itemviews model for optional content. 1369 | 1370 | The model is owned by the document. 1371 | 1372 | \since 0.8 1373 | */ 1374 | OptContentModel *optionalContentModel(); 1375 | 1376 | /** 1377 | Document-level JavaScript scripts. 1378 | 1379 | Returns the list of document level JavaScript scripts to be always 1380 | executed before any other script. 1381 | 1382 | \since 0.10 1383 | */ 1384 | QStringList scripts() const; 1385 | 1386 | /** 1387 | The PDF identifiers. 1388 | 1389 | \param permanentId an optional pointer to a variable where store the 1390 | permanent ID of the document 1391 | \param updateId an optional pointer to a variable where store the 1392 | update ID of the document 1393 | 1394 | \return whether the document has the IDs 1395 | 1396 | \since 0.16 1397 | */ 1398 | bool getPdfId(QByteArray *permanentId, QByteArray *updateId) const; 1399 | 1400 | /** 1401 | Returns the type of forms contained in the document 1402 | 1403 | \since 0.22 1404 | */ 1405 | FormType formType() const; 1406 | 1407 | /** 1408 | Destructor. 1409 | */ 1410 | ~Document(); 1411 | 1412 | private: 1413 | Q_DISABLE_COPY(Document) 1414 | 1415 | DocumentData *m_doc; 1416 | 1417 | Document(DocumentData *dataA); 1418 | }; 1419 | 1420 | class BaseConverterPrivate; 1421 | class PSConverterPrivate; 1422 | class PDFConverterPrivate; 1423 | /** 1424 | \brief Base converter. 1425 | 1426 | This is the base class for the converters. 1427 | 1428 | \since 0.8 1429 | */ 1430 | class POPPLER_QT5_EXPORT BaseConverter 1431 | { 1432 | friend class Document; 1433 | public: 1434 | /** 1435 | Destructor. 1436 | */ 1437 | virtual ~BaseConverter(); 1438 | 1439 | /** Sets the output file name. You must set this or the output device. */ 1440 | void setOutputFileName(const QString &outputFileName); 1441 | 1442 | /** 1443 | * Sets the output device. You must set this or the output file name. 1444 | * 1445 | * \since 0.8 1446 | */ 1447 | void setOutputDevice(QIODevice *device); 1448 | 1449 | /** 1450 | Does the conversion. 1451 | 1452 | \return whether the conversion succeeded 1453 | */ 1454 | virtual bool convert() = 0; 1455 | 1456 | enum Error 1457 | { 1458 | NoError, 1459 | FileLockedError, 1460 | OpenOutputError, 1461 | NotSupportedInputFileError 1462 | }; 1463 | 1464 | /** 1465 | Returns the last error 1466 | \since 0.12.1 1467 | */ 1468 | Error lastError() const; 1469 | 1470 | protected: 1471 | /// \cond PRIVATE 1472 | BaseConverter(BaseConverterPrivate &dd); 1473 | Q_DECLARE_PRIVATE(BaseConverter) 1474 | BaseConverterPrivate *d_ptr; 1475 | /// \endcond 1476 | 1477 | private: 1478 | Q_DISABLE_COPY(BaseConverter) 1479 | }; 1480 | 1481 | /** 1482 | Converts a PDF to PS 1483 | 1484 | Sizes have to be in Points (1/72 inch) 1485 | 1486 | If you are using QPrinter you can get paper size by doing: 1487 | \code 1488 | QPrinter dummy(QPrinter::PrinterResolution); 1489 | dummy.setFullPage(true); 1490 | dummy.setPageSize(myPageSize); 1491 | width = dummy.width(); 1492 | height = dummy.height(); 1493 | \endcode 1494 | 1495 | \since 0.6 1496 | */ 1497 | class POPPLER_QT5_EXPORT PSConverter : public BaseConverter 1498 | { 1499 | friend class Document; 1500 | public: 1501 | /** 1502 | Options for the PS export. 1503 | 1504 | \since 0.10 1505 | */ 1506 | enum PSOption { 1507 | Printing = 0x00000001, ///< The PS is generated for printing purposes 1508 | StrictMargins = 0x00000002, 1509 | ForceRasterization = 0x00000004, 1510 | PrintToEPS = 0x00000008, ///< Output EPS instead of PS \since 0.20 1511 | HideAnnotations = 0x00000010 ///< Don't print annotations \since 0.20 1512 | }; 1513 | Q_DECLARE_FLAGS( PSOptions, PSOption ) 1514 | 1515 | /** 1516 | Destructor. 1517 | */ 1518 | ~PSConverter(); 1519 | 1520 | /** Sets the list of pages to print. Mandatory. */ 1521 | void setPageList(const QList &pageList); 1522 | 1523 | /** 1524 | Sets the title of the PS Document. Optional 1525 | */ 1526 | void setTitle(const QString &title); 1527 | 1528 | /** 1529 | Sets the horizontal DPI. Defaults to 72.0 1530 | */ 1531 | void setHDPI(double hDPI); 1532 | 1533 | /** 1534 | Sets the vertical DPI. Defaults to 72.0 1535 | */ 1536 | void setVDPI(double vDPI); 1537 | 1538 | /** 1539 | Sets the rotate. Defaults to not rotated 1540 | */ 1541 | void setRotate(int rotate); 1542 | 1543 | /** 1544 | Sets the output paper width. Has to be set. 1545 | */ 1546 | void setPaperWidth(int paperWidth); 1547 | 1548 | /** 1549 | Sets the output paper height. Has to be set. 1550 | */ 1551 | void setPaperHeight(int paperHeight); 1552 | 1553 | /** 1554 | Sets the output right margin. Defaults to 0 1555 | */ 1556 | void setRightMargin(int marginRight); 1557 | 1558 | /** 1559 | Sets the output bottom margin. Defaults to 0 1560 | */ 1561 | void setBottomMargin(int marginBottom); 1562 | 1563 | /** 1564 | Sets the output left margin. Defaults to 0 1565 | */ 1566 | void setLeftMargin(int marginLeft); 1567 | 1568 | /** 1569 | Sets the output top margin. Defaults to 0 1570 | */ 1571 | void setTopMargin(int marginTop); 1572 | 1573 | /** 1574 | Defines if margins have to be strictly followed (even if that 1575 | means changing aspect ratio), or if the margins can be adapted 1576 | to keep aspect ratio. 1577 | 1578 | Defaults to false. 1579 | */ 1580 | void setStrictMargins(bool strictMargins); 1581 | 1582 | /** Defines if the page will be rasterized to an image before printing. Defaults to false */ 1583 | void setForceRasterize(bool forceRasterize); 1584 | 1585 | /** 1586 | Sets the options for the PS export. 1587 | 1588 | \since 0.10 1589 | */ 1590 | void setPSOptions(PSOptions options); 1591 | 1592 | /** 1593 | The currently set options for the PS export. 1594 | 1595 | The default flags are: Printing. 1596 | 1597 | \since 0.10 1598 | */ 1599 | PSOptions psOptions() const; 1600 | 1601 | /** 1602 | Sets a function that will be called each time a page is converted. 1603 | 1604 | The payload belongs to the caller. 1605 | 1606 | \since 0.16 1607 | */ 1608 | void setPageConvertedCallback(void (* callback)(int page, void *payload), void *payload); 1609 | 1610 | bool convert(); 1611 | 1612 | private: 1613 | Q_DECLARE_PRIVATE(PSConverter) 1614 | Q_DISABLE_COPY(PSConverter) 1615 | 1616 | PSConverter(DocumentData *document); 1617 | }; 1618 | 1619 | /** 1620 | Converts a PDF to PDF (thus saves a copy of the document). 1621 | 1622 | \since 0.8 1623 | */ 1624 | class POPPLER_QT5_EXPORT PDFConverter : public BaseConverter 1625 | { 1626 | friend class Document; 1627 | public: 1628 | /** 1629 | Options for the PDF export. 1630 | */ 1631 | enum PDFOption { 1632 | WithChanges = 0x00000001 ///< The changes done to the document are saved as well 1633 | }; 1634 | Q_DECLARE_FLAGS( PDFOptions, PDFOption ) 1635 | 1636 | /** 1637 | Destructor. 1638 | */ 1639 | virtual ~PDFConverter(); 1640 | 1641 | /** 1642 | Sets the options for the PDF export. 1643 | */ 1644 | void setPDFOptions(PDFOptions options); 1645 | /** 1646 | The currently set options for the PDF export. 1647 | */ 1648 | PDFOptions pdfOptions() const; 1649 | 1650 | bool convert(); 1651 | 1652 | private: 1653 | Q_DECLARE_PRIVATE(PDFConverter) 1654 | Q_DISABLE_COPY(PDFConverter) 1655 | 1656 | PDFConverter(DocumentData *document); 1657 | }; 1658 | 1659 | /** 1660 | Conversion from PDF date string format to QDateTime 1661 | */ 1662 | POPPLER_QT5_EXPORT QDateTime convertDate( char *dateString ); 1663 | 1664 | /** 1665 | Whether the color management functions are available. 1666 | 1667 | \since 0.12 1668 | */ 1669 | POPPLER_QT5_EXPORT bool isCmsAvailable(); 1670 | 1671 | /** 1672 | Whether the overprint preview functionality is available. 1673 | 1674 | \since 0.22 1675 | */ 1676 | POPPLER_QT5_EXPORT bool isOverprintPreviewAvailable(); 1677 | 1678 | class SoundData; 1679 | /** 1680 | Container class for a sound file in a PDF document. 1681 | 1682 | A sound can be either External (in that case should be loaded the file 1683 | whose url is represented by url() ), or Embedded, and the player has to 1684 | play the data contained in data(). 1685 | 1686 | \since 0.6 1687 | */ 1688 | class POPPLER_QT5_EXPORT SoundObject { 1689 | public: 1690 | /** 1691 | The type of sound 1692 | */ 1693 | enum SoundType { 1694 | External, ///< The real sound file is external 1695 | Embedded ///< The sound is contained in the data 1696 | }; 1697 | 1698 | /** 1699 | The encoding format used for the sound 1700 | */ 1701 | enum SoundEncoding { 1702 | Raw, ///< Raw encoding, with unspecified or unsigned values in the range [ 0, 2^B - 1 ] 1703 | Signed, ///< Twos-complement values 1704 | muLaw, ///< mu-law-encoded samples 1705 | ALaw ///< A-law-encoded samples 1706 | }; 1707 | 1708 | /// \cond PRIVATE 1709 | SoundObject(Sound *popplersound); 1710 | /// \endcond 1711 | 1712 | ~SoundObject(); 1713 | 1714 | /** 1715 | Is the sound embedded (SoundObject::Embedded) or external (SoundObject::External)? 1716 | */ 1717 | SoundType soundType() const; 1718 | 1719 | /** 1720 | The URL of the sound file to be played, in case of SoundObject::External 1721 | */ 1722 | QString url() const; 1723 | 1724 | /** 1725 | The data of the sound, in case of SoundObject::Embedded 1726 | */ 1727 | QByteArray data() const; 1728 | 1729 | /** 1730 | The sampling rate of the sound 1731 | */ 1732 | double samplingRate() const; 1733 | 1734 | /** 1735 | The number of sound channels to use to play the sound 1736 | */ 1737 | int channels() const; 1738 | 1739 | /** 1740 | The number of bits per sample value per channel 1741 | */ 1742 | int bitsPerSample() const; 1743 | 1744 | /** 1745 | The encoding used for the sound 1746 | */ 1747 | SoundEncoding soundEncoding() const; 1748 | 1749 | private: 1750 | Q_DISABLE_COPY(SoundObject) 1751 | 1752 | SoundData *m_soundData; 1753 | }; 1754 | 1755 | class MovieData; 1756 | /** 1757 | Container class for a movie object in a PDF document. 1758 | 1759 | \since 0.10 1760 | */ 1761 | class POPPLER_QT5_EXPORT MovieObject { 1762 | friend class AnnotationPrivate; 1763 | public: 1764 | /** 1765 | The play mode for playing the movie 1766 | */ 1767 | enum PlayMode { 1768 | PlayOnce, ///< Play the movie once, closing the movie controls at the end 1769 | PlayOpen, ///< Like PlayOnce, but leaving the controls open 1770 | PlayRepeat, ///< Play continuously until stopped 1771 | PlayPalindrome ///< Play forward, then backward, then again foward and so on until stopped 1772 | }; 1773 | 1774 | ~MovieObject(); 1775 | 1776 | /** 1777 | The URL of the movie to be played 1778 | */ 1779 | QString url() const; 1780 | 1781 | /** 1782 | The size of the movie 1783 | */ 1784 | QSize size() const; 1785 | 1786 | /** 1787 | The rotation (either 0, 90, 180, or 270 degrees clockwise) for the movie, 1788 | */ 1789 | int rotation() const; 1790 | 1791 | /** 1792 | Whether show a bar with movie controls 1793 | */ 1794 | bool showControls() const; 1795 | 1796 | /** 1797 | How to play the movie 1798 | */ 1799 | PlayMode playMode() const; 1800 | 1801 | /** 1802 | Returns whether a poster image should be shown if the movie is not playing. 1803 | \since 0.22 1804 | */ 1805 | bool showPosterImage() const; 1806 | 1807 | /** 1808 | Returns the poster image that should be shown if the movie is not playing. 1809 | If the image is null but showImagePoster() returns @c true, the first frame of the movie 1810 | should be used as poster image. 1811 | \since 0.22 1812 | */ 1813 | QImage posterImage() const; 1814 | 1815 | private: 1816 | /// \cond PRIVATE 1817 | MovieObject( AnnotMovie *ann ); 1818 | /// \endcond 1819 | 1820 | Q_DISABLE_COPY(MovieObject) 1821 | 1822 | MovieData *m_movieData; 1823 | }; 1824 | 1825 | } 1826 | 1827 | Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Page::PainterFlags) 1828 | Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Page::SearchFlags) 1829 | Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Document::RenderHints) 1830 | Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::PDFConverter::PDFOptions) 1831 | Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::PSConverter::PSOptions) 1832 | 1833 | #endif 1834 | -------------------------------------------------------------------------------- /external_libs/poppler/lib/libpoppler-qt5.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qzind/pulas/65f54bb78b067daf219c691ecf8129277961d1f9/external_libs/poppler/lib/libpoppler-qt5.dll -------------------------------------------------------------------------------- /external_libs/poppler/lib/libpoppler.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qzind/pulas/65f54bb78b067daf219c691ecf8129277961d1f9/external_libs/poppler/lib/libpoppler.dll --------------------------------------------------------------------------------