RemoveAllImages.cs
//
// This code is part of Document Solutions for PDF demos.
// Copyright (c) MESCIUS inc. All rights reserved.
//
using System;
using System.IO;
using System.Drawing;
using System.Text;
using GrapeCity.Documents.Pdf;
using GrapeCity.Documents.Text;
using GrapeCity.Documents.Drawing;

namespace DsPdfWeb.Demos
{
    // This demo shows how to remove all images from a PDF using the GcPdfDocument.RemoveImages() method.
    public class RemoveAllImages
    {
        public int CreatePDF(Stream stream)
        {
            using var fs = File.OpenRead(Path.Combine("Resources", "PDFs", "Wetlands.pdf"));
            var doc= new GcPdfDocument();
            doc.Load(fs);
            // Get the list of images in the document:            
            var imageInfos = doc.GetImages();
            // Remove all images:
            doc.RemoveImages(imageInfos);
            // Done:
            doc.Save(stream);
            return doc.Pages.Count;
        }
    }
}