> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/core/redaction/redact.md).

# Redact a PDF document on Server/Desktop

Learn how to redact content from a PDF document using Apryse SDK API. Remove sensitive data securely with pdftron.PDF.Redactor. Control redaction style and more. The Apryse Server SDK streamlines secu

{% hint style="info" %}
**Requirements**

*These packages are required to use these features in production. Trial keys have unlimited access to all features*

<a href="https://apryse.com/capabilities#Redaction" class="button primary">Package: Redaction</a><a href="https://showcase.apryse.com/redaction" class="button primary">Live demo</a>
{% endhint %}

To redact content from a PDF document.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
ArrayList rarr = new ArrayList();
rarr.Add(new Redactor.Redaction(1, new Rect(100, 100, 550, 600), false, "Top Secret"));
rarr.Add(new Redactor.Redaction(2, new Rect(30, 30, 450, 450), true, "Negative Redaction"));
rarr.Add(new Redactor.Redaction(2, new Rect(0, 0, 100, 100), false, "Positive"));
rarr.Add(new Redactor.Redaction(2, new Rect(100, 100, 200, 200), false, "Positive"));
rarr.Add(new Redactor.Redaction(2, new Rect(300, 300, 400, 400), false, ""));
rarr.Add(new Redactor.Redaction(2, new Rect(500, 500, 600, 600), false, ""));
rarr.Add(new Redactor.Redaction(3, new Rect(0, 0, 700, 20), false, ""));

Redactor.Appearance app = new Redactor.Appearance();
app.RedactionOverlay = true;
app.Border = false;
app.ShowRedactedContentRegions = true;

PDFDoc doc = new PDFDoc(input_path + "newsletter.pdf");
Redactor.Redact(doc, rarr, app, false, true);
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
vector<Redactor::Redaction> vec;
vec.push_back(Redactor::Redaction(1, Rect(100, 100, 550, 600), false, "Top Secret"));
vec.push_back(Redactor::Redaction(2, Rect(30, 30, 450, 450), true, "Negative Redaction"));
vec.push_back(Redactor::Redaction(2, Rect(0, 0, 100, 100), false, "Positive"));
vec.push_back(Redactor::Redaction(2, Rect(100, 100, 200, 200), false, "Positive"));
vec.push_back(Redactor::Redaction(2, Rect(300, 300, 400, 400), false, ""));
vec.push_back(Redactor::Redaction(2, Rect(500, 500, 600, 600), false, ""));
vec.push_back(Redactor::Redaction(3, Rect(0, 0, 700, 20), false, ""));

Redactor::Appearance app;
app.RedactionOverlay = true;
app.Border = false;
app.ShowRedactedContentRegions = true;

PDFDoc doc(filename);
Redactor::Redact(doc, vec, app, false, true);
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
vec := NewVectorRedaction()
vec.Add(NewRedaction(1, NewRect(100.0, 100.0, 550.0, 600.0), false, "Top Secret"))
vec.Add(NewRedaction(2, NewRect(30.0, 30.0, 450.0, 450.0), true, "Negative Redaction"))
vec.Add(NewRedaction(2, NewRect(0.0, 0.0, 100.0, 100.0), false, "Positive"))
vec.Add(NewRedaction(2, NewRect(100.0, 100.0, 200.0, 200.0), false, "Positive"))
vec.Add(NewRedaction(2, NewRect(300.0, 300.0, 400.0, 400.0), false, ""))
vec.Add(NewRedaction(2, NewRect(500.0, 500.0, 600.0, 600.0), false, ""))
vec.Add(NewRedaction(3, NewRect(0.0, 0.0, 700.0, 20.0), false, ""))

app := NewAppearance() 
app.SetRedactionOverlay(true)
app.SetBorder(false)
app.SetShowRedactedContentRegions(true)

doc := NewPDFDoc(filename)
Redact(doc, vec, app, false, true)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
Redactor.Redaction[] rarr = new Redactor.Redaction[7];
rarr[0] = new Redactor.Redaction(1, new Rect(100, 100, 550, 600), false, "Top Secret");
rarr[1] = new Redactor.Redaction(2, new Rect(30, 30, 450, 450), true, "Negative Redaction");
rarr[2] = new Redactor.Redaction(2, new Rect(0, 0, 100, 100), false, "Positive");
rarr[3] = new Redactor.Redaction(2, new Rect(100, 100, 200, 200), false, "Positive");
rarr[4] = new Redactor.Redaction(2, new Rect(300, 300, 400, 400), false, "");
rarr[5] = new Redactor.Redaction(2, new Rect(500, 500, 600, 600), false, "");
rarr[6] = new Redactor.Redaction(3, new Rect(0, 0, 700, 20), false, "");

Redactor.Appearance app = new Redactor.Appearance();
app.redactionOverlay = true;
app.border = false;
app.showRedactedContentRegions = true;

PDFDoc doc = new PDFDoc(filename);
Redactor.redact(doc, rarr, app, false, true);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
async function main() {
    const rarr = []; // we will contain a list of redaction objects in this array
    rarr.push(await PDFNet.Redactor.redactionCreate(1, (await PDFNet.Rect.init(100, 100, 550, 600)), false, 'Top Secret'));
    rarr.push(await PDFNet.Redactor.redactionCreate(2, (await PDFNet.Rect.init(30, 30, 450, 450)), true, 'Negative Redaction'));
    rarr.push(await PDFNet.Redactor.redactionCreate(2, (await PDFNet.Rect.init(0, 0, 100, 100)), false, 'Positive'));
    rarr.push(await PDFNet.Redactor.redactionCreate(2, (await PDFNet.Rect.init(100, 100, 200, 200)), false, 'Positive'));
    rarr.push(await PDFNet.Redactor.redactionCreate(2, (await PDFNet.Rect.init(300, 300, 400, 400)), false, ''));
    rarr.push(await PDFNet.Redactor.redactionCreate(2, (await PDFNet.Rect.init(500, 500, 600, 600)), false, ''));
    rarr.push(await PDFNet.Redactor.redactionCreate(3, (await PDFNet.Rect.init(0, 0, 700, 20)), false, ''));

    const app = {};
    app.redaction_overlay = true;
    app.border = false;
    app.show_redacted_content_regions = true;

    const doc = await PDFNet.PDFDoc.createFromURL(filename);
    PDFNet.Redactor.redact(doc, rarr, app, false, false);
}
PDFNet.runWithCleanup(main);
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
val rarr = arrayOfNulls<Redactor.Redaction>(6)
rarr[0] = Redactor.Redaction(1, Rect(0.0, 0.0, 600.0, 600.0), false, "Top Secret")
rarr[1] = Redactor.Redaction(2, Rect(0.0, 0.0, 100.0, 100.0), false, "foo")
rarr[2] = Redactor.Redaction(2, Rect(100.0, 100.0, 200.0, 200.0), false, "bar")
rarr[3] = Redactor.Redaction(2, Rect(300.0, 300.0, 400.0, 400.0), false, "")
rarr[4] = Redactor.Redaction(2, Rect(500.0, 500.0, 600.0, 600.0), false, "")
rarr[5] = Redactor.Redaction(3, Rect(0.0, 0.0, 700.0, 20.0), false, "")

val app = Redactor.Appearance()
app.redactionOverlay = true
app.border = false
app.showRedactedContentRegions = true

val doc = PDFDoc(filename)
Redactor.redact(doc, rarr, app, false, true)
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objc
PTVectorRedaction *vec = [[PTVectorRedaction alloc] init];
[vec add: [[PTRedaction alloc] initWithPage_num: 1 bbox: [[[PTPDFRect alloc] init] Set: 100 y1: 100 x2: 550 y2: 600] negative: NO text: @"Top Secret"]];
[vec add: [[PTRedaction alloc] initWithPage_num: 2 bbox: [[[PTPDFRect alloc] init] Set: 30 y1: 30 x2: 450 y2: 450] negative: YES text: @"Negative Redaction"]];
[vec add: [[PTRedaction alloc] initWithPage_num: 2 bbox: [[[PTPDFRect alloc] init] Set: 0 y1: 0 x2: 100 y2: 100] negative: NO text: @"Positive"]];
[vec add: [[PTRedaction alloc] initWithPage_num: 2 bbox: [[[PTPDFRect alloc] init] Set: 100 y1: 100 x2: 200 y2: 200] negative: NO text: @"Positive"]];
[vec add: [[PTRedaction alloc] initWithPage_num: 2 bbox: [[[PTPDFRect alloc] init] Set: 300 y1: 300 x2: 400 y2: 400] negative: NO text: @""]];
[vec add: [[PTRedaction alloc] initWithPage_num: 2 bbox: [[[PTPDFRect alloc] init] Set: 500 y1: 500 x2: 600 y2: 600] negative: NO text: @""]];
[vec add: [[PTRedaction alloc] initWithPage_num: 3 bbox: [[[PTPDFRect alloc] init] Set: 0 y1: 0 x2: 700 y2: 20] negative: NO text: @""]];
        
PTAppearance *app = [[PTAppearance alloc] init];
[app setRedactionOverlay: YES];
[app setBorder: NO];
[app setShowRedactedContentRegions: YES];

PTPDFDoc *doc = [[PTPDFDoc alloc] initWithFilepath: filename];
[PTRedactor Redact: doc red_arr: vec app: app ext_neg_mode: NO page_coord_sys: YES];
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
let vec: PTVectorRedaction = PTVectorRedaction()
vec.add(PTRedaction(page_num: 1, bbox: PTPDFRect(x1: 100, y1: 100, x2: 550, y2: 600), negative: false, text: "Top Secret"))
vec.add(PTRedaction(page_num: 2, bbox: PTPDFRect(x1: 30, y1: 30, x2: 450, y2: 450), negative: true, text: "Negative Redaction"))
vec.add(PTRedaction(page_num: 2, bbox: PTPDFRect(x1: 0, y1: 0, x2: 100, y2: 100), negative: false, text: "Positive"))
vec.add(PTRedaction(page_num: 2, bbox: PTPDFRect(x1: 100, y1: 100, x2: 200, y2: 200), negative: false, text: "Positive"))
vec.add(PTRedaction(page_num: 2, bbox: PTPDFRect(x1: 300, y1: 300, x2: 400, y2: 400), negative: false, text: ""))
vec.add(PTRedaction(page_num: 2, bbox: PTPDFRect(x1: 500, y1: 500, x2: 600, y2: 600), negative: false, text: ""))
vec.add(PTRedaction(page_num: 3, bbox: PTPDFRect(x1: 0, y1: 0, x2: 700, y2: 20), negative: false, text: ""))

let app: PTAppearance = PTAppearance()
app.setRedactionOverlay(true)
app.setBorder(false)
app.setShowRedactedContentRegions(true)

let doc: PTPDFDoc = PTPDFDoc(filepath: filename)
PTRedactor.redact(doc, red_arr: vec, app: app, ext_neg_mode: false, page_coord_sys: true)
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$vec = new VectorRedaction();
$vec->push(new Redaction(1, new Rect(0.0, 0.0, 600.0, 600.0), false, "Top Secret"));
$vec->push(new Redaction(2, new Rect(0.0, 0.0, 100.0, 100.0), false, "foo"));
$vec->push(new Redaction(2, new Rect(100.0, 100.0, 200.0, 200.0), false, "bar"));
$vec->push(new Redaction(2, new Rect(300.0, 300.0, 400.0, 400.0), false, ""));
$vec->push(new Redaction(2, new Rect(500.0, 500.0, 600.0, 600.0), false, ""));
$vec->push(new Redaction(3, new Rect(0.0, 0.0, 700.0, 20.0), false, ""));

$doc = new PDFDoc($filename);
Redactor::Redact($doc, $vec);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
vec = VectorRedaction()
vec.append(Redaction(1, Rect(100, 100, 550, 600), False, "Top Secret"))
vec.append(Redaction(2, Rect(30, 30, 450, 450), True, "Negative Redaction"))
vec.append(Redaction(2, Rect(0, 0, 100, 100), False, "Positive"))
vec.append(Redaction(2, Rect(100, 100, 200, 200), False, "Positive"))
vec.append(Redaction(2, Rect(300, 300, 400, 400), False, ""))
vec.append(Redaction(2, Rect(500, 500, 600, 600), False, ""))
vec.append(Redaction(3, Rect(0, 0, 700, 20), False, ""))

app = Appearance() 
app.RedactionOverlay = True
app.Border = False
app.ShowRedactedContentRegions = True

doc = PDFDoc(filename)
Redactor.Redact(doc, vec, app, False, True)
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
vec = [
    Redaction.new(1, Rect.new(100, 100, 550, 600), false, "Top Secret"),
    Redaction.new(2, Rect.new(30, 30, 450, 450), true, "Negative Redaction"),
    Redaction.new(2, Rect.new(0, 0, 100, 100), false, "Positive"),
    Redaction.new(2, Rect.new(100, 100, 200, 200), false, "Positive"),
    Redaction.new(2, Rect.new(300, 300, 400, 400), false, ""),
    Redaction.new(2, Rect.new(500, 500, 600, 600), false, ""),
    Redaction.new(3, Rect.new(0, 0, 700, 20), false, "")
]

app = Appearance.new
app.RedactionOverlay = true
app.Border = false
app.ShowRedactedContentRegions = true

doc = PDFDoc.new(filename)
Redactor.Redact(doc, vec, app, false, true)
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
Dim rarr As ArrayList = New ArrayList
rarr.Add(New Redactor.Redaction(1, New Rect(100, 100, 550, 600), False, "Top Secret"))
rarr.Add(New Redactor.Redaction(2, New Rect(30, 30, 450, 450), True, "Negative Redaction"))
rarr.Add(New Redactor.Redaction(2, New Rect(0, 0, 100, 100), False, "Positive"))
rarr.Add(New Redactor.Redaction(2, New Rect(100, 100, 200, 200), False, "Positive"))
rarr.Add(New Redactor.Redaction(2, New Rect(300, 300, 400, 400), False, ""))
rarr.Add(New Redactor.Redaction(2, New Rect(500, 500, 600, 600), False, ""))
rarr.Add(New Redactor.Redaction(3, New Rect(0, 0, 700, 20), False, ""))

Dim app As Redactor.Appearance = New Redactor.Appearance()
app.RedactionOverlay = True
app.Border = False
app.ShowRedactedContentRegions = True

Dim doc As PDFDoc = New PDFDoc(filename)
Redactor.Redact(doc, rarr, app, False, True)
```

{% endcode %}
{% endtab %}
{% endtabs %}

[PDF redaction](/core/get-started/samples/pdfredacttest.md) Full code sample which shows how to use `pdftron.PDF.Redactor` to remove potentially sensitive content within PDF documents. Code sample is available in C++, C#, Java, Python, Go, PHP, Ruby & VB.

## About redactor

Apryse Redactor makes sure that if a portion of an image, text, or vector graphics is contained in a redaction region, that portion of the image or path data is destroyed and is not hidden with clipping or image masks. Apryse SDK API can also be used to review and remove metadata and other content that can exist in a PDF document, including XML Forms Architecture (XFA) content and Extensible Metadata Platform (XMP) content.

The redaction process in Apryse SDK consists of two steps:

**1. Content identification** A user applies redact annotations that specify the pieces or regions of content that should be removed. The content for redaction can be identified either interactively (e.g. using ‘pdftron.PDF.PDFViewCtrl’ as shown in PDFView sample) or programmatically (e.g. using ‘pdftron.PDF.TextSearch’ or ‘pdftron.PDF.TextExtractor’). Up until the next step is performed, the user can see, move and redefine these annotations.

**2. Content removal** Using ‘pdftron.PDF.Redactor.Redact()’ the user instructs Apryse SDK to apply the redact regions, after which the content in the area specified by the redact annotations is removed. The redaction function includes number of options to control the style of the redaction overlay (including color, text, font, border, transparency, etc.).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/core/redaction/redact.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
