Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

how to extract data from a document using c#

void ExtractRegex()  
{  
    using (var fs = File.OpenRead(Path.Combine("Resources", "PDFs", "InvoiceDemo.pdf")))  
    {  
        //Load Sample PDF document  
        GcPdfDocument doc = **new** GcPdfDocument();  
        doc.Load(fs);

        //Find Invoice total amount  
        FindTextParams searchParam1 = **new** FindTextParams(@"(Total)
$([-+]?[0-9]*.?[0-9]+)", false, false, 72, 72, true, true);  
        IList<FoundPosition> pos1 = doc.FindText(searchParam1);  
        string totalAmount = pos1[0].NearText.Substring(pos1[0].PositionInNearText + pos1[0].TextMapFragment[0].Length).TrimStart();  
        Console.WriteLine("Total amount found using regex in FindText method: " + totalAmount);

        //Find customer's email address from Invoice  
        FindTextParams searchParam2 = new FindTextParams(@"[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+", false, false, 72, 72, true, true);  
        IList<FoundPosition> pos2 = doc.FindText(searchParam2);  
        string foundEmail = pos2[0].NearText.Substring(pos2[0].PositionInNearText, pos2[0].TextMapFragment[0].Length);  
        Console.WriteLine("Email Address found using regex in FindText method: " + foundEmail);  
    }  
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: string.format c# 
Csharp :: async method out parameter c# 
Csharp :: [Package Manager Window] Error while fetching labels: User is not logged in or user status invalid. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) 
Csharp :: index sort 
Csharp :: add RowDefinition from cs xamarin 
Csharp :: C# milisecond to h m s 
Csharp :: 2d collision handling jump table 
Csharp :: UnityEngine.Mesh:get_vertices() 
Csharp :: c# skip debug attribute 
Csharp :: upload file add more size webconfig in asp.net mvc 
Csharp :: set-variables-from-an-object-using-reflection 
Csharp :: nodatime instant to datetime off set c# 
Csharp :: edit opened excel file directly 
Csharp :: json.net jobject replace value 
Csharp :: ask int text c# 
Csharp :: clickable table row asp.net core cursor 
Csharp :: How to fill text with 2 different color/texture 
Csharp :: inline c# custom operator implicit 
Csharp :: duplicate global system runtime versioning targetframeworkattribute 
Csharp :: vb.net check operating system 
Csharp :: C# Compound Assignment Operator 
Csharp :: console.out 
Csharp :: telerik mvc grid scroll 
Csharp :: c# system.io check if file exists 
Csharp :: unity exenerate 
Csharp :: asp net identity add a unique fields to user 
Csharp :: how to add serilog to your asp.net project 
Csharp :: telerik mvc grid unbound column 
Csharp :: how to change an object color with fill c# 
Csharp :: RGB Arduino uno r3 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =