- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要填写pdf表格。为此,我发现并使用了 qPDF c++ 库。
我在 fillPdf.pro 上添加了 libqpdf.dll.a 使用:
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/qpdf/lib/ -llibqpdf.dll
INCLUDEPATH += $$PWD/qpdf
DEPENDPATH += $$PWD/qpdf
我还将 qpdf 库中的所有包含 .h 和 .hh header 添加到我的项目中。
但我仍然有看起来像链接问题的错误:
.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 creator 识别,我可以通过单击它们来访问它们的类:
#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 5.9.1(MSVC 2015,32 位)的 qt creator 4.4.0
谁能告诉我哪里错了?
我的.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
最佳答案
我使用下面的配置让它工作:
我的.pro :
#-------------------------------------------------
#
# Project created by QtCreator 2019-04-01T16:52:28
#
#-------------------------------------------------
QT += core gui
QT += axcontainer
QT += serialport
CONFIG += c++11 console
CONFIG -= app_bundle
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = QTfillpdftest
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
qtfillpdf.cpp
HEADERS += \
qtfillpdf.h\
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
FORMS += \
qtfillpdf.ui
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/qpdf/lib/ -llibqpdf.dll
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/qpdf/lib/ -llibqpdf.dll
else:unix: LIBS += -L$$PWD/qpdf/lib/ -llibqpdf.dll
INCLUDEPATH += $$PWD/qpdf
DEPENDPATH += $$PWD/qpdf
函数:
int qtfillpdf::qtfillpdfFile( char const* infilename , char const* outfilename,char const* value )
{
qDebug() << "qtfillpdf : 1 " << value;
// This is a contrived example that just goes through a file page
// by page and sets the value of any text fields it finds to a
// fixed value as given on the command line. The purpose here is
// to illustrate use of the helper classes around interactive
// forms.
QPDF qpdf;
qDebug() << "qtfillpdfFile : 1.1 " << value;
qpdf.processFile(infilename);
std::string nm;
nm= qpdf.getFilename();
qDebug() << "qtfillpdf : 2 " << nm.c_str() ;
// We will iterate through form fields by starting at the page
// level and looking at each field for each page. We could
// also called QPDFAcroFormDocumentHelper::getFormFields to
// iterate at the field level, but doing it as below
// illustrates how we can map from annotations to fields.
QPDFAcroFormDocumentHelper afdh(qpdf);
QPDFPageDocumentHelper pdh(qpdf);
std::vector<QPDFPageObjectHelper> pages = pdh.getAllPages();
qDebug() << "qtfillpdf : 3 " ;
for (std::vector<QPDFPageObjectHelper>::iterator page_iter =
pages.begin();
page_iter != pages.end(); ++page_iter)
{
// Get all widget annotations for each page. Widget
// annotations are the ones that contain the details of
// what's in a form field.
std::vector<QPDFAnnotationObjectHelper> annotations =
afdh.getWidgetAnnotationsForPage(*page_iter);
for (std::vector<QPDFAnnotationObjectHelper>::iterator annot_iter = annotations.begin();
annot_iter != annotations.end(); ++annot_iter)
{
// For each annotation, find its associated field. If
// it's a text field, set its value. This will
// automatically update the document to indicate that
// appearance streams need to be regenerated. At the
// time of this writing, qpdf doesn't have any helper
// code to assist with appearance stream generation,
// though there's nothing that prevents it from being
// possible.
//qDebug() << "qtfillpdf : 4 " << annot_iter->getAppearanceState().c_str() ;
QPDFFormFieldObjectHelper ffh =
afdh.getFieldForAnnotation(*annot_iter);
if (ffh.getFieldType() == "/Tx")
{
//qDebug() << "qtfillpdf : 5 " <<ffh.getChoices().front().c_str();
// Set the value. This will automatically set
// /NeedAppearances to true. If you don't want to
// do that, pass false as the second argument. For
// details see comments in
// QPDFFormFieldObjectHelper.hh.
ffh.setV(value);
qDebug() << "OK6" << value << " ffh.getValueAsString() : " <<ffh.getValueAsString().c_str();
}
}
}
// Write out a new file
QPDFWriter w(qpdf, outfilename);
w.setStaticID(true); // for testing only
w.write();
return 3;
}
void qtfillpdf::on_Browse_clicked()
{
///TODO : mettre le liens
QString s_configFileName;
QString outfilename = "OUT.pdf";
QString value="qfiller";
s_configFileName = QFileDialog::getOpenFileName(
this,
tr("Selectfile"),
"", tr("pdf Files (*.pdf)")
);
qDebug() << "File Name : " << s_configFileName ;
qtfillpdfFile(s_configFileName.toStdString().c_str(), outfilename.toStdString().c_str(), value.toStdString().c_str());
qDebug()<< " END_BROWSE :" << s_configFileName ;
}
关于c++ - 在 Qt 中链接 qPDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55455731/
我需要将文本放在 中在一个 Div 中,在另一个 Div 中,在另一个 Div 中。所以这是它的样子: #document Change PIN
奇怪的事情发生了。 我有一个基本的 html 代码。 html,头部, body 。(因为我收到了一些反对票,这里是完整的代码) 这是我的CSS: html { backgroun
我正在尝试将 Assets 中的一组图像加载到 UICollectionview 中存在的 ImageView 中,但每当我运行应用程序时它都会显示错误。而且也没有显示图像。 我在ViewDidLoa
我需要根据带参数的 perl 脚本的输出更改一些环境变量。在 tcsh 中,我可以使用别名命令来评估 perl 脚本的输出。 tcsh: alias setsdk 'eval `/localhome/
我使用 Windows 身份验证创建了一个新的 Blazor(服务器端)应用程序,并使用 IIS Express 运行它。它将显示一条消息“Hello Domain\User!”来自右上方的以下 Ra
这是我的方法 void login(Event event);我想知道 Kotlin 中应该如何 最佳答案 在 Kotlin 中通配符运算符是 * 。它指示编译器它是未知的,但一旦知道,就不会有其他类
看下面的代码 for story in book if story.title.length < 140 - var story
我正在尝试用 C 语言学习字符串处理。我写了一个程序,它存储了一些音乐轨道,并帮助用户检查他/她想到的歌曲是否存在于存储的轨道中。这是通过要求用户输入一串字符来完成的。然后程序使用 strstr()
我正在学习 sscanf 并遇到如下格式字符串: sscanf("%[^:]:%[^*=]%*[*=]%n",a,b,&c); 我理解 %[^:] 部分意味着扫描直到遇到 ':' 并将其分配给 a。:
def char_check(x,y): if (str(x) in y or x.find(y) > -1) or (str(y) in x or y.find(x) > -1):
我有一种情况,我想将文本文件中的现有行包含到一个新 block 中。 line 1 line 2 line in block line 3 line 4 应该变成 line 1 line 2 line
我有一个新项目,我正在尝试设置 Django 调试工具栏。首先,我尝试了快速设置,它只涉及将 'debug_toolbar' 添加到我的已安装应用程序列表中。有了这个,当我转到我的根 URL 时,调试
在 Matlab 中,如果我有一个函数 f,例如签名是 f(a,b,c),我可以创建一个只有一个变量 b 的函数,它将使用固定的 a=a1 和 c=c1 调用 f: g = @(b) f(a1, b,
我不明白为什么 ForEach 中的元素之间有多余的垂直间距在 VStack 里面在 ScrollView 里面使用 GeometryReader 时渲染自定义水平分隔线。 Scrol
我想知道,是否有关于何时使用 session 和 cookie 的指南或最佳实践? 什么应该和什么不应该存储在其中?谢谢! 最佳答案 这些文档很好地了解了 session cookie 的安全问题以及
我在 scipy/numpy 中有一个 Nx3 矩阵,我想用它制作一个 3 维条形图,其中 X 轴和 Y 轴由矩阵的第一列和第二列的值、高度确定每个条形的 是矩阵中的第三列,条形的数量由 N 确定。
假设我用两种不同的方式初始化信号量 sem_init(&randomsem,0,1) sem_init(&randomsem,0,0) 现在, sem_wait(&randomsem) 在这两种情况下
我怀疑该值如何存储在“WORD”中,因为 PStr 包含实际输出。? 既然Pstr中存储的是小写到大写的字母,那么在printf中如何将其给出为“WORD”。有人可以吗?解释一下? #include
我有一个 3x3 数组: var my_array = [[0,1,2], [3,4,5], [6,7,8]]; 并想获得它的第一个 2
我意识到您可以使用如下方式轻松检查焦点: var hasFocus = true; $(window).blur(function(){ hasFocus = false; }); $(win
我是一名优秀的程序员,十分优秀!