Required Dll: itextsharp.dll
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PDF_READING_BY_RANJEET
{
class Program
{
static void Main(string[] args)
{
string currentText = string.Empty;
string currentLine;
int flag = 0;
PdfReader pdfReader = new PdfReader(@"D:\rk.pdf");
for (int page = 3; page <= pdfReader.NumberOfPages; page++)
{
ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
currentText = currentText + PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy) + Environment.NewLine;
}
//...............................................start....................1................................................................
using (var reader = new StringReader(currentText))
{
while ((currentLine = reader.ReadLine()) != null)
{
SecondTimeSTD: //here it will come second time not first time
if (currentLine.IndexOf("Xyz. Contain", StringComparison.InvariantCultureIgnoreCase) != -1)
{
while ((currentLine = reader.ReadLine()) != null)
{
if ((currentLine.Contains(":") && currentLine.Contains("-")) && currentLine.Contains(":") && currentLine.Contains("."))
{
string[] processCDR = currentLine.Split(' ');
int ranjeetCount = processCDR.Count();
if (ranjeetCount == 7)
{
string time = processCDR[0];
string calledno = processCDR[1];
string destination = processCDR[2];
string duration = processCDR[3];
string callunit = processCDR[4];
string chargaes = processCDR[5];
//first insert into database
}
if (ranjeetCount == 12)
{
string time = processCDR[0];
string calledno = processCDR[1];
string destination = processCDR[2];
string duration = processCDR[3];
string callunit = processCDR[4];
string chargaes = processCDR[5];
//first insert into database
string time2 = processCDR[6];
string calledno2 = processCDR[7];
string destination3 = processCDR[8];
string duration4 = processCDR[9];
string callunit5 = processCDR[10];
string chargaes6 = processCDR[11];
//second insert into database
}
}
else if (currentLine.IndexOf("Xyz. Contain-2", StringComparison.InvariantCultureIgnoreCase) != -1)
{
goto ISD_Section;
}
}
}
ISD_Section:
if (currentLine.IndexOf("Xyz. Contain-3", StringComparison.InvariantCultureIgnoreCase) != -1)
{
while ((currentLine = reader.ReadLine()) != null)
{
if ((currentLine.Contains(":") && currentLine.Contains(":") && currentLine.Contains(".")))
{
string[] processCDR = currentLine.Split(' ');
int ranjeetCount = processCDR.Count();
if (ranjeetCount == 7)
{
string time = processCDR[0];
string calledno = processCDR[1];
string destination = processCDR[2];
string duration = processCDR[3];
string callunit = processCDR[4];
string chargaes = processCDR[5];
//first insert into database
}
if (ranjeetCount == 12)
{
string time = processCDR[0];
string calledno = processCDR[1];
string destination = processCDR[2];
string duration = processCDR[3];
string callunit = processCDR[4];
string chargaes = processCDR[5];
//first insert into database
string time2 = processCDR[6];
string calledno2 = processCDR[7];
string destination3 = processCDR[8];
string duration4 = processCDR[9];
string callunit5 = processCDR[10];
string chargaes6 = processCDR[11];
//second insert into database
}
}
else if (currentLine.IndexOf("Xyz. Contain-4", StringComparison.InvariantCultureIgnoreCase) != -1)
{
goto ZonalCall;
}
}
}
ZonalCall:
flag++;
if (currentLine.IndexOf("Xyz. Contain-4", StringComparison.InvariantCultureIgnoreCase) != -1)
{
while ((currentLine = reader.ReadLine()) != null)
{
if ((currentLine.Contains(":") && currentLine.Contains("-")) && currentLine.Contains(":") && currentLine.Contains("."))
{
string[] processCDR = currentLine.Split(' ');
int ranjeetCount = processCDR.Count();
if (ranjeetCount == 7)
{
string time = processCDR[0];
string calledno = processCDR[1];
string destination = processCDR[2];
string duration = processCDR[3];
string callunit = processCDR[4];
string chargaes = processCDR[5];
//first insert into database
}
if (ranjeetCount == 12)
{
string time = processCDR[0];
string calledno = processCDR[1];
string destination = processCDR[2];
string duration = processCDR[3];
string callunit = processCDR[4];
string chargaes = processCDR[5];
//first insert into database
string time2 = processCDR[6];
string calledno2 = processCDR[7];
string destination3 = processCDR[8];
string duration4 = processCDR[9];
string callunit5 = processCDR[10];
string chargaes6 = processCDR[11];
//second insert into database
}
}
else if (flag == 65)
{
if (currentLine.IndexOf("abc", StringComparison.InvariantCultureIgnoreCase) != -1)
{
goto SecondTimeSTD;
}
}
}
}
}
}
//................end....................1................................................................
ExitPDF:
Console.WriteLine("I am going Out ranjeet");
}
}
}
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PDF_READING_BY_RANJEET
{
class Program
{
static void Main(string[] args)
{
string currentText = string.Empty;
string currentLine;
int flag = 0;
PdfReader pdfReader = new PdfReader(@"D:\rk.pdf");
for (int page = 3; page <= pdfReader.NumberOfPages; page++)
{
ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
currentText = currentText + PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy) + Environment.NewLine;
}
//...............................................start....................1................................................................
using (var reader = new StringReader(currentText))
{
while ((currentLine = reader.ReadLine()) != null)
{
SecondTimeSTD: //here it will come second time not first time
if (currentLine.IndexOf("Xyz. Contain", StringComparison.InvariantCultureIgnoreCase) != -1)
{
while ((currentLine = reader.ReadLine()) != null)
{
if ((currentLine.Contains(":") && currentLine.Contains("-")) && currentLine.Contains(":") && currentLine.Contains("."))
{
string[] processCDR = currentLine.Split(' ');
int ranjeetCount = processCDR.Count();
if (ranjeetCount == 7)
{
string time = processCDR[0];
string calledno = processCDR[1];
string destination = processCDR[2];
string duration = processCDR[3];
string callunit = processCDR[4];
string chargaes = processCDR[5];
//first insert into database
}
if (ranjeetCount == 12)
{
string time = processCDR[0];
string calledno = processCDR[1];
string destination = processCDR[2];
string duration = processCDR[3];
string callunit = processCDR[4];
string chargaes = processCDR[5];
//first insert into database
string time2 = processCDR[6];
string calledno2 = processCDR[7];
string destination3 = processCDR[8];
string duration4 = processCDR[9];
string callunit5 = processCDR[10];
string chargaes6 = processCDR[11];
//second insert into database
}
}
else if (currentLine.IndexOf("Xyz. Contain-2", StringComparison.InvariantCultureIgnoreCase) != -1)
{
goto ISD_Section;
}
}
}
ISD_Section:
if (currentLine.IndexOf("Xyz. Contain-3", StringComparison.InvariantCultureIgnoreCase) != -1)
{
while ((currentLine = reader.ReadLine()) != null)
{
if ((currentLine.Contains(":") && currentLine.Contains(":") && currentLine.Contains(".")))
{
string[] processCDR = currentLine.Split(' ');
int ranjeetCount = processCDR.Count();
if (ranjeetCount == 7)
{
string time = processCDR[0];
string calledno = processCDR[1];
string destination = processCDR[2];
string duration = processCDR[3];
string callunit = processCDR[4];
string chargaes = processCDR[5];
//first insert into database
}
if (ranjeetCount == 12)
{
string time = processCDR[0];
string calledno = processCDR[1];
string destination = processCDR[2];
string duration = processCDR[3];
string callunit = processCDR[4];
string chargaes = processCDR[5];
//first insert into database
string time2 = processCDR[6];
string calledno2 = processCDR[7];
string destination3 = processCDR[8];
string duration4 = processCDR[9];
string callunit5 = processCDR[10];
string chargaes6 = processCDR[11];
//second insert into database
}
}
else if (currentLine.IndexOf("Xyz. Contain-4", StringComparison.InvariantCultureIgnoreCase) != -1)
{
goto ZonalCall;
}
}
}
ZonalCall:
flag++;
if (currentLine.IndexOf("Xyz. Contain-4", StringComparison.InvariantCultureIgnoreCase) != -1)
{
while ((currentLine = reader.ReadLine()) != null)
{
if ((currentLine.Contains(":") && currentLine.Contains("-")) && currentLine.Contains(":") && currentLine.Contains("."))
{
string[] processCDR = currentLine.Split(' ');
int ranjeetCount = processCDR.Count();
if (ranjeetCount == 7)
{
string time = processCDR[0];
string calledno = processCDR[1];
string destination = processCDR[2];
string duration = processCDR[3];
string callunit = processCDR[4];
string chargaes = processCDR[5];
//first insert into database
}
if (ranjeetCount == 12)
{
string time = processCDR[0];
string calledno = processCDR[1];
string destination = processCDR[2];
string duration = processCDR[3];
string callunit = processCDR[4];
string chargaes = processCDR[5];
//first insert into database
string time2 = processCDR[6];
string calledno2 = processCDR[7];
string destination3 = processCDR[8];
string duration4 = processCDR[9];
string callunit5 = processCDR[10];
string chargaes6 = processCDR[11];
//second insert into database
}
}
else if (flag == 65)
{
if (currentLine.IndexOf("abc", StringComparison.InvariantCultureIgnoreCase) != -1)
{
goto SecondTimeSTD;
}
}
}
}
}
}
//................end....................1................................................................
ExitPDF:
Console.WriteLine("I am going Out ranjeet");
}
}
}
No comments:
Post a Comment