I'm working step by step with simple things to make sure I'm getting C++ syntax correct (especially with namespaces, and pointers!).
I'm working with Poppler, a library for working with PDF files. There is, apparently, no constructor for a Poppler Document. Once I have the document object, I can load_from_file(), though.
The problem I'm having is that I am trying to declare the object pDoc, then use it in a loop. In each iteration, I'm going to load a new file into pDoc.
Here is the link to the docs that cover the poppler::document class:
https://oinksoft.com/doc/poppler/cpp...1document.html
I do notice that the load_from_file() is static, so my assumption is that I use it to create a document (since there's no constructor), but I'm not clear on the syntax and formatting.
Right now I have:
Code:
...
#include "poppler/cpp/poppler-document.h"
using namespace std;
...
void addPDFs(list<string> fList) {
list<string>::iterator iList;
poppler::document pDoc; //Problem Line #1
int x = 1;
int pNum = -1;
for (iList = fList.begin(); iList != fList.end(); iList++) {
pDoc.load_from_file(*iList);
pNum = pDoc.pages(); //Problem Line #2
cout << "Item : " << x << " : " << *iList << ", Total Pages: "
<< pNum << endl;
}
}
(There may be other errors in my code - I can look them up and find them through debugging and I'll remember them better that way, but I'm having trouble with this one because I can't find any example code for this class.)
I'm having problems with two lines (marked with comments). In the first I'm declaring pDoc (and eventually it will be used outside of the loop). When I compiled this program, Eclipse gave me the error, "no matching function for call to 'poppler::document::document()'" (The point that it seems to know what's available makes me think I'm at least referring to the poppler::document object correctly.)
What I don't see is how to declare pDoc here properly (I don't want to load a file in yet).
Then, on the 2nd problem line, I think that should be something like:
Code:
pDoc = poppler::document::load_from_file(filename)
I'm willing to bet that the answer is pretty obvious - I'm just not sure how those two lines should be written to declare pDoc and, later, to load in the file and create a new instance.