-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from SyncfusionExamples/Find-text-sample
841800 -Added the Find Text sample
- Loading branch information
Showing
4 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
15 changes: 15 additions & 0 deletions
15
...Find-text-in-PDF-document/.NET/Find-text-in-PDF-document/Find-text-in-PDF-document.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<RootNamespace>Find_text_in_PDF_document</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.Pdf.NET" Version="22.2.11" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Binary file added
BIN
+6.4 KB
Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document/Input.pdf
Binary file not shown.
28 changes: 28 additions & 0 deletions
28
Text/Find-text-in-PDF-document/.NET/Find-text-in-PDF-document/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<int, List<Syncfusion.Drawing.RectangleF>> matchRects = new Dictionary<int, List<Syncfusion.Drawing.RectangleF>>(); | ||
loadedDocument.FindText("document", out matchRects); | ||
|
||
for (int i = 0; i < loadedDocument.Pages.Count; i++) | ||
{ | ||
List<Syncfusion.Drawing.RectangleF> 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(); |