Redacting PDF areas
PDF redaction permanently removes sensitive information from a document. Use it when you need to share or archive files without exposing confidential content.
This guide shows how to:
- Load a PDF
- Define a redaction rectangle by coordinates
- Apply permanent redaction
- Save the sanitized output
Prepare the project
Register the SDK license before running redaction operations. For setup details, refer to the getting started with .NET SDK guide.
using GdPicture14;
LicenseManager licence = new LicenseManager();licence.RegisterKEY(""); // Set your license keyLoad the PDF document
Create a GdPicturePDF instance and load the source file:
using GdPicturePDF pdf = new GdPicturePDF();pdf.LoadFromFile(@"input.pdf");Define a redaction region
Add a rectangular region to redact:
pdf.AddRedactionRegion(72, 707, 40, 14);Parameters use PDF coordinates:
- X position
- Y position
- Width
- Height
Apply the redaction
Apply all queued redaction regions:
pdf.ApplyRedaction();This operation removes content inside the defined regions from the PDF structure.
Save the redacted document
Write the redacted output file:
pdf.SaveToFile(@"output.pdf");Coordinate system reference
PDF coordinates use points:
- Origin
(0,0)— Bottom-left corner 72points = one inch- X axis increases left to right
- Y axis increases bottom to top
Additional redaction options
Extend this workflow with:
- Multiple
AddRedactionRegioncalls beforeApplyRedaction - Custom redaction colors
- Text-driven redaction
- Annotation redaction
Error handling and validation
In production, add checks for:
- Input file existence and file type
- Operation status after each call
- Redaction bounds within page size
- Post-redaction verification for sensitive fields
For status-handling patterns, refer to the handling errors with .NET SDK guide.
Security notes
Before distribution:
- Verify that every instance of sensitive content is redacted
- Confirm that content can’t be recovered through selection or extraction
- Sanitize metadata if needed
- Secure both the original and redacted document versions
Conclusion
This workflow redacts fixed PDF areas and generates a sanitized output file for secure sharing.