ApplyRedact.cs
  1. //
  2. // This code is part of Document Solutions for PDF demos.
  3. // Copyright (c) MESCIUS inc. All rights reserved.
  4. //
  5. using System.IO;
  6. using System.Drawing;
  7. using System.Text.RegularExpressions;
  8. using GrapeCity.Documents.Pdf;
  9. using GrapeCity.Documents.Pdf.Annotations;
  10. using GrapeCity.Documents.Pdf.TextMap;
  11. using GrapeCity.Documents.Pdf.AcroForms;
  12.  
  13. namespace DsPdfWeb.Demos
  14. {
  15. // This sample demonstrates the use of GcPdfDocument.Redact() method.
  16. // It loads the PDF generated by the FindAndRedact sample, in which
  17. // certain areas are marked for redaction, and applies those redacts.
  18. // The original PDF without redact annotations is created by TimeSheet.
  19. public class ApplyRedact
  20. {
  21. public int CreatePDF(Stream stream)
  22. {
  23. var doc = new GcPdfDocument();
  24. using var fs = File.OpenRead(Path.Combine("Resources", "PDFs", "find-and-redact.pdf"));
  25. // Load the PDF containing redact annotations (areas marked for redaction):
  26. doc.Load(fs);
  27.  
  28. // Apply the redacts:
  29. doc.Redact();
  30.  
  31. // Done:
  32. doc.Save(stream);
  33. return doc.Pages.Count;
  34. }
  35. }
  36. }
  37.