# Redact, Sanitize, and Optimize PDF Files

Remove sensitive content by detected coordinates, sanitize interactive structures, and optimize a verified delivery copy.

Redaction, sanitization, and optimization are separate operations. Redaction removes selected content. Sanitization removes or normalizes risky document structures according to policy. Optimization changes representation to reduce or simplify the file.

## Redact detected text

Use `Get-OfficePdfRedactionPlan -Text` when you want to preview the matching areas, or pass the same literal text directly to `Remove-OfficePdfContent`:

```powershell
Get-OfficePdfRedactionPlan -Path '.\Incident.pdf' -Text 'Secret account'

Remove-OfficePdfContent `
    -Path '.\Incident.pdf' `
    -OutputPath '.\Incident-Redacted.pdf' `
    -Text 'Secret account'
```

The [redact-detected-text recipe](https://github.com/EvotecIT/OfficeIMO/blob/3b680b1b6fb15a268ff5525a4ca6cdd70b2f6613/PowerShell/PSWriteOffice/Examples/Pdf/Recipe-Pdf-RedactDetectedText.ps1) shows the same operation with a self-contained source PDF.

## Prepare a delivery copy

`Optimize-OfficePdf -Sanitize -PassThru` writes a sanitized file and returns its report. `Optimize-OfficePdf -PassThru` reports optimization actions and the size outcome. Neither should overwrite the only source copy in an auditable workflow.

The [sanitize-and-optimize recipe](https://github.com/EvotecIT/OfficeIMO/blob/3b680b1b6fb15a268ff5525a4ca6cdd70b2f6613/PowerShell/PSWriteOffice/Examples/Pdf/Recipe-Pdf-SanitizeAndOptimize.ps1) keeps the source, sanitized copy, and optimized delivery file separate.

To remove author names, comments and other metadata from PDF and Office files in one pass, see [Clean files before sharing](/docs/pswriteoffice/before-sharing/).

Visual black boxes are not automatically secure redactions. Use the redaction command and verify extracted content rather than relying on a stamp or shape to hide text.

<!-- PowerForge markdown source sha256:8542CBF1DBAAE3B8A6BCBC65F00CA7DE6C0BD3A97E7E4CFE4A2ABEB4A64A42F6; title=True -->

<!-- PowerForge markdown artifact sha256:62799F8A748DA0394CAE0ADBFCF9A381A63A4F965EAB80E0A0AD8587E6FEC8F6 -->
