-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain.cpp
More file actions
39 lines (31 loc) · 1012 Bytes
/
main.cpp
File metadata and controls
39 lines (31 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <QtCore>
#include <QString>
#include <QDebug>
#include <iostream>
#include "poppler-qt5.h"
#include "poppler-form.h"
bool saveToFile(const QString &filename, const Poppler::Document* doc) {
Poppler::PDFConverter *pdfConv = doc->pdfConverter();
pdfConv->setOutputFileName(filename);
pdfConv->setPDFOptions(pdfConv->pdfOptions()|Poppler::PDFConverter::WithChanges);
bool success = pdfConv->convert();
delete pdfConv;
return success;
}
int main(int argc, char **argv) {
freopen("dev/null", "w", stderr);
QString filename, toFile;
filename = QString(argv[1]);
toFile = QString(argv[2]);
Poppler::Document* doc = Poppler::Document::load(filename);
Poppler::Page* page = doc->page(0);
QList<Poppler::FormField *> fields = page->formFields();
for(int j = 0; j < fields.length(); j++) {
Poppler::FormField *f = fields.at(j);
f->setVisible(false);
}
saveToFile(toFile, doc);
delete page;
delete doc;
return 0;
}