Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Document-Processing-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,7 @@
<li><a href="/document-processing/pdf/pdf-viewer/maui/Magnification">Magnification</a></li>
<li><a href="/document-processing/pdf/pdf-viewer/maui/Text-Search">Text Search</a></li>
<li><a href="/document-processing/pdf/pdf-viewer/maui/Text-Selection">Text Selection</a></li>
<li><a href="/document-processing/pdf/pdf-viewer/maui/Redaction">Redaction</a></li>
<li><a href="/document-processing/pdf/pdf-viewer/maui/Form-Filling">Form Filling</a></li>
<li>
<a href="/document-processing/pdf/pdf-viewer/maui/Annotations-Overview">Annotations</a>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
173 changes: 173 additions & 0 deletions Document-Processing/PDF/PDF-Viewer/maui/Redaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
---
layout: post
title: Redaction in .NET MAUI PDF Viewer control | Syncfusion
description: Learn here all about Redaction in Syncfusion<sup>®</sup> .NET MAUI PDF Viewer (SfPdfViewer) control and its functionalities.
platform: document-processing
control: SfPdfViewer
documentation: ug
keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .net maui open pdf, maui pdf viewer, maui pdf view
---

# Redaction in .NET MAUI PDF Viewer (SfPdfViewer)

Redaction support of [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) allows you to conceal sensitive or confidential information in text and images within a PDF document. This ensures that private data, such as personal details or financial information, is securely hidden before sharing or publishing. Once redaction is applied and the document is resaved, the concealed content cannot be recovered.

## Types of Redactions

The PDF Viewer provides multiple methods to apply redaction, allowing you to securely conceal sensitive content based on different requirements. The available redaction types include:

- **Text-based Redaction** : Allows you to manually select the texts on a page and apply redaction to hide the texts.
- **Selected Area Redaction** : Allows you to manually select a rectangular area on a page and apply redaction to hide any content within that region.
- **Page-based Redaction** : Enables you to redact entire pages of a PDF document, ensuring that all content on those pages is permanently removed.


## Mark region to redact

You need to mark the region for redaction by using one of the available methods such as text-based, selected-area or page-based redaction.

## Mark regions for redaction using toolbar

The built-in toolbar includes a redaction tool that allows you to redact text, specific areas, or entire pages by marking the desired region on the PDF document and clicking the Apply button. The toolbar also provides options to modify redaction properties, such as the color and the text to display in the redacted area.

The following image represents how to perform redactions using the toolbar on the desktop.

![Redaction in desktop](Images/RedactionDesktop.gif)

The following image represents how to perform redactions using the toolbar on mobile.

![Redaction in mobile](Images/RedactionMobile.gif)

## Mark regions for redaction without using the toolbar

You can mark the region for redaction in a PDF document with UI interaction using touch or mouse using the `RedactionMode` property in the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). The following steps explain how to mark the region on a PDF.

1. Set the `RedactionMode` property of the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) to Text or Rect. It activates the text-based or selected-area Redaction mode on the control.
2. Place your finger (or mouse) on the text in the PDF document, where you want to start redaction.
3. Drag the finger (or cursor) across the text to select.
4. Complete adding the region to the selected text or area by releasing the finger (or cursor).
5. Once you have done that, set the `RedactionMode` to None. It will disable the redaction mode and save the marked region for redaction.
6. You can later redact the marked regions using `RedactAsync` method.

The following code explains how to enable the text-based redaction mode.

