'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsSystem.TextImportsGrapeCity.Documents.PdfImportsGrapeCity.Documents.TextImportsGrapeCity.Documents.Drawing '' This sample loads a PDF (we use the document generated by the Wetlands sample)'' and extracts all images from it. It then prints those images into a new PDF,'' centered one per page.PublicClassGetImagesFunctionCreatePDF(ByVal stream AsStream) AsIntegerDim tf = NewTextFormat() With {.Font = StandardFonts.Times, .FontSize = 12}Using fs = NewFileStream(Path.Combine("Resources", "PDFs", "Wetlands.pdf"), FileMode.Open, FileAccess.Read)Dim docSrc = NewGcPdfDocument()'' Load an existing PDF with some images: docSrc.Load(fs)'' This call extracts information about images from the loaded PDF,'' note that for large files it may take a while to complete:Dim imageInfos = docSrc.GetImages() Dim doc = NewGcPdfDocument()Dim textPt = NewPointF(72, 72)Dim imageRc = NewRectangleF(72, 72 * 2, doc.PageSize.Width - 72 * 2, doc.PageSize.Height - 72 * 3) ForEach imageInfo In imageInfos'' The same image may appear on multiple locations,'' imageInfo includes page indices and locations on pages'' for simplicity sake we only print page numbers here:Dim sb = NewStringBuilder() imageInfo.Locations.ForEach(Function(il_) sb.Append((il_.Page.Index + 1).ToString() + ", "))Dim g = doc.NewPage().Graphics g.DrawString($"This image appears on page(s) {sb.ToString().TrimEnd(" "c, ","c)} of the original PDF:", tf, NewPointF(72, 72)) g.DrawImage(imageInfo.Image, imageRc, Nothing, ImageAlign.ScaleImage)Next'' Done: doc.Save(stream)Return doc.Pages.CountEndUsingEndFunctionEndClass