# Redact PDFs using coordinates in C#

Nutrient.NET SDK (formerly GdPicture.NET) enables you to specify areas in a document and permanently redact these areas.

## Alternative minimal pipeline

If you want a concise coordinate-based redaction flow, this snippet applies one redaction region and saves the redacted PDF:

```csharp

using GdPicture14;

LicenseManager licence = new LicenseManager();
licence.RegisterKEY("");

using GdPicturePDF pdf = new GdPicturePDF();
pdf.LoadFromFile(@"input.pdf");
pdf.AddRedactionRegion(72, 707, 40, 14);
pdf.ApplyRedaction();
pdf.SaveToFile(@"output.pdf");

```

## Redacting by coordinates

To redact areas in a document using coordinates, follow these steps:

1. Create a `GdPicturePDF` object.

2. Select the source PDF file by passing its path to the `LoadFromFile` method of the `GdPicturePDF` object.

3. Specify each area to redact in the following way:
   - Select the page with the area to redact with the `SelectPage` method of the `GdPicturePDF` object.
   - Specify the coordinates of the area with the `AddRedactionRegion` method of the `GdPicturePDF` object. By default, the origin of the coordinate system is the bottom-left corner. This method takes four parameters:
     - The horizontal coordinate of the bottom-left corner of the rectangular area in points.
     - The vertical coordinate of the bottom-left corner of the rectangular area in points.
     - The width of the rectangular area in points.
     - The height of the rectangular area in points.
       For more information on changing the default settings, see [Setting the Coordinate System Origin](#setting-the-coordinate-system-origin) and [Setting the Measurement Unit](#setting-the-measurement-unit).

4. Run the redaction process with the `ApplyRedaction` method of the `GdPicturePDF` object.

5. Save the output in a PDF document with the `SaveToFile` method.

The example below loads a PDF document, redacts the specified areas, and then saves the redacted file in a PDF:

### C#

```csharp

using GdPicturePDF gdpicturePDF = new GdPicturePDF();
// Load the source document.
gdpicturePDF.LoadFromFile(@"C:\temp\source.pdf");
// Specify the areas to redact.
gdpicturePDF.SelectPage(1);
gdpicturePDF.AddRedactionRegion(120, 300, 140, 20);
gdpicturePDF.SelectPage(2);
gdpicturePDF.AddRedactionRegion(100, 280, 70, 15);
// Run the redaction process.
gdpicturePDF.ApplyRedaction();
// Save the output in a PDF document.
gdpicturePDF.SaveToFile(@"C:\temp\output.pdf");

```

### VB.NET

```vb

Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    ' Load the source document.
    gdpicturePDF.LoadFromFile("C:\temp\source.pdf")
    ' Specify the areas to redact.
    gdpicturePDF.SelectPage(1)
    gdpicturePDF.AddRedactionRegion(120, 300, 140, 20)
    gdpicturePDF.SelectPage(2)
    gdpicturePDF.AddRedactionRegion(100, 280, 70, 15)
    ' Run the redaction process.
    gdpicturePDF.ApplyRedaction()
    ' Save the output in a PDF document.
    gdpicturePDF.SaveToFile("C:\temp\output.pdf")
End Using

```

#### Used methods

- [`AddRedactionRegion`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~AddRedactionRegion.html)

- [`LoadFromFile`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~LoadFromFile.html)

- [`SelectPage`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~SelectPage.html)

- [`SetOrigin`]

- [`SaveToFile`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~SaveToFile.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)

## Setting the coordinate system origin

To set the origin of the coordinate system, use the [`SetOrigin`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPicturePDF~SetOrigin.html) method of the `GdPicturePDF` object. This method takes a member of the `PdfOrigin` enumeration as its parameter. For example, to set the origin to the top left, call `gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)`.

The reference point for the first two parameters of the `AddRedactionRegion` method is the point of the rectangle that's closest to the origin. If you define a different origin for the coordinate system, the reference point also changes. For example, if the origin is the top-right corner of the document, then the first two parameters of the `AddRedactionRegion` method define the coordinates of the top-right corner of the rectangular area that is to be redacted.

## Setting the measurement unit

Each parameter of the `AddRedactionRegion` method is expressed in the unit of measurement specified by the [`SetMeasurementUnit`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~SetMeasurementUnit.html) method. The default unit of measurement is points. To change the unit of measurement, use the `SetMeasurementUnit` method. This method takes a member of the `PdfMeasurementUnit` enumeration as its parameter. For example, to set the unit of measurement to centimeters, call `gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)`.
---

## Related pages

- [Redact PDFs in C#.NET](/guides/dotnet/redaction.md)
- [Search and redact PDFs in C#](/guides/dotnet/redaction/search-and-redact.md)
- [Smart redaction in C#](/guides/dotnet/redaction/smart-redaction.md)

