//// This code is part of Document Solutions for PDF .NET demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.IO;usingGrapeCity.Documents.Pdf; namespaceDsPdfWeb.Demos{// This demo shows how to remove images that have a certain aspect ratio// (square, width same as height) from a PDF using the GcPdfDocument.RemoveImages() method.publicclassRemoveSquareImages {publicintCreatePDF(Stream stream) {usingvar fs = File.OpenRead(Path.Combine("Resources", "PDFs", "SlidePages.pdf"));var doc= newGcPdfDocument(); doc.Load(fs);// Get the list of images in the document: var imageInfos = doc.GetImages();// Remove non-square images from the list:for (int i = imageInfos.Count - 1; i >= 0; i--) {if (imageInfos[i].Image.Width != imageInfos[i].Image.Height) imageInfos.RemoveAt(i); }// Remove images left in the list from the PDF: doc.RemoveImages(imageInfos);// Done: doc.Save(stream);return doc.Pages.Count; } }}