Мне нужно заполнить PDF форму.Для этого я нашел и использую библиотеку qPDF c ++.
Я добавил libqpdf.dll.a на fillPdf.pro, используя:
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/qpdf/lib/ -llibqpdf.dll
INCLUDEPATH += $$PWD/qpdf
DEPENDPATH += $$PWD/qpdf
Я также добавил все заголовки .h и .hh.из библиотеки qpdf в мой проект.
Но у меня все еще есть ошибки, которые выглядят как проблемы со связью:
.o:-1: In function `ZN8reporter8fillTestEPKcS1_S1_':
.cpp:19: erreur : undefined reference to `QPDF::QPDF()'
.cpp:20: erreur : undefined reference to `QPDF::processFile(char const*, char const*)' ^
.cpp:19: erreur : undefined reference to `QPDF::~QPDF()'
collect2.exe:-1: erreur : error: ld returned 1 exit status
Суммированный код: все символы распознаются создателем qt, и у меня есть доступ к их классам пощелкнув по ним:
#include <qpdf/QPDF.hh>
#include <qpdf/QPDFWriter.hh>
#include <qpdf/QUtil.hh>
#include <iostream>
int main(int argc, char* argv[])
{
char* whoami = QUtil::getWhoami(argv[0]);
if (argc != 3)
{
std::cerr << "Usage: " << whoami << " infile outfile" << std::endl;
return 2;
}
char const* infile = argv[1];
char const* outfile = argv[2];
QPDF in;
in.processFile(infile);
int pageno = 0;
std::vector<QPDFObjectHandle> const& pages = in.getAllPages();
for (std::vector<QPDFObjectHandle>::const_iterator iter = pages.begin();
iter != pages.end(); ++iter)
{
std::cout << ++pageno << " ";
QPDFObjectHandle page = *iter;
page.replaceKey(
"/Contents",
QPDFObjectHandle::newStream(&in, "q Q"));
}
QPDFWriter out(in, outfile);
out.write();
return 0;
}
Дополнительная информация:
QPDF WINDOWS Lib : https://sourceforge.net/projects/qpdf/files/qpdf/8.4.0/
includes : https://github.com/qpdf/qpdf/tree/master/include/qpdf
exemple : https://github.com/qpdf/qpdf/blob/master/examples/pdf-set-form-values.cc
Я использую qt creator 4.4.0 на основе qt 5.9.1 (MSVC 2015, 32bit)
Может кто-нибудь сказать мне, где я не прав?
Мой .pro
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG += qt
QT += core gui
QT += axcontainer
QT += serialport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
SOURCES += main.cpp
HEADERS += \
qpdf/Buffer.hh \
qpdf/BufferInputSource.hh \
qpdf/ClosedFileInputSource.hh \
qpdf/Constants.h \
qpdf/DLL.h \
qpdf/FileInputSource.hh \
qpdf/InputSource.hh \
qpdf/JSON.hh \
qpdf/Pipeline.hh \
qpdf/Pl_Buffer.hh \
qpdf/Pl_Concatenate.hh \
qpdf/Pl_Count.hh \
qpdf/Pl_DCT.hh \
qpdf/Pl_Discard.hh \
qpdf/Pl_Flate.hh \
qpdf/Pl_QPDFTokenizer.hh \
qpdf/Pl_RunLength.hh \
qpdf/Pl_StdioFile.hh \
qpdf/PointerHolder.hh \
qpdf/qpdf-c.h \
qpdf/QPDF.hh \
qpdf/QPDFAcroFormDocumentHelper.hh \
qpdf/QPDFAnnotationObjectHelper.hh \
qpdf/QPDFDocumentHelper.hh \
qpdf/QPDFExc.hh \
qpdf/QPDFFormFieldObjectHelper.hh \
qpdf/QPDFNameTreeObjectHelper.hh \
qpdf/QPDFNumberTreeObjectHelper.hh \
qpdf/QPDFObject.hh \
qpdf/QPDFObjectHandle.hh \
qpdf/QPDFObjectHelper.hh \
qpdf/QPDFObjGen.hh \
qpdf/QPDFOutlineDocumentHelper.hh \
qpdf/QPDFOutlineObjectHelper.hh \
qpdf/QPDFPageDocumentHelper.hh \
qpdf/QPDFPageLabelDocumentHelper.hh \
qpdf/QPDFPageObjectHelper.hh \
qpdf/QPDFSystemError.hh \
qpdf/QPDFTokenizer.hh \
qpdf/QPDFWriter.hh \
qpdf/QPDFXRefEntry.hh \
qpdf/QTC.hh \
qpdf/QUtil.hh \
qpdf/RandomDataProvider.hh \
qpdf/Types.h
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/qpdf/lib/ -llibqpdf.dll
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/qpdf/lib/ -llibqpdf.dllINCLUDEPATH += $$PWD/qpdf
DEPENDPATH += $$PWD/qpdf