-
Notifications
You must be signed in to change notification settings - Fork 10
983750: Separated Redaction in separate section. #1493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3734d74
983750: Separated Redaction in separate section.
SF4524LogeshKumar 268e65f
1234: Updated Toc
SF4524LogeshKumar 1477fca
983750: Redaction Updated image names properly
SF4524LogeshKumar 3b0dfcd
983750: Update create-programmatically.md
SF4524LogeshKumar 6cd9deb
1234: Updated Image names
SF4524LogeshKumar 88f0e2b
9876: Updated Image names
SF4524LogeshKumar 3c239d1
98765: Updated proper image location
SF4524LogeshKumar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
354 changes: 0 additions & 354 deletions
354
Document-Processing/PDF/PDF-Viewer/blazor/annotation/redaction-annotation.md
This file was deleted.
Oops, something went wrong.
233 changes: 233 additions & 0 deletions
233
Document-Processing/PDF/PDF-Viewer/blazor/redaction/create-programmatically.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,233 @@ | ||
| --- | ||
| layout: post | ||
| title: Programmatic redaction in Blazor SfPdfViewer | Syncfusion | ||
| description: Learn how to add, edit, delete, and apply redaction annotations programmatically in the Syncfusion Blazor SfPdfViewer component. | ||
| platform: document-processing | ||
| control: SfPdfViewer | ||
| documentation: ug | ||
| --- | ||
|
|
||
| # Programmatic Support for Redaction in Blazor PDF Viewer | ||
|
|
||
| ## Add redaction annotations programmatically | ||
|
|
||
| Use the [`AddAnnotationAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.PdfViewer.SfPdfViewer2.html#Syncfusion_Blazor_PdfViewer_SfPdfViewer2_AddAnnotationAsync_Syncfusion_Blazor_PdfViewer_PdfAnnotation_) method to add a redaction annotation by creating a [`PdfAnnotation`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.PdfViewer.PdfAnnotation.html) instance. Configure redaction-specific settings with [`RedactionProperties`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.PdfViewer.RedactionProperties.html). | ||
|
|
||
| The example below creates a redaction annotation with custom appearance, redaction options, and position on the first page. | ||
|
|
||
| ```cshtml | ||
| @page "/" | ||
|
|
||
| <SfButton OnClick="AddRedactionAnnotation">Add Redaction Annotation</SfButton> | ||
| <SfPdfViewer2 @ref="SfPdfViewer2" DocumentPath="@DocumentPath" Height="800px" Width="100%"> | ||
| </SfPdfViewer2> | ||
|
|
||
| @code{ | ||
|
|
||
| private string DocumentPath { get; set; } = "wwwroot/data/Annotations.pdf"; | ||
| private SfPdfViewer2? SfPdfViewer2; | ||
|
|
||
| // Adds a redaction annotation to the first page of the PDF Viewer | ||
| private async void AddRedactionAnnotation() | ||
| { | ||
| // Create a redaction annotation with custom appearance and properties | ||
| PdfAnnotation annotation = new PdfAnnotation() | ||
| { | ||
| Id = "redaction_Annotation", | ||
| FontSize = 20, | ||
| Bound = new Bound() | ||
| { | ||
| X = 200, | ||
| Y = 80, | ||
| Width = 150, | ||
| Height = 75 | ||
| }, | ||
| PageNumber = 0, | ||
|
|
||
| // Configure redaction-specific properties | ||
| AnnotationProperties = new RedactionProperties() | ||
| { | ||
| MarkerFillColor = "#FF00FF", | ||
| MarkerOpacity = 0.5, | ||
| MarkerBorderColor = "#233A77", | ||
| OverlayText = "Hello", | ||
| IsRepeat = false | ||
| }, | ||
|
|
||
| // Set the font and fill style | ||
| FontColor = "#0000FF", | ||
| FontFamily = "Courier", | ||
| FillColor = "#EEEEEE", | ||
|
|
||
| // Specify the annotation type | ||
| Type = AnnotationType.Redaction | ||
| }; | ||
|
|
||
| // Add the annotation to the PDF Viewer | ||
| await SfPdfViewer2.AddAnnotationAsync(annotation); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
|  | ||
|
|
||
| The `RedactionProperties` settings control the annotation’s appearance and behavior: `MarkerFillColor` (overlay color), `MarkerOpacity` (0–1), `MarkerBorderColor` (border color), `OverlayText` (text over the redacted area), and `IsRepeat` (repeat overlay text across the area). | ||
|
|
||
| ## Delete redaction annotations programmatically | ||
|
|
||
| Delete redaction annotations programmatically using the [`DeleteAnnotationAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_DeleteAnnotationsAsync) method by passing the annotation ID or object reference. | ||
|
|
||
| For additional examples, see [Delete annotation programmatically](./text-markup-annotation#delete-annotation-programmatically). | ||
|
|
||
| ## Update redaction annotation properties programmatically | ||
|
|
||
| To update an existing redaction annotation, first retrieve it using [`GetAnnotationsAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.PdfViewer.SfPdfViewer2.html#Syncfusion_Blazor_PdfViewer_SfPdfViewer2_GetAnnotationsAsync), then modify the required properties and apply the changes using [`EditAnnotationAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.PdfViewer.SfPdfViewer2.html#Syncfusion_Blazor_PdfViewer_SfPdfViewer2_EditAnnotationAsync_Syncfusion_Blazor_PdfViewer_PdfAnnotation_). | ||
|
|
||
| The following example retrieves an existing redaction annotation, updates properties such as overlay text, colors, and opacity along with general appearance settings, and then applies the changes using [`EditAnnotationAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.PdfViewer.SfPdfViewer2.html#Syncfusion_Blazor_PdfViewer_SfPdfViewer2_EditAnnotationAsync_Syncfusion_Blazor_PdfViewer_PdfAnnotation_). | ||
|
|
||
| ```cshtml | ||
| @page "/" | ||
|
|
||
| <SfButton OnClick="EditRedaction">Edit Redaction</SfButton> | ||
|
|
||
| <SfPdfViewer2 @ref="SfPdfViewer2" DocumentPath="@DocumentPath" Height="800px" Width="100%"> | ||
| </SfPdfViewer2> | ||
|
|
||
| @code{ | ||
| private string DocumentPath { get; set; } = "wwwroot/data/Annotations.pdf"; | ||
| private SfPdfViewer2? SfPdfViewer2; | ||
| // Updates the first redaction annotation's properties in the PDF Viewer | ||
| private async void EditRedaction() | ||
| { | ||
| // Retrieve all annotations from the viewer | ||
| List<PdfAnnotation> annotations = await SfPdfViewer2.GetAnnotationsAsync(); | ||
|
|
||
| // Get the first annotation to update | ||
| PdfAnnotation annotation = annotations[0]; | ||
|
|
||
| // Check if the annotation is a redaction type and update redaction-specific properties | ||
| if (annotation.AnnotationProperties is RedactionProperties redaction) | ||
| { | ||
| redaction.OverlayText = "Updated Text"; | ||
| redaction.MarkerFillColor = "#9bc7b8"; | ||
| redaction.MarkerBorderColor = "#888f8c"; | ||
| redaction.IsRepeat = true; | ||
| redaction.MarkerOpacity = 0.2; | ||
| } | ||
|
|
||
| // Update general annotation properties | ||
| annotation.FontSize = 15; | ||
| annotation.FontColor = "Yellow"; | ||
| annotation.TextAlignment = TextAlignment.Left; | ||
|
|
||
| // Apply the changes to the annotation in the viewer | ||
| await SfPdfViewer2.EditAnnotationAsync(annotation); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
|  | ||
|
|
||
| ## Add page redactions programmatically | ||
|
|
||
| Entire pages can be marked for redaction using the [`AddPageRedactionsAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.PdfViewer.SfPdfViewer2.html#Syncfusion_Blazor_PdfViewer_SfPdfViewer2_AddPageRedactionsAsync_System_Collections_Generic_List_System_Int32__) method. | ||
|
|
||
| This is useful when the full page contains confidential data. | ||
|
|
||
| The following example adds redaction annotations to specific pages in a PDF using 0-based page indexes. Here, redaction is applied to the first and third pages. | ||
|
|
||
| ```cshtml | ||
| @page "/" | ||
|
|
||
| <SfButton OnClick="RedactPages">Add Redact Pages</SfButton> | ||
|
|
||
| <SfPdfViewer2 @ref="SfPdfViewer2" DocumentPath="@DocumentPath" Height="800px" Width="100%"> | ||
| </SfPdfViewer2> | ||
|
|
||
| @code{ | ||
|
|
||
| private string DocumentPath { get; set; } = "wwwroot/data/Annotations.pdf"; | ||
|
|
||
| private SfPdfViewer2? SfPdfViewer2; | ||
|
|
||
| // Adds redaction annotations to entire pages using 0-based page indexes. | ||
| // In this example, redaction is applied to the first (0) and third (2) pages. | ||
| private async void RedactPages() | ||
| { | ||
| List<int> pagesToRedact = new() { 0, 2 }; // Page indexes start from 0 | ||
| await SfPdfViewer2.AddPageRedactionsAsync(pagesToRedact); | ||
| } | ||
|
|
||
| } | ||
| ``` | ||
|
|
||
|  | ||
|
|
||
| ## Apply redaction programmatically | ||
|
|
||
| Use the [`RedactAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.PdfViewer.SfPdfViewer2.html#Syncfusion_Blazor_PdfViewer_SfPdfViewer2_RedactAsync) method to apply all redaction annotations. | ||
|
|
||
| Note: Applying redaction is permanent and cannot be undone. Consider saving a copy of the document before applying redaction. | ||
|
|
||
| ```cshtml | ||
| @page "/" | ||
|
|
||
| <SfButton OnClick="ApplyRedaction">Apply Redaction</SfButton> | ||
|
|
||
| <SfPdfViewer2 @ref="SfPdfViewer2" DocumentPath="@DocumentPath" Height="800px" Width="100%"> | ||
| </SfPdfViewer2> | ||
|
|
||
| @code{ | ||
| private string DocumentPath { get; set; } = "wwwroot/data/Annotations.pdf"; | ||
| private SfPdfViewer2? SfPdfViewer2; | ||
|
|
||
| // Applies all redaction annotations permanently | ||
| private async void ApplyRedaction() | ||
| { | ||
| await SfPdfViewer2.RedactAsync(); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
|  | ||
|
|
||
| ## Configure default redaction annotation properties | ||
|
|
||
| Use [`PdfViewerRedactionSettings`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.PdfViewer.PdfViewerRedactionSettings.html) inside the viewer to set default redaction properties for newly created annotations, including fill color, overlay text, font style, and alignment. | ||
|
|
||
| These defaults apply to newly added annotations created from the toolbar unless overridden. | ||
|
|
||
| The following example shows how to set default properties for redaction annotations using [`PdfViewerRedactionSettings`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.PdfViewer.PdfViewerRedactionSettings.html). | ||
|
|
||
| ```cshtml | ||
| @* | ||
| This component demonstrates how to configure default redaction annotation settings | ||
| in the Syncfusion Blazor PDF Viewer. | ||
| *@ | ||
| <SfPdfViewer2 @ref="SfPdfViewer2" DocumentPath="@DocumentPath" Height="800px" Width="100%"> | ||
| <PdfViewerRedactionSettings OverlayText="Confidential" | ||
| MarkerFillColor="#FF0000" | ||
| MarkerBorderColor="#000000" | ||
| IsRepeat="false" | ||
| FillColor="#F8F8F8" | ||
| FontColor="#333333" | ||
| FontSize="14" | ||
| FontFamily="Symbol" | ||
| TextAlignment="TextAlignment.Right" /> | ||
| <PdfViewerToolbarSettings ToolbarItems="ToolbarItems" MobileToolbarItems="MobileToolbarItems"></PdfViewerToolbarSettings> | ||
| </SfPdfViewer2> | ||
| ``` | ||
|
|
||
| ## Redaction property panel | ||
|
|
||
| When no annotation is selected, the property panel displays default values from [`PdfViewerRedactionSettings`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.PdfViewer.PdfViewerRedactionSettings.html). When a redaction is selected, it shows the selected annotation’s properties. | ||
|
|
||
| Use the panel to update overlay text, font settings, opacity, and related options. | ||
|
|
||
|  | ||
|
|
||
| ## See also | ||
|
|
||
| * [Overview of redaction](./overview) | ||
| * [Interact with redaction using the UI](./ui-interactions) | ||
| * [Redaction in mobile view](./redaction-in-mobileView) |
76 changes: 76 additions & 0 deletions
76
Document-Processing/PDF/PDF-Viewer/blazor/redaction/overview.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| --- | ||
| layout: post | ||
| title: Redaction in Blazor PDF Viewer | Syncfusion | ||
| description: Learn how to add, delete, redact pages, and apply redaction in the Syncfusion Blazor PDF Viewer, including comments and import/export. | ||
| platform: document-processing | ||
| control: SfPdfViewer | ||
| documentation: ug | ||
| --- | ||
|
|
||
| # Redaction annotations in Blazor SfPdfViewer Component | ||
|
|
||
| Redaction annotations conceal sensitive content in a PDF. The Syncfusion Blazor PDF Viewer (SfPdfViewer) supports both interactive and programmatic redaction with customizable appearance and a one-click final apply action. | ||
|
|
||
| N> Prerequisites: Add the SfPdfViewer component to the Blazor app and ensure the redaction feature is available in the used version. Redaction permanently removes content when applied. | ||
|
|
||
|  | ||
|
|
||
| ## Add a Redaction annotation to the PDF document | ||
|
|
||
| The redaction feature hides sensitive information by adding redaction annotations to pages. Annotations can be added from the toolbar or programmatically. | ||
|
|
||
| Click the Redaction tool on the toolbar and draw over the content to redact. After marking, optionally show overlay text (for example, "Confidential") and customize appearance, including fill color, border color, and opacity. | ||
|
|
||
|  | ||
|
|
||
| ## Delete Redaction Annotations | ||
|
|
||
| Redaction annotations can be removed through the UI or programmatically. | ||
|
|
||
| * Click the Delete button on the toolbar, or | ||
| * Press the `Delete` key after selecting the annotation. | ||
|
|
||
|  | ||
|
|
||
| ## Add Page Redaction in Blazor SfPdfViewer Component | ||
|
|
||
| The Blazor PDF Viewer supports redacting entire pages that contain sensitive or confidential information. Use the built-in UI dialog (to choose specific pages, ranges, or all pages) or perform page redaction programmatically. | ||
|
|
||
|  | ||
|
|
||
| ## Apply Redaction to the Document in Blazor SfPdfViewer Component | ||
|
|
||
| The Blazor PDF Viewer can permanently apply redaction annotations to the document, removing the marked content. This action is irreversible. Apply redaction using the toolbar button or programmatically. | ||
|
|
||
| The Apply Redaction button on the toolbar applies all redaction annotations in the document. | ||
|
|
||
| * The button is disabled when no redaction annotations exist. | ||
| * The button automatically enables when at least one redaction annotation is present. | ||
|
|
||
|  | ||
|
|
||
| A confirmation dialog appears before applying redaction to confirm the irreversible operation. | ||
|
|
||
|  | ||
|
|
||
| N> The redaction process is irreversible. Once applied, the original content cannot be recovered. | ||
|
|
||
| ## Comment Panel Support for Redaction Annotations | ||
|
|
||
| Redaction annotations support comments through the built-in comment panel. Use comments to add notes, track reviews, or record the reason for redaction. | ||
|
|
||
| Comments are available through the UI and API. For details, see the Comments documentation. | ||
|
|
||
| For details, see the [Comments documentation](../annotation/comments). | ||
|
|
||
| ## Export and Import Support for the Redaction Annotations | ||
|
|
||
| The viewer supports exporting and importing redaction annotations to save and reload them for future use. Annotations can be exchanged in JSON format for persistence and sharing. | ||
|
|
||
| For details, see the [Export and import annotations documentation](../annotation/import-export-annotation). | ||
|
|
||
| ## See also | ||
|
|
||
| * [UI Interaction in Redaction Annotation](./ui-interactions) | ||
| * [Programmatic Support in Redaction](./create-programmatically) | ||
| * [Redaction in Mobile View](./redaction-in-mobile-view) |
File renamed without changes
File renamed without changes
Binary file added
BIN
+24.2 KB
...iewer/blazor/redaction/redaction-annotations-images/applied-redaction-annot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+25.6 KB
...-Viewer/blazor/redaction/redaction-annotations-images/apply-redaction-annot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+24.7 KB
...wer/blazor/redaction/redaction-annotations-images/apply-redaction-button-mv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+28.3 KB
...azor/redaction/redaction-annotations-images/apply-redaction-dialog-mv-annot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added
BIN
+27.1 KB
...or/redaction/redaction-annotations-images/delete-redaction-annotation-annot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added
BIN
+25.4 KB
...F-Viewer/blazor/redaction/redaction-annotations-images/page-redaction-annot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.8 KB
...r/blazor/redaction/redaction-annotations-images/page-redaction-dialog-annot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added
BIN
+27 KB
...er/blazor/redaction/redaction-annotations-images/redaction-annotation-annot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added
BIN
+26.6 KB
...-Viewer/blazor/redaction/redaction-annotations-images/redaction-mobile-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+25.8 KB
...er/blazor/redaction/redaction-annotations-images/redaction-properties-annot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20.5 KB
...or/redaction/redaction-annotations-images/redaction-properties-dialog-annot.png
Oops, something went wrong.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added
BIN
+26 KB
...redaction/redaction-annotations-images/review-redaction-annotation-mv-annot.png
SF4524LogeshKumar marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
File renamed without changes
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.