'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsGrapeCity.Documents.Pdf PublicClassRemoveImageLocationPublicFunctionCreatePDF(ByVal stream AsStream) AsIntegerUsing fs = File.OpenRead(Path.Combine("Resources", "PDFs", "ImageTransparency.pdf"))Dim doc = NewGcPdfDocument() doc.Load(fs)' Get the list of images in the document:Dim imageInfos = doc.GetImages()' For each image with multiple locations, remove the leftmost location:ForEach ii In imageInfosIf ii.Locations.Count > 1ThenDim iLeft AsInteger = -1For i = 0To ii.Locations.Count - 1If iLeft = -1OrElse ii.Locations(i).PageBounds.ToRect().Left < ii.Locations(iLeft).PageBounds.ToRect().LeftThen iLeft = iEndIfNext' Remove the locations we want to keep:For i = ii.Locations.Count - 1To0Step -1If i <> iLeft Then ii.Locations.RemoveAt(i)EndIfNext' Remove the locations that are left: doc.RemoveImages({ii})EndIfNext'' Done: doc.Save(stream)Return doc.Pages.CountEndUsingEndFunctionEndClass