Repair PDF Guide

How to integrate the Repair PDF tool into your application to fix damaged or corrupted files using iLovePDF’s REST API.

New to the API? Start with Processing a PDF: every tool guide builds on its task flow.

Basic repair

Repair is one of the simplest iLoveAPI tools to use and can be done by simply uploading one or more files, like in this example code:

Basic repair
// Create a new task
$myTask = $ilovepdf->newTask('repair');
// Add files to task for upload
$file1=$myTask->addFile('path/to/file1_name.pdf');
// Execute the task
$myTask->execute();
// Download the package files
$myTask->download();
PHP library ilovepdf/ilovepdf-phpcomposer require ilovepdf/ilovepdf-php

With this code, file1_name.pdf will be uploaded to be repaired. If the file was repaired successfully (or wasn't originally damaged!) the process will end successfully and files will be ready to download.


However, sometimes it is possible that one or more files are heavily damaged and cannot be repaired. For these cases, the Repair tool will inform you with a warning message indicating which files couldn't be repaired.


That's it! Remember that you can explore more functions like setting the output filename in the Common features guide.