RemoveAllImages.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;
  6. using System.IO;
  7. using System.Drawing;
  8. using System.Text;
  9. using GrapeCity.Documents.Pdf;
  10. using GrapeCity.Documents.Text;
  11. using GrapeCity.Documents.Drawing;
  12.  
  13. namespace DsPdfWeb.Demos
  14. {
  15. // This demo shows how to remove all images from a PDF using the GcPdfDocument.RemoveImages() method.
  16. public class RemoveAllImages
  17. {
  18. public int CreatePDF(Stream stream)
  19. {
  20. using var fs = File.OpenRead(Path.Combine("Resources", "PDFs", "Wetlands.pdf"));
  21. var doc= new GcPdfDocument();
  22. doc.Load(fs);
  23. // Get the list of images in the document:
  24. var imageInfos = doc.GetImages();
  25. // Remove all images:
  26. doc.RemoveImages(imageInfos);
  27. // Done:
  28. doc.Save(stream);
  29. return doc.Pages.Count;
  30. }
  31. }
  32. }
  33.