Repair
A complete, runnable c program — 15 lines, shipped in your download.
Demonstrates Import & Output APIs
Same example, other languages: activex_cpp cpp cpp_linux csharp python vbnet
examples/c/repair/repair.c
15 lines
// repair -- fix a damaged PDF with a SINGLE method: pdfConvertFileA(..., ctNormalize).
#include <lumaspdf.h>
#include <stdio.h>
int main(void){
PPDF p = pdfNewPDF();
int rc = pdfConvertFileA(p,
"../../test_files/corrupt.pdf", /* 4-page 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/c/repair/repair.c.
The build fails if this page and that file ever differ.