RedactArea.vb
C# VB
'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''Imports System.IOImports System.DrawingImports GrapeCity.Documents.PdfImports GrapeCity.Documents.Pdf.Annotations
'' This sample demonstrates the use of GcPdfDocument.Redact() method.'' It loads the PDF generated by the SlidePages sample, creates'' a redact annotation on the first page, and applies it.Public Class RedactArea Function CreatePDF(ByVal stream As Stream) As Integer Dim doc = New GcPdfDocument() Using fs = New FileStream(Path.Combine("Resources", "PDFs", "SlidePages.pdf"), FileMode.Open, FileAccess.Read) '' Load the PDF containing redact annotations (areas marked for redaction): doc.Load(fs)
Dim rc = New RectangleF(16, 16, 280, 300)
Dim redact = New RedactAnnotation() With { .Rect = rc, .Page = doc.Pages(0), .OverlayText = "This content has been redacted.", .OverlayFillColor = Color.PaleGoldenrod }
'' Apply the redact doc.Redact(redact)
'' doc.Pages(0).Graphics.DrawRectangle(rc, Color.Red)
'' Done doc.Save(stream) Return doc.Pages.Count End Using End FunctionEnd Class