RedactArea.vb
  1. ''
  2. '' This code is part of Document Solutions for PDF demos.
  3. '' Copyright (c) MESCIUS inc. All rights reserved.
  4. ''
  5. Imports System.IO
  6. Imports System.Drawing
  7. Imports System.Text.RegularExpressions
  8. Imports GrapeCity.Documents.Pdf
  9. Imports GrapeCity.Documents.Pdf.Annotations
  10. Imports GrapeCity.Documents.Pdf.TextMap
  11. Imports GrapeCity.Documents.Pdf.AcroForms
  12.  
  13. '' This sample demonstrates the use of GcPdfDocument.Redact() method.
  14. '' It loads the PDF generated by the SlidePages sample, creates
  15. '' a redact annotation on the first page, and applies it.
  16. Public Class RedactArea
  17. Function CreatePDF(ByVal stream As Stream) As Integer
  18. Dim doc = New GcPdfDocument()
  19. Using fs = New FileStream(Path.Combine("Resources", "PDFs", "SlidePages.pdf"), FileMode.Open, FileAccess.Read)
  20. '' Load the PDF containing redact annotations (areas marked for redaction):
  21. doc.Load(fs)
  22.  
  23. Dim rc = New RectangleF(16, 16, 280, 300)
  24.  
  25. Dim redact = New RedactAnnotation() With
  26. {
  27. .Rect = rc,
  28. .Page = doc.Pages(0),
  29. .OverlayText = "This content has been redacted.",
  30. .OverlayFillColor = Color.PaleGoldenrod
  31. }
  32.  
  33. '' Apply the redact
  34. doc.Redact(redact)
  35.  
  36. '' doc.Pages(0).Graphics.DrawRectangle(rc, Color.Red)
  37.  
  38. '' Done
  39. doc.Save(stream)
  40. Return doc.Pages.Count
  41. End Using
  42. End Function
  43. End Class
  44.