diff --git a/Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document.sln b/Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document.sln new file mode 100644 index 00000000..5478a919 --- /dev/null +++ b/Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32819.101 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Find-text-in-PDF-document", "Find-text-in-PDF-document\Find-text-in-PDF-document.csproj", "{A3B398F4-E8B9-4522-943B-12037BE3A417}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A3B398F4-E8B9-4522-943B-12037BE3A417}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A3B398F4-E8B9-4522-943B-12037BE3A417}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A3B398F4-E8B9-4522-943B-12037BE3A417}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A3B398F4-E8B9-4522-943B-12037BE3A417}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C22A03D0-BE02-4878-B421-6975254E28C6} + EndGlobalSection +EndGlobal diff --git a/Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document/Find-text-in-PDF-document.csproj b/Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document/Find-text-in-PDF-document.csproj new file mode 100644 index 00000000..c44d302a --- /dev/null +++ b/Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document/Find-text-in-PDF-document.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + Find_text_in_PDF_document + enable + enable + + + + + + + diff --git a/Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document/Input.pdf b/Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document/Input.pdf new file mode 100644 index 00000000..e9b4324d Binary files /dev/null and b/Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document/Input.pdf differ diff --git a/Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document/Program.cs b/Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document/Program.cs new file mode 100644 index 00000000..7a78c048 --- /dev/null +++ b/Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document/Program.cs @@ -0,0 +1,28 @@ +// See https://aka.ms/new-console-template for more information + +using Syncfusion.Pdf.Parsing; +using static System.Net.Mime.MediaTypeNames; + +string matchText = string.Empty; +//Load an existing PDF document. +FileStream docStream = new FileStream("../../../Input.pdf", FileMode.Open, FileAccess.Read); +PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream); + +//Returns page number and rectangle positions of the text maches. +Dictionary> matchRects = new Dictionary>(); +loadedDocument.FindText("document", out matchRects); + +for (int i = 0; i < loadedDocument.Pages.Count; i++) +{ + List rectCoords = matchRects[i]; + matchText = "First Occurrence: X:" + rectCoords[0].X + "; Y:" + rectCoords[0].Y + "; Width:" + rectCoords[0].Width + "; Height:" + rectCoords[0].Height + Environment.NewLine + + "Second Occurrence: X:" + rectCoords[1].X + "; Y:" + rectCoords[1].Y + "; Width:" + rectCoords[1].Width + "; Height:" + rectCoords[1].Height + Environment.NewLine + + "Third Occurrence: X:" + rectCoords[2].X + "; Y:" + rectCoords[2].Y + "; Width:" + rectCoords[2].Width + "; Height:" + rectCoords[2].Height + Environment.NewLine + + "Fourth Occurrence: X:" + rectCoords[3].X + "; Y:" + rectCoords[3].Y + "; Width:" + rectCoords[3].Width + "; Height:" + rectCoords[3].Height + Environment.NewLine; +} + +//Close the document. +loadedDocument.Close(true); + +Console.WriteLine(matchText); +Console.ReadLine();