# Repair PDF files: web app and Aspose.PDF.FOSS (C#)

## What it does
The Recovery feature rebuilds the structure of a damaged PDF, attempts to restore missing pages or content, and can strip hidden data, revisions, metadata, attachments, and active content according to a chosen sanitization profile.

## Inputs and limits
* **Input** – a single PDF file. The file must be a valid PDF; encrypted PDFs or non‑PDF files are reported as unrecoverable.
* **Optional advanced controls**
  * Expected page count – reject a repair that ends up with fewer pages than this value (0 to skip).
  * Minimum text coverage (%) – reject a repair unless at least this percentage of pages contain extractable text (0 to skip).
  * Sanitization profile – selects what hidden data to remove (Full, Structural, Public release, Court filing, Internal share, Keep attachments, None).

## Web app
The page asks you to upload a PDF that will not open, is missing pages, or contains hidden content you do not want to share. After you click the upload button, the service triages the file, runs a staged repair pipeline, applies the selected sanitization profile, and finally provides a repaired PDF together with a PDF‑X‑ray report that details what was fixed and what was removed.

## Aspose.PDF.FOSS (C#)
The C# sample loads the input PDF with Aspose.PDF.FOSS and saves it unchanged, which demonstrates a basic repair operation using the library. ```csharp
#:package Aspose.PDF.FOSS@26.11.0

using Aspose.Pdf;

var inputDir = args[0];
var outputDir = args[1];

var inputFile = Path.Combine(inputDir, "sample.pdf");
var doc = new Document(inputFile);
var outputPath = Path.Combine(outputDir, "repaired.pdf");
doc.Save(outputPath);
Console.WriteLine("repaired.pdf written");
```

Save it as `app.cs` and run `dotnet run app.cs -- ./in ./out` (.NET 10 SDK).

## Verified

Every code sample on this page was run on 2026-11-03 and its result was checked:

- Repair PDF via Aspose.PDF.FOSS (no changes) (Aspose.PDF.FOSS): passed in 10 s
