From c20affd4bbb96a4254723c5567f42d17e799da40 Mon Sep 17 00:00:00 2001 From: jeyalakshmit Date: Tue, 29 Aug 2023 17:09:05 +0530 Subject: [PATCH] Added the Find Text sample --- .../.NET/Find-text-in-PDF-document.sln | 25 ++++++++++++++++ .../Find-text-in-PDF-document.csproj | 15 ++++++++++ .../.NET/Find-text-in-PDF-document/Input.pdf | Bin 0 -> 6551 bytes .../.NET/Find-text-in-PDF-document/Program.cs | 28 ++++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document.sln create mode 100644 Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document/Find-text-in-PDF-document.csproj create mode 100644 Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document/Input.pdf create mode 100644 Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document/Program.cs 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 0000000000000000000000000000000000000000..e9b4324d1dcefb53f04495365f9e0dffdf39a7e8 GIT binary patch literal 6551 zcmeHMc|6qH`=>>cX_2zDja?X@**A=sF=ZQDBBL@ZGG@liU?NdSJ4Lq8ExFyRRFw5n z+HSU#Jw-&>QzDV=H{43U@2}tYb?@u-{r=bIuQTU7&-*;j`#fh}?{kipJ&6o~8KOa2 z9i30=Kyp|x6wIUV1sNLyWN(g$B>>1AnutYWF?dXtq)Q+afpLHhi|Z-!0>dycfC7dC z+xPKVfE|6WlgO7q5Q+pWnlDJs>!mTpOfDR{a?*!uY?s)SYg z)e*zt*0EN4%N#!v!y?oY>z8=v-drdPmFg6z7XBbc*nEt(ED?=K6VbqMNuMKNPxE96 z!HBu`+~N==V;r6*fdKlF->lu2b^fxLa2ys3IQi2>vy16!Yx7q+UxDY>)!0CH7!fA_~7b+9+nMBN2t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B`-$(D z^qL3d_dVUWO6!-YiT0?x%lFS45?lIlH#)xaX|7SGL;ZZz$t5r`rTsd@qNU+~b_mG^6bA|Ze z@p6UtalomjjiuY=s6MjyKEL-UJm1`hF?qP}JS~&pb^fJ&y>G>(D&x za9Sgx?OxVhPX@;Zu#V1I2j;KntAGU8qLYPu56?-|ZAmn#G#0eb<9>CF)F1Yj7PK={$SgC&V-Y-VPLf}@Z)3zRvQh(HptFq{P$ zizbrMXgCySjw2XjVF(P21h*if%`6ZoBpORJ!&=}hEN~<^2~NhE6LtZXTs99pD}f!q z-rb`xfFqA50?%HiI|5GLK`b!r%T>OsBa02VP+^iwb=a(valnA> 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();