Examples / repair / cpp

Repair

A complete, runnable cpp program — 15 lines, shipped in your download.

Demonstrates Import & Output APIs

Same example, other languages: activex_cpp c cpp_linux csharp python vbnet

examples/cpp/repair/repair.cpp 15 lines
// repair -- C++ port: fix a damaged PDF with a SINGLE method: pdfConvertFileA(..., ctNormalize).
#include <lumaspdf.h>
#include <cstdio>
int main(void){
  PPDF p = pdfNewPDF();
  int rc = pdfConvertFileA(p,
      "../../test_files/corrupt.pdf",   // damaged input (mangled xref)
      "repaired.pdf",
      ctNormalize, 0, NULL, NULL, NULL, NULL, NULL, NULL);
  printf("pdfConvertFile(ctNormalize) rc=%d  (repair-mode used: %d)\n",
         rc, (int)pdfGetInRepairMode(p));
  pdfDeletePDF(p);
  return rc < 0 ? 1 : 0;
}

This file is in the SDK at examples/cpp/repair/repair.cpp. The build fails if this page and that file ever differ.