https://github.com/qpdf
需要引用头文件:
#include "qpdf\QPDF.hh" #include "qpdf/QPDFWriter.hh" #include "qpdf/QUtil.hh"
QPDF outpdf; outpdf.emptyPDF(); QPDF inpdfa; inpdfa.processFile("D:\\aaaa.tmp"); std::vector<QPDFObjectHandle> apages=inpdfa.getAllPages(); for (std::vector<QPDFObjectHandle>::iterator iter = apages.begin(); iter != apages.end(); ++iter) outpdf.addPage(*iter, false); QPDF inpdfb; inpdfb.processFile("D:\\bbbb.tmp"); std::vector<QPDFObjectHandle> bpages = inpdfb.getAllPages(); for (std::vector<QPDFObjectHandle>::iterator iter = bpages.begin(); iter != bpages.end(); ++iter) outpdf.addPage(*iter, false); QPDFWriter outpdfw(outpdf, "D:\\cccc.pdf"); outpdfw.write();