{% tabs %}
{% highlight C# %}
// Enable or activate the text-based redaction mode.
void EnableTextBasedRedactionMode()
{
// Set the redaction mode to text using the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) instance.
PdfViewer.RedactionMode = RedactionMode.Text;
}

// Enable or activate the area redaction mode.
void EnableSelectedAreaRedactionMode()
{
// Set the redaction mode to rect using the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) instance.
PdfViewer.RedactionMode = RedactionMode.Rect;
}
{% endhighlight %}
{% endtabs %}

Similarly, refer to the following code to disable the redaction mode.

{% tabs %}
{% highlight C# %}
//Disable redaction mode after marking the region.
void DisableRedactionMode()
{
// Set the redaction mode to none using the [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) instance.
PdfViewer.RedactionMode = RedactionMode.None;
}
{% endhighlight %}
{% endtabs %}

## How to perform redaction programmatically

### Add redaction mark on the PDF

You can mark regions for text or specific areas programmatically using the `AddRedactionMark` method of [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html), and redact entire pages using the `AddPageRedactionMarks` method. The following example demonstrates how to mark regions for redaction, such as a specific area and page in the PDF document.

{% tabs %}
{% highlight C# %}
void AddRedactionMarkOnSpecificRegionAndPages()
{
// Define the bounds of the area or text to redact (x, y, width, height) on page number 2.
RedactionMark redactionMark = new RedactionMark(new RectF(30, 40, 100, 100), 2);

// Set the appearance for the redaction mark.
redactionMark.MarkerBorderColor = Colors.Black; // Sets the marker border color
redactionMark.MarkerFillColor = Colors.Yellow; // Sets the marker fill color

// Add the redaction mark to the specified region.
PdfViewer.AddRedactionMark(redactionMark);

// Add redaction marks to specific pages (pages 3, 5, and 1).
PdfViewer.AddPageRedactionMarks(new List<int>([3, 5, 1]));
}
{% endhighlight %}
{% endtabs %}

### Remove the selected redaction mark on the PDF

You can remove a redaction mark for text, a specific area, or a page programmatically using the `SelectedRedactionMark` property and the `RemoveRedactionMark` method of SfPdfViewer. To remove a redaction mark, select the specific mark you want to delete and pass it to the `RemoveRedactionMark` method. The following example demonstrates how to remove a selected redaction mark from the PDF document.

{% tabs %}
{% highlight C# %}
void RemoveSelectedRedactionMark()
{
// Check if any redaction mark is currently selected.
if (PdfViewer.SelectedRedactionMark != null)
{
// Remove the selected redaction mark from the PDF.
PdfViewer.RemoveRedactionMark(PdfViewer.SelectedRedactionMark);
}
}
{% endhighlight %}
{% endtabs %}

### Remove all the redaction marks in the PDF

You can remove all redaction marks from a document programmatically by calling the `RemoveAllRedactionMarks` method. The following example demonstrates how to remove all redaction marks from a PDF document.

{% tabs %}
{% highlight C# %}
void RemoveAllRedactionMarksDrawn()
{
// Removes all the redaction marks from a PDF document using `RemoveAllRedactionMarks` method of [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html).
PdfViewer.RemoveAllRedactionMarks();
}
{% endhighlight %}
{% endtabs %}

### Redact the marked region

You can redact the marked regions by using the `RedactAsync` method of [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html). This method redacts all marked regions and saves the document, making the changes irreversible. The following example demonstrates how to redact a marked region or page in a PDF document.

{% tabs %}
{% highlight C# %}
private async void RedactMarkedRegion()
{
// Apply redaction to all marked regions in the PDF document.
await PdfViewer.RedactAsync();
}
{% endhighlight %}
{% endtabs %}

## Customize the default redaction appearance

In redaction mode, the redaction is applied with a default appearance and behavior. You can modify these settings before marking regions on the pages. To define the appearance and behavior, customize the default settings using the `RedactionSettings` property of [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html).
The following example demonstrates how to obtain the default redaction settings and modify their appearance properties. Similarly, you can modify other available properties.

{% tabs %}
{% highlight C# %}
void CustomizeDefaultRedactionSettings()
{
// Access the default redaction settings from the SfPdfViewer instance and modify the default appearance properties.
PdfViewer.RedactionSettings.MarkerBorderColor = Colors.Blue; // Border color for the marked region.
PdfViewer.RedactionSettings.FillColor = Colors.Red; // Fill color after redaction is applied.
PdfViewer.RedactionSettings.FontColor = Colors.Black; // Font color for overlay text.
PdfViewer.RedactionSettings.OverlayText = "text"; // Text to display on the redacted area.
PdfViewer.RedactionSettings.IsRepeat = true; // Repeat overlay text across the redacted area.
}
{% endhighlight %}
{% endtabs %}
28 changes: 28 additions & 0 deletions Document-Processing/PDF/PDF-Viewer/maui/Scrolling.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,31 @@ PdfViewer.ShowScrollHead = false;
{% endtabs %}

N> The scroll head is available only on **mobile platforms**. It is not supported on **Windows** or **macOS**.

## Render multiple pages while scrolling

When scrolling through large PDF documents, you may notice blank pages appearing temporarily while new pages are being rendered. This happens because the viewer renders pages on demand to optimize memory usage.

To minimize this and provide a smoother scrolling experience, the SfPdfViewer control offers the `OverscanCount` property. This property defines how many pages should be pre-rendered and kept in memory on each side of the current viewport. Increasing this value reduces the chance of blank pages during fast scrolling but may increase memory usage.

The following example shows how to set `OverscanCount` property:

{% tabs %}
{% highlight xaml %}
<syncfusion:SfPdfViewer x:Name="PdfViewer"
OverscanCount ="15" />
{% endhighlight %}

{% highlight c# %}
SfPdfViewer PdfViewer = new SfPdfViewer();

// Set the cache range (number of pages before and after the current viewport)
PdfViewer.OverscanCount = 15;

// Load a PDF document
PdfViewer.LoadDocument("sample.pdf");
{% endhighlight %}
{% endtabs %}

N> - Use a reasonable OverscanCount value. Large values can cause memory spikes and app freezes.
N> - Pages with very high resolution may still render slowly due to native rendering limitations.
6 changes: 5 additions & 1 deletion Document-Processing/PDF/PDF-Viewer/maui/Signature.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ keywords: .net maui pdf viewer, .net maui view pdf, pdf viewer in .net maui, .ne

# Electronic Signature in .NET MAUI PDF Viewer (SfPdfViewer)

The electronic signature feature of [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) allows you to add, remove signatures in the PDF document. This section will go through the various types and functions available in PDF Viewer for working with signature.
The electronic signature feature of [SfPdfViewer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.PdfViewer.SfPdfViewer.html) allows you to add, remove signatures in the PDF document. This section will go through the various types and functions available in PDF Viewer for working with signature.

You can also watch our video tutorial below to learn about working with electronic signatures.

<style>#MAUISfPdfViewerVideoTutorial{width : 90% !important; height: 400px !important }</style> <iframe id='MAUISfPdfViewerVideoTutorial' src='https://www.youtube.com/embed/XinSyPuloqw'></iframe>

## Types of electronic signature

Expand Down