Reputation: 1
I used 'vcpkg install podofo' to get podofo here is code I tried to build
#include <podofo/podofo.h>
#include <iostream>
#include <vector>
#include <string>
using namespace PoDoFo;
void mergePDFs(const std::vector<std::string>& inputFiles, const std::string& outputFile) {
PdfMemDocument outputPdf;
try {
for (const auto& file : inputFiles) {
PdfMemDocument pdf;
pdf.Load(file.c_str());
for (int i = 0; i < pdf.GetPageCount(); ++i) {
PdfPage* page = pdf.GetPage(i);
outputPdf.InsertPage(page, outputPdf.GetPageCount());
}
}
outputPdf.Write(outputFile.c_str());
std::cout << "PDF files merged successfully into " << outputFile << std::endl;
} catch (PdfError& e) {
std::cerr << "Error merging PDF files: " << e.GetError() << std::endl;
}
}
void changePageOrder(const std::string& inputFile, const std::string& outputFile) {
try {
PdfMemDocument pdf;
pdf.Load(inputFile.c_str());
int pageCount = pdf.GetPageCount();
PdfMemDocument outputPdf;
int front = 0;
int back = pageCount - 1;
while (front <= back) {
if (front <= back) {
PdfPage* page = pdf.GetPage(front);
outputPdf.InsertPage(page, outputPdf.GetPageCount());
++front;
}
if (front <= back) {
PdfPage* page = pdf.GetPage(back);
outputPdf.InsertPage(page, outputPdf.GetPageCount());
--back;
}
}
outputPdf.Write(outputFile.c_str());
std::cout << "Page order changed successfully in " << outputFile << std::endl;
} catch (PdfError& e) {
std::cerr << "Error changing page order: " << e.GetError() << std::endl;
}
}
int main() {
while (true) {
int choice;
std::cout << "Menu:\n";
std::cout << "1. Merge PDFs\n";
std::cout << "2. Change Page Order\n";
std::cout << "3. Merge and Change Page Order\n";
std::cout << "4. Exit\n";
std::cout << "Enter your choice: ";
std::cin >> choice;
switch (choice) {
case 1: {
std::vector<std::string> inputFiles;
std::string filename;
std::cout << "Enter PDF filenames to merge (enter 'done' to finish):\n";
while (true) {
std::cin >> filename;
if (filename == "done") break;
inputFiles.push_back(filename);
}
std::string outputFile;
std::cout << "Enter output PDF filename: ";
std::cin >> outputFile;
mergePDFs(inputFiles, outputFile);
break;
}
case 2: {
std::string inputFile, outputFile;
std::cout << "Enter PDF filename to reorder: ";
std::cin >> inputFile;
std::cout << "Enter output PDF filename: ";
std::cin >> outputFile;
changePageOrder(inputFile, outputFile);
break;
}
case 3: {
std::vector<std::string> inputFiles;
std::string filename;
std::cout << "Enter PDF filenames to merge (enter 'done' to finish):\n";
while (true) {
std::cin >> filename;
if (filename == "done") break;
inputFiles.push_back(filename);
}
std::string mergedFile;
std::cout << "Enter intermediate merged PDF filename: ";
std::cin >> mergedFile;
mergePDFs(inputFiles, mergedFile);
std::string reorderedFile;
std::cout << "Enter output PDF filename for reordered pages: ";
std::cin >> reorderedFile;
changePageOrder(mergedFile, reorderedFile);
break;
}
case 4:
std::cout << "Exiting the program.\n";
return 0;
default:
std::cout << "Invalid choice. Please enter a number between 1 and 4.\n";
}
}
}
from developer cmd I used
cl /EHsc /std:c++17 PDFencil.cpp /I"E:\vcpkg\installed\x64-windows\include" /link /LIBPATH:"E:\vcpkg\installed\x64-windows\lib" podofo.lib
I think i made sure i included path correctly and used c++17
but I am getting
PDFencil.cpp(16): error C2039: 'GetPageCount': is not a member of 'PoDoFo::PdfMemDocument'
E:\vcpkg\installed\x64-windows\include\podofo\main\PdfMemDocument.h(37): note: see declaration of 'PoDoFo::PdfMemDocument'
PDFencil.cpp(17): error C2039: 'GetPage': is not a member of 'PoDoFo::PdfMemDocument'
E:\vcpkg\installed\x64-windows\include\podofo\main\PdfMemDocument.h(37): note: see declaration of 'PoDoFo::PdfMemDocument'
PDFencil.cpp(18): error C2039: 'InsertPage': is not a member of 'PoDoFo::PdfMemDocument'
E:\vcpkg\installed\x64-windows\include\podofo\main\PdfMemDocument.h(37): note: see declaration of 'PoDoFo::PdfMemDocument'
PDFencil.cpp(18): error C2039: 'GetPageCount': is not a member of 'PoDoFo::PdfMemDocument'
E:\vcpkg\installed\x64-windows\include\podofo\main\PdfMemDocument.h(37): note: see declaration of 'PoDoFo::PdfMemDocument'
PDFencil.cpp(22): error C2039: 'Write': is not a member of 'PoDoFo::PdfMemDocument'
E:\vcpkg\installed\x64-windows\include\podofo\main\PdfMemDocument.h(37): note: see declaration of 'PoDoFo::PdfMemDocument'
PDFencil.cpp(25): error C2039: 'GetError': is not a member of 'PoDoFo::PdfError'
E:\vcpkg\installed\x64-windows\include\podofo\main\PdfError.h(148): note: see declaration of 'PoDoFo::PdfError'
PDFencil.cpp(34): error C2039: 'GetPageCount': is not a member of 'PoDoFo::PdfMemDocument'
E:\vcpkg\installed\x64-windows\include\podofo\main\PdfMemDocument.h(37): note: see declaration of 'PoDoFo::PdfMemDocument'
PDFencil.cpp(42): error C2039: 'GetPage': is not a member of 'PoDoFo::PdfMemDocument'
E:\vcpkg\installed\x64-windows\include\podofo\main\PdfMemDocument.h(37): note: see declaration of 'PoDoFo::PdfMemDocument'
PDFencil.cpp(43): error C2039: 'InsertPage': is not a member of 'PoDoFo::PdfMemDocument'
E:\vcpkg\installed\x64-windows\include\podofo\main\PdfMemDocument.h(37): note: see declaration of 'PoDoFo::PdfMemDocument'
PDFencil.cpp(43): error C2039: 'GetPageCount': is not a member of 'PoDoFo::PdfMemDocument'
E:\vcpkg\installed\x64-windows\include\podofo\main\PdfMemDocument.h(37): note: see declaration of 'PoDoFo::PdfMemDocument'
PDFencil.cpp(48): error C2039: 'GetPage': is not a member of 'PoDoFo::PdfMemDocument'
E:\vcpkg\installed\x64-windows\include\podofo\main\PdfMemDocument.h(37): note: see declaration of 'PoDoFo::PdfMemDocument'
PDFencil.cpp(49): error C2039: 'InsertPage': is not a member of 'PoDoFo::PdfMemDocument'
E:\vcpkg\installed\x64-windows\include\podofo\main\PdfMemDocument.h(37): note: see declaration of 'PoDoFo::PdfMemDocument'
PDFencil.cpp(49): error C2039: 'GetPageCount': is not a member of 'PoDoFo::PdfMemDocument'
E:\vcpkg\installed\x64-windows\include\podofo\main\PdfMemDocument.h(37): note: see declaration of 'PoDoFo::PdfMemDocument'
PDFencil.cpp(54): error C2039: 'Write': is not a member of 'PoDoFo::PdfMemDocument'
E:\vcpkg\installed\x64-windows\include\podofo\main\PdfMemDocument.h(37): note: see declaration of 'PoDoFo::PdfMemDocument'
PDFencil.cpp(57): error C2039: 'GetError': is not a member of 'PoDoFo::PdfError'
E:\vcpkg\installed\x64-windows\include\podofo\main\PdfError.h(148): note: see declaration of 'PoDoFo::PdfError'
I have no idea how to fix this This is my first time using external libraries
I double checked path to vcpkg files. I also tried to git clone podofo and build it for past 7 days. tried using vcpkg to download dependencies also tried using bootstrap.cmd on playground but it fail.
Upvotes: 0
Views: 43