I'm trying to delete the selected pages in a pdf, but can't seem to figure it out...
The idea here is that the user has selected one or more pages in a pdf (loaded in pPDFViewer). I then save the selected pages to a tempfile for future use. This works fine. The rest of the pages should then be available for the user to make another selection, but without the pages previously selected. I therefore try to delete the pages from the original document, but the COMPDF_PageSelectionGet-command returns -1 no matter what I do, and consequently the page aren't deleted. Did I miss anything?
Code
int Res = 0;
Res = pPDFViewer->Plus->SaveSelectionToFile(TempFileName); // Res = 65536
int SelectedCount = pPDFViewer->CommandEx(COMPDF_PageSelectionGet, -1); // SelectedCount = -1
for (int i = 0, j = 0; i < pPDFViewer->PageCount && j < SelectedCount; i++) { // pPDFViewer->PageCount = 55 for my testdocument
if ((Res = pPDFViewer->CommandEx(COMPDF_PageSelectionGet, i)) == 1) { // Res = -1, both for selected and unselected pages
Res = pPDFViewer->DeletePage(i);
j++;
}
}
Res = pPDFViewer->Command(COMPDF_PageSelectionClear);
I guess I could invert the selection, save the selection as a new tempfile and load this as my new original... but I don't want to :)