diff --git a/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/App.config b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/App.config new file mode 100644 index 0000000..193aecc --- /dev/null +++ b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Data/PDF_Succinctly.pdf b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Data/PDF_Succinctly.pdf new file mode 100644 index 0000000..706d6f2 Binary files /dev/null and b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Data/PDF_Succinctly.pdf differ diff --git a/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/DisplayPDFpagesAsThumbnails.csproj b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/DisplayPDFpagesAsThumbnails.csproj new file mode 100644 index 0000000..0a1931f --- /dev/null +++ b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/DisplayPDFpagesAsThumbnails.csproj @@ -0,0 +1,86 @@ + + + + + Debug + AnyCPU + {2D7B60B6-DB7C-4E04-AFDD-C71BFF712F35} + WinExe + DisplayPDFpagesAsThumbnails + DisplayPDFpagesAsThumbnails + v4.8 + 512 + true + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/DisplayPDFpagesAsThumbnails.sln b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/DisplayPDFpagesAsThumbnails.sln new file mode 100644 index 0000000..c62f7b1 --- /dev/null +++ b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/DisplayPDFpagesAsThumbnails.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35707.178 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DisplayPDFpagesAsThumbnails", "DisplayPDFpagesAsThumbnails.csproj", "{2D7B60B6-DB7C-4E04-AFDD-C71BFF712F35}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2D7B60B6-DB7C-4E04-AFDD-C71BFF712F35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2D7B60B6-DB7C-4E04-AFDD-C71BFF712F35}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2D7B60B6-DB7C-4E04-AFDD-C71BFF712F35}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2D7B60B6-DB7C-4E04-AFDD-C71BFF712F35}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/DisplayPDFpagesAsThumbnails_NET.csproj b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/DisplayPDFpagesAsThumbnails_NET.csproj new file mode 100644 index 0000000..b4ca493 --- /dev/null +++ b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/DisplayPDFpagesAsThumbnails_NET.csproj @@ -0,0 +1,15 @@ + + + + WinExe + net8.0-windows + enable + true + enable + + + + + + + \ No newline at end of file diff --git a/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/DisplayPDFpagesAsThumbnails_NET.csproj.user b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/DisplayPDFpagesAsThumbnails_NET.csproj.user new file mode 100644 index 0000000..562025a --- /dev/null +++ b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/DisplayPDFpagesAsThumbnails_NET.csproj.user @@ -0,0 +1,9 @@ + + + + + + Form + + + \ No newline at end of file diff --git a/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/DisplayPDFpagesAsThumbnails_NET.sln b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/DisplayPDFpagesAsThumbnails_NET.sln new file mode 100644 index 0000000..63ec65a --- /dev/null +++ b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/DisplayPDFpagesAsThumbnails_NET.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35707.178 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DisplayPDFpagesAsThumbnails_NET", "DisplayPDFpagesAsThumbnails_NET.csproj", "{7714F1FB-8A22-4268-96D8-4548D7C17409}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7714F1FB-8A22-4268-96D8-4548D7C17409}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7714F1FB-8A22-4268-96D8-4548D7C17409}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7714F1FB-8A22-4268-96D8-4548D7C17409}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7714F1FB-8A22-4268-96D8-4548D7C17409}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Form1.Designer.cs b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Form1.Designer.cs new file mode 100644 index 0000000..82192a7 --- /dev/null +++ b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Form1.Designer.cs @@ -0,0 +1,40 @@ +namespace DisplayPDFpagesAsThumbnails +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "Form1"; + } + + #endregion + } +} + diff --git a/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Form1.cs b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Form1.cs new file mode 100644 index 0000000..8fae8cc --- /dev/null +++ b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Form1.cs @@ -0,0 +1,125 @@ +using Syncfusion.Windows.Forms.PdfViewer; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace DisplayPDFpagesAsThumbnails +{ + public partial class Form1 : Form + { + string filePath; + int thumbnailZoomfactor = 4; + TableLayoutPanel tableLayoutPanel; + FlowLayoutPanel thumbnailLayoutPanel; + PdfViewerControl pdfViewerControl; + public Form1() + { + InitializeComponent(); + this.Load += Form1_Load; + } + + private void Form1_Load(object sender, EventArgs e) + { + //Initialize a new TableLayoutPanel and configure the tableLayoutPanel to hold two column and one row + tableLayoutPanel = new TableLayoutPanel(); + tableLayoutPanel.Dock = DockStyle.Fill; + tableLayoutPanel.ColumnStyles.Clear(); + tableLayoutPanel.ColumnCount = 2; + tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16F)); + tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 84F)); + + tableLayoutPanel.RowStyles.Clear(); + tableLayoutPanel.RowCount = 1; + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + + //Create a Scrolllable layout panel for the thumbnail images + thumbnailLayoutPanel = new FlowLayoutPanel + { + Dock = DockStyle.Fill, + AutoScroll = true, + FlowDirection = FlowDirection.TopDown, + WrapContents = false, + }; + + //Add the thumbnailLayout to the first column of the tableLayoutPanel + tableLayoutPanel.Controls.Add(thumbnailLayoutPanel,0,0); + + pdfViewerControl = new PdfViewerControl(); + pdfViewerControl.Dock = DockStyle.Fill; + //Add the pdfViewer to the second column of the tableLayoutPanel + tableLayoutPanel.Controls.Add(pdfViewerControl,1,0); +#if NETCOREAPP + filePath = @"../../../Data/PDF_Succinctly.pdf"; +#else + filePath = @"../../Data/PDF_Succinctly.pdf"; +#endif + // Load the PDF file. + pdfViewerControl.Load(filePath); + pdfViewerControl.DocumentLoaded += PdfViewerControl_DocumentLoaded; + this.Controls.Add(tableLayoutPanel); + this.WindowState = FormWindowState.Maximized; + } + + /// + /// Triggers once the document is loaded it invoke the conversion of pdf page to image + /// + private void PdfViewerControl_DocumentLoaded(object sender, EventArgs args) + { + thumbnailLayoutPanel.Controls.Clear(); + ExportAsImage(); + } + + /// + /// Converts the PDF pages into images + /// + private async void ExportAsImage() + { + //Calculate height and width of the panel + float height = pdfViewerControl.LoadedDocument.Pages[0].Size.Height / thumbnailZoomfactor; + float width = pdfViewerControl.LoadedDocument.Pages[0].Size.Width / thumbnailZoomfactor; + this.tableLayoutPanel.ColumnStyles[0].SizeType = SizeType.Absolute; + if (pdfViewerControl.LoadedDocument.Pages.Count > 4) + { + this.tableLayoutPanel.ColumnStyles[0].Width = width + 30; + } + else + { + this.tableLayoutPanel.ColumnStyles[0].Width = width + 5; + } + for (int i = 0; i < pdfViewerControl.LoadedDocument.Pages.Count; i++) + { + PictureBox picture = new PictureBox(); + //Convert the PDF page as image + Bitmap image = new Bitmap(await Task.Run(() => pdfViewerControl.LoadedDocument.ExportAsImage(i)), new Size((int)width, (int)height)); + //Set the exported image to the picture control + picture.Image = image; + picture.Update(); + picture.Height = (int)height; + picture.Width = (int)width; + picture.Visible = true; + picture.Refresh(); + picture.MouseUp += Picture_MouseUp; + //Add the picture control to the thumbnailPanel + thumbnailLayoutPanel.Controls.Add(picture); + } + } + + /// + /// Triggered whenever the thumbnail images is clicked + /// + private void Picture_MouseUp(object sender, MouseEventArgs e) + { + PictureBox pictureBox = (PictureBox)sender; + //Get the index of the page + int index = thumbnailLayoutPanel.Controls.IndexOf(pictureBox); + //Navigate to the specified page + pdfViewerControl.GoToPageAtIndex(index + 1); + } + } +} diff --git a/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Form1.resx b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Form1.resx new file mode 100644 index 0000000..d9e357e --- /dev/null +++ b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Form1.resx @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFFTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj00LjAuMC4wLCBDdWx0 + dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABVTeXN0ZW0uRHJh + d2luZy5Qb2ludEYCAAAAAXgBeQAACwsCAAAAAAAAAAAAAAAL + + + \ No newline at end of file diff --git a/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Program.cs b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Program.cs new file mode 100644 index 0000000..e6f88dd --- /dev/null +++ b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace DisplayPDFpagesAsThumbnails +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Properties/AssemblyInfo.cs b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..93f082e --- /dev/null +++ b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Properties/AssemblyInfo.cs @@ -0,0 +1,27 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyDescription("")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("2d7b60b6-db7c-4e04-afdd-c71bff712f35")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// diff --git a/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Properties/Resources.Designer.cs b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Properties/Resources.Designer.cs new file mode 100644 index 0000000..cd663d9 --- /dev/null +++ b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DisplayPDFpagesAsThumbnails.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DisplayPDFpagesAsThumbnails.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Properties/Resources.resx b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Properties/Settings.Designer.cs b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Properties/Settings.Designer.cs new file mode 100644 index 0000000..0f1bdbb --- /dev/null +++ b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DisplayPDFpagesAsThumbnails.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Properties/Settings.settings b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/packages.config b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/packages.config new file mode 100644 index 0000000..93f9167 --- /dev/null +++ b/How-to/How-to-display-PDF-pages-as-thumbnails/DisplayPDFpagesAsThumbnails/packages.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file