//// This code is part of Document Solutions for PDF .NET demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.IO;usingSystem.Collections.Generic;usingGrapeCity.Documents.Pdf;usingGrapeCity.Documents.Drawing; namespaceDsPdfWeb.Demos{// Shows how to create a PDF document from images, with each image representing a full document page.publicclassImagesToPdf {publicintCreatePDF(Stream stream) {var doc = newGcPdfDocument(); // Load the page images from the Resources/ImagesBis folder:var pageImages = newList<(string FileName, Image Image)>();foreach (var fname inDirectory.GetFiles(Path.Combine("Resources", "ImagesBis"), "Wetlands-page*.png", SearchOption.TopDirectoryOnly)) pageImages.Add((Path.GetFileName(fname), Image.FromFile(fname))); // Optional: sort the page images by file name: pageImages.Sort((a, b) => string.Compare(a.FileName, b.FileName)); // Align images to the top-left corner without scaling, cropping, or tiling, while preserving aspect ratio:var align = newImageAlign(ImageAlignHorz.Left, ImageAlignVert.Top, false, false, true, false, false); // Add one page per image and draw the image on the page:foreach (var pageImage in pageImages) {var page = doc.Pages.Add(); page.Graphics.DrawImage(pageImage.Image, page.Bounds, null, align); } // Done: doc.Save(stream);return doc.Pages.Count; } }